Repository navigation
Checking of boxed primitives (e.g. Double) for case null with JEP 441 #3830
Description
Activity
I have a similar issue where an error is shown in vs-codium, but the code compiles in other IDEs and with maven CLI just fine.
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 ofthis.someMethod()is stored in a Boolean var firstExpected Result
No compilation error should be seen here
Does not properly support checking of boxed Double or Float for case null with JEP 441 pattern switching. Instead it shows Case constants in a switch on 'Double' must have type 'double' Java(2099252).
This issue has been fixed in VS Code pre-release
I have a similar issue where an error is shown in vs-codium, but the code compiles in other IDEs and with maven CLI just fine.
"java.jdt.ls.javac.enabled": "on",fixes this.@snjeza Sadly i am limited to java 17 so can't use this javac feature
Sadly i am limited to java 17 so can't use this javac feature
@sworthiness You only need to run VS Code with Java 23. Your project can use JDK >= 1.8
@sworthiness Could you provide a project example?
@snjeza if you’re asking for an example of this issue, i’ve given one above that is easily reproducible
If youre asking for an example of the issue i just linked, i will list it thereIf youre asking for an example of the issue i just linked, i will list it there
I have asked for an example of the linked issue.
The original issue with boxed primitives is fixed, so I'm closing this issue. I've opened #4211 specifically for the other one found by @sworthiness.
Hvala @snjeza!
Does not properly support checking of boxed
DoubleorFloatforcase nullwith JEP 441 pattern switching. Instead it showsCase constants in a switch on 'Double' must have type 'double' Java(2099252).Environment
Steps To Reproduce
Current Result
This displays the following error in VSCode:
Expected Result
As Java 21 compiles and runs the above code it should not show an error.