mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 09:53:18 +00:00
8364987: javac fails with an exception when looking for diamond creation
Reviewed-by: vromero
This commit is contained in:
parent
1fc0b01601
commit
8b5bb01355
@ -240,7 +240,7 @@ public class Analyzer {
|
||||
|
||||
@Override
|
||||
List<JCNewClass> rewrite(JCNewClass oldTree) {
|
||||
if (oldTree.clazz.hasTag(TYPEAPPLY)) {
|
||||
if (oldTree.clazz.hasTag(TYPEAPPLY) && !oldTree.type.isErroneous()) {
|
||||
JCNewClass nc = copier.copy(oldTree);
|
||||
((JCTypeApply)nc.clazz).arguments = List.nil();
|
||||
return List.of(nc);
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8349132
|
||||
* @bug 8349132 8364987
|
||||
* @summary Check behavior of the diamond analyzer
|
||||
* @library /tools/lib
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
@ -139,4 +139,43 @@ public class Diamond extends TestRunner {
|
||||
}
|
||||
}
|
||||
|
||||
@Test //JDK-8364987:
|
||||
public void testNoCrashErroneousTypes(Path base) throws Exception {
|
||||
Path current = base.resolve(".");
|
||||
Path src = current.resolve("src");
|
||||
Path classes = current.resolve("classes");
|
||||
tb.writeJavaFiles(src,
|
||||
"""
|
||||
public class Test {
|
||||
void t() {
|
||||
L<Object> l = new L<Test>();
|
||||
}
|
||||
static class L<T> { }
|
||||
}
|
||||
""");
|
||||
|
||||
Files.createDirectories(classes);
|
||||
|
||||
var out = new JavacTask(tb)
|
||||
.options("-XDfind=diamond",
|
||||
"-XDshould-stop.at=FLOW",
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(tb.findJavaFiles(src))
|
||||
.run(Task.Expect.FAIL)
|
||||
.writeAll()
|
||||
.getOutputLines(Task.OutputKind.DIRECT);
|
||||
|
||||
var expectedOut = List.of(
|
||||
"Test.java:3:23: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: Test.L<Test>, Test.L<java.lang.Object>)",
|
||||
"1 error"
|
||||
);
|
||||
|
||||
if (!Objects.equals(expectedOut, out)) {
|
||||
throw new AssertionError("Incorrect Output, expected: " + expectedOut +
|
||||
", actual: " + out);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user