vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

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

Open fbricon opened this issue 1 month ago • 0 comments

Extracted this issue from https://github.com/redhat-developer/vscode-java/issues/3830#issuecomment-2519729457, 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

fbricon avatar Oct 14 '25 10:10 fbricon