21
21
import static com .google .errorprone .fixes .SuggestedFixes .addModifiers ;
22
22
import static com .google .errorprone .matchers .Description .NO_MATCH ;
23
23
import static com .google .errorprone .matchers .Matchers .SERIALIZATION_METHODS ;
24
+ import static com .google .errorprone .util .ASTHelpers .enclosingClass ;
24
25
import static com .google .errorprone .util .ASTHelpers .getStartPosition ;
25
26
import static com .google .errorprone .util .ASTHelpers .streamSuperMethods ;
26
27
import static java .util .Collections .disjoint ;
@@ -233,7 +234,7 @@ public Void visitMemberReference(MemberReferenceTree tree, Void unused) {
233
234
234
235
private void fixQualifier (Tree tree , ExpressionTree qualifierExpression ) {
235
236
if (sym .equals (ASTHelpers .getSymbol (tree ))) {
236
- builder .replace (qualifierExpression , sym . owner . enclClass ( ).getSimpleName ().toString ());
237
+ builder .replace (qualifierExpression , enclosingClass ( sym ).getSimpleName ().toString ());
237
238
}
238
239
}
239
240
}.scan (state .getPath ().getCompilationUnit (), null );
@@ -248,11 +249,11 @@ private static boolean isExcluded(MethodTree tree, VisitorState state) {
248
249
if (!ASTHelpers .canBeRemoved (sym , state ) || ASTHelpers .shouldKeep (tree )) {
249
250
return true ;
250
251
}
251
- switch (sym . owner . enclClass ( ).getNestingKind ()) {
252
+ switch (enclosingClass ( sym ).getNestingKind ()) {
252
253
case TOP_LEVEL -> {}
253
254
case MEMBER -> {
254
255
if (!SourceVersion .supportsStaticInnerClass (state .context )
255
- && sym . owner . enclClass ( ).hasOuterInstance ()) {
256
+ && enclosingClass ( sym ).hasOuterInstance ()) {
256
257
return true ;
257
258
}
258
259
}
0 commit comments