redhat-developer / redhat-developer/vscode-java
Generified method call shows "cannot convert from Object to boolean" error
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 546
- Avg merge
- 20h 1m
- Merged PRs (30d)
- 11
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Java snippet in VS Codium with JDK 17 and inspect the diagnostic produced for the generic method call. Done means the direct use of someMethod() in the if condition no longer reports a conversion error, while the shown reproduction remains covered by a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100