private void tryReplaceSuper ( Node superNode ) { checkState ( ! superclasses . isEmpty ( ) , "`super` cannot appear outside a function" ) ; Optional < Node > currentSuperclass = superclasses . peek ( ) ; if ( ! currentSuperclass . isPresent ( ) || ! currentSuperclass . get ( ) . isQualifiedName ( ) ) { // either if a) we're in a static class fn without an 'extends' clause or b) we're not in // a static class function return ; } Node fullyQualifiedSuperRef = currentSuperclass . get ( ) . cloneTree ( ) ; superNode . replaceWith ( fullyQualifiedSuperRef ) ; compiler . reportChangeToEnclosingScope ( fullyQualifiedSuperRef ) ; }
Replaces super with Super . Class if in a static class method with a qname superclass