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 {
16701670 /** Holds if this instance access is to an enclosing instance of type `t`. */
16711671 predicate isEnclosingInstanceAccess ( RefType t ) {
16721672 t = this .getQualifier ( ) .getType ( ) .( RefType ) .getSourceDeclaration ( ) and
1673- t != this .getEnclosingCallable ( ) .getDeclaringType ( )
1673+ t != this .getEnclosingCallable ( ) .getDeclaringType ( ) and
1674+ not this .isSuperInterfaceAccess ( )
16741675 or
1675- not exists ( this .getQualifier ( ) ) and
1676+ ( not exists ( this .getQualifier ( ) ) or this . isSuperInterfaceAccess ( ) ) and
16761677 exists ( LambdaExpr lam | lam .asMethod ( ) = this .getEnclosingCallable ( ) |
16771678 t = lam .getAnonymousClass ( ) .getEnclosingType ( )
16781679 )
16791680 }
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+ }
16801692}
16811693
16821694/**
You can’t perform that action at this time.
0 commit comments