提交 24b28329 编写于 作者: V vromero

8059921: Missing compile error in Java 8 mode for Interface.super.field access

Reviewed-by: mcimadamore, jlahoda
上级 14ad5d78
...@@ -3243,6 +3243,10 @@ public class Attr extends JCTree.Visitor { ...@@ -3243,6 +3243,10 @@ public class Attr extends JCTree.Visitor {
// Determine the symbol represented by the selection. // Determine the symbol represented by the selection.
env.info.pendingResolutionPhase = null; env.info.pendingResolutionPhase = null;
Symbol sym = selectSym(tree, sitesym, site, env, resultInfo); Symbol sym = selectSym(tree, sitesym, site, env, resultInfo);
if (sym.kind == VAR && sym.name != names._super && env.info.defaultSuperCallSite != null) {
log.error(tree.selected.pos(), "not.encl.class", site.tsym);
sym = syms.errSymbol;
}
if (sym.exists() && !isType(sym) && (pkind() & (PCK | TYP)) != 0) { if (sym.exists() && !isType(sym) && (pkind() & (PCK | TYP)) != 0) {
site = capture(site); site = capture(site);
sym = selectSym(tree, sitesym, site, env, resultInfo); sym = selectSym(tree, sitesym, site, env, resultInfo);
......
/*
* @test /nodynamiccopyright/
* @bug 8059921
* @summary Missing compile error in Java 8 mode for Interface.super.field access
* @compile/fail/ref=ForbidAccessToFieldUsingSuperTest.out -XDrawDiagnostics ForbidAccessToFieldUsingSuperTest.java
*/
public class ForbidAccessToFieldUsingSuperTest {
class C {
int m() { return 0; }
}
interface T {
int f = 0;
C c = null;
default int mm() {
return 0;
}
}
interface T1 extends T {}
class X implements T1 {
int i = T1.super.f; //fail
int j = T1.super.c.m(); //fail
void foo(Runnable r) {
foo(T1.super::mm); //should'n fail
}
}
}
ForbidAccessToFieldUsingSuperTest.java:24:19: compiler.err.not.encl.class: ForbidAccessToFieldUsingSuperTest.T1
ForbidAccessToFieldUsingSuperTest.java:25:19: compiler.err.not.encl.class: ForbidAccessToFieldUsingSuperTest.T1
2 errors
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册