Import computer: a type used only as a constructor call's type argument (var x = new Box<Sol>()) is not imported
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 67/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- java
调研方向
Start by locating javaInspector.importComputer and the code that collects types used by constructor calls; the issue reproduces the omission with new Box<Sol>(4) when assigned to var. Run the reproduction through javaInspector.print2 and check that the output includes import a.c.Sol; and compiles with javac. The issue names no test file, so first look for existing import computer tests and add the case there.
由索引模型根据 Issue 内容生成。
描述
A type that a unit uses only as a type argument of a constructor call, as in var x = new Box<Sol>(4), loses its import: the import computer does not collect it.
package a.c;
public class Sol { }
package a.b;
public class Box<S> { public Box(int i) { } }
package a.b;
import a.c.Sol;
public class V {
Object m() {
var box = new Box<Sol>(4);
return box;
}
}
javaInspector.print2(cu, null, javaInspector.importComputer(4, cu.sourceSet())) prints
package a.b;
public class V { Object m() { var box = new Box<Sol>(4); return box; } }
without import a.c.Sol;, and javac rejects it. With var, the constructor call's type arguments are the only place the type is written, so nothing else brings the import in.
Found re-parsing printed sources of timefold-solver, where this is a common style: var termination = new MoveCountTermination<TestdataSolution>(4), var map = new HashMap<Class<?>, Set<Object>>(), new LinkedHashMap<Class<?>, List<AbstractRootNode<?>>>(), ... 10 units are dropped for it in one run (TestdataSolution, Set, List, ConstraintMetaModel, MoveSelector, TestdataListSolution).
maddi 0.9.6-alpha.4.
- 主要语言
- Java
- 星标
- 1
- 派生
- 1
- 平均合并
- 1 小时 55 分钟
- 30 天内合并 PR
- 8
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
CodeLaser/maddi 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
build/ci good first issue
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
Java printer: a nested type prints by simple name when the unit imports another type of that name未关闭bug
难度 3/5 1-2 天 新手友好度 57/100
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 66/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
oracle/graalvm-reachability-metadata#11472 ·
维护者通常 1 天内回复
-
OkHttp versions 5.4.0+ no longer include baseline-prof.txt可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 1/5 1 小时以内 新手友好度 83/100
lysine-dev/okhttp#9828 ·
维护者通常 1 天内回复
-
status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 70/100
spring-projects/spring-ai#7269 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 89/100
objectionary/hone-maven-plugin#1353 ·
维护者通常 9 天内回复
-
ClassNotFoundException: io.netty.channel.kqueue.KQueueEventLoop stack trace printed during native build on main (Netty 4.2 removed the class)可能已有人在做 @gastaldi 今天认领。 未关闭area/netty kind/bug
难度 2/5 1-3 小时 新手友好度 68/100
quarkusio/quarkus#57939 · 1 条评论 ·
维护者通常 1 天内回复