Skip to content

Commit 27a9a2f

Browse files
committedJul 29, 2020
8249261: AssertionError in StructuralStuckChecker
Reviewed-by: mcimadamore
1 parent b37228e commit 27a9a2f

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
 

‎src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java

+7
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,13 @@ public void visitApply(JCMethodInvocation tree) {
918918
//do nothing
919919
}
920920

921+
@Override
922+
public void visitConditional(JCTree.JCConditional tree) {
923+
//skip tree.cond
924+
scan(tree.truepart);
925+
scan(tree.falsepart);
926+
}
927+
921928
@Override
922929
public void visitReference(JCMemberReference tree) {
923930
Assert.checkNonNull(tree.getOverloadKind());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* @test /nodynamiccopyright/
3+
* @bug 8249261
4+
* @summary Verify method references as conditions to conditional expressions
5+
* are handled properly.
6+
* @compile/fail/ref=MethodRefStuck8249261.out -XDrawDiagnostics MethodRefStuck8249261.java
7+
*/
8+
class MethodRefStuck8249261 {
9+
10+
void p(int padding) {}
11+
12+
static boolean t() {
13+
return true;
14+
}
15+
16+
private void test() {
17+
p(MethodRefStuck8249261::t);
18+
p((MethodRefStuck8249261::t));
19+
p(MethodRefStuck8249261::t + 1);
20+
p(MethodRefStuck8249261::t ? 1 : 0);
21+
p(true ? MethodRefStuck8249261::t : 0);
22+
p(switch (MethodRefStuck8249261::t) { default -> 0; });
23+
p(() -> true);
24+
p((() -> true));
25+
p((() -> true) + 1);
26+
p((() -> true) ? 1 : 0);
27+
p(true ? (() -> true) : 0);
28+
p(switch ((() -> true)) { default -> 0; });
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
MethodRefStuck8249261.java:17:9: compiler.err.cant.apply.symbol: kindname.method, p, int, @11, kindname.class, MethodRefStuck8249261, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))
2+
MethodRefStuck8249261.java:18:9: compiler.err.cant.apply.symbol: kindname.method, p, int, @11, kindname.class, MethodRefStuck8249261, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))
3+
MethodRefStuck8249261.java:19:11: compiler.err.unexpected.mref
4+
MethodRefStuck8249261.java:20:11: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: boolean)
5+
MethodRefStuck8249261.java:21:9: compiler.err.cant.apply.symbol: kindname.method, p, int, @16, kindname.class, MethodRefStuck8249261, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.not.a.functional.intf: int)))
6+
MethodRefStuck8249261.java:22:19: compiler.err.unexpected.mref
7+
MethodRefStuck8249261.java:23:9: compiler.err.cant.apply.symbol: kindname.method, p, int, @11, kindname.class, MethodRefStuck8249261, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))
8+
MethodRefStuck8249261.java:24:9: compiler.err.cant.apply.symbol: kindname.method, p, int, @11, kindname.class, MethodRefStuck8249261, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))
9+
MethodRefStuck8249261.java:25:12: compiler.err.unexpected.lambda
10+
MethodRefStuck8249261.java:26:12: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: boolean)
11+
MethodRefStuck8249261.java:27:9: compiler.err.cant.apply.symbol: kindname.method, p, int, @16, kindname.class, MethodRefStuck8249261, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.not.a.functional.intf: int)))
12+
MethodRefStuck8249261.java:28:20: compiler.err.unexpected.lambda
13+
12 errors

0 commit comments

Comments
 (0)
Please sign in to comment.