Generified method call shows "cannot convert from Object to boolean" error
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
调研方向
使用 JDK 17 在 VS Codium 中复现 Java 代码片段,并检查为泛型方法调用生成的诊断。完成标准是:在 if 条件中直接使用 someMethod() 不再报告转换错误,同时所示复现仍由回归检查覆盖。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 547
- 平均合并
- 5 小时 36 分钟
- 30 天内合并 PR
- 10
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
redhat-developer/vscode-java 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
redhat-developer/vscode-java#4511 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
redhat-developer/vscode-java#4426 ·
维护者通常 4 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 45/100
redhat-developer/vscode-java#4506 · 6 条评论 · 4 个 reaction ·
维护者通常 4 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 45/100
redhat-developer/vscode-java#4505 · 5 条评论 · 2 个 reaction ·
维护者通常 4 天内回复
-
难度 4/5 3-5 天 新手友好度 52/100
redhat-developer/vscode-java#4504 · 3 条评论 · 1 个 reaction ·
维护者通常 4 天内回复
查看 redhat-developer/vscode-java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
opengovsg/FormSG#10118 · 1 条评论 ·
维护者通常 1 天内回复
-
ai-driven-qa bug claude
难度 1/5 1 小时以内 新手友好度 75/100
linagora/twake-calendar-frontend#1434 · 1 条评论 ·
维护者通常 1 天内回复
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 78/100
jaegertracing/jaeger-ui#4512 ·
维护者通常 1 天内回复
-
area:ide documentation enhancement platform:macos platform:vscode
难度 1/5 1-3 小时 新手友好度 88/100
anthropics/claude-code#97389 ·
维护者通常 1 天内回复