Skip to content

Generified method call shows "cannot convert from Object to boolean" error #4211

Open

Description

@fbricon

Extracted this issue from #3830 (comment), from @sworthiness

Error:

Type mismatch: cannot convert from Object to boolean Java(16777233)

Environment:

(VS Codium - SSH remote development)

  • Version: 1.95.3
  • Release: 24321
  • Commit: dc5a551c256719475d2d0959270e3836c9bbb632
  • Date: 2024-11-16T09:16:49.983Z
  • Electron: 32.2.5
  • ElectronBuildId: undefined
  • Chromium: 128.0.6613.186
  • Node.js: 20.18.0
  • V8: 12.8.374.38-electron.0
  • OS: Windows_NT x64 10.0.19045
  • JDK: 17

Steps to reproduce

public class Test {
  public <T> T someMethod() {
    return (T) Boolean.TRUE;
  }

  public void someOtherMethod() {
    if (this.someMethod()) { // Type mismatch: cannot convert from Object to boolean Java(16777233)
    }
  }
}

Current Result

The following compilation error is shown in vs-codium:
Type mismatch: cannot convert from Object to boolean Java(16777233)
The error is not seen if the result of this.someMethod() is stored in a Boolean var first

Expected Result

No compilation error should be seen here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions