File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
java/ql/lib/semmle/code/java Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1670,13 +1670,25 @@ abstract class InstanceAccess extends Expr {
1670
1670
/** Holds if this instance access is to an enclosing instance of type `t`. */
1671
1671
predicate isEnclosingInstanceAccess ( RefType t ) {
1672
1672
t = this .getQualifier ( ) .getType ( ) .( RefType ) .getSourceDeclaration ( ) and
1673
- t != this .getEnclosingCallable ( ) .getDeclaringType ( )
1673
+ t != this .getEnclosingCallable ( ) .getDeclaringType ( ) and
1674
+ not this .isSuperInterfaceAccess ( )
1674
1675
or
1675
- not exists ( this .getQualifier ( ) ) and
1676
+ ( not exists ( this .getQualifier ( ) ) or this . isSuperInterfaceAccess ( ) ) and
1676
1677
exists ( LambdaExpr lam | lam .asMethod ( ) = this .getEnclosingCallable ( ) |
1677
1678
t = lam .getAnonymousClass ( ) .getEnclosingType ( )
1678
1679
)
1679
1680
}
1681
+
1682
+ // A default method on an interface, `I`, may be invoked using `I.super.m()`.
1683
+ // This always refers to the implemented interfaces of `this`. This form of
1684
+ // qualified `super` cannot be combined with accessing an enclosing instance.
1685
+ // JLS 15.11.2. "Accessing Superclass Members using super"
1686
+ // JLS 15.12. "Method Invocation Expressions"
1687
+ // JLS 15.12.1. "Compile-Time Step 1: Determine Type to Search"
1688
+ private predicate isSuperInterfaceAccess ( ) {
1689
+ this instanceof SuperAccess and
1690
+ this .getQualifier ( ) .getType ( ) .( RefType ) .getSourceDeclaration ( ) instanceof Interface
1691
+ }
1680
1692
}
1681
1693
1682
1694
/**
You can’t perform that action at this time.
0 commit comments