Skip to content

Commit

Permalink
Make a defensive null check in SameNameButDifferent.
Browse files Browse the repository at this point in the history
Fixes(?) external #3245.

(I haven't included a test as the external bug doesn't have a repro, and is apparently in generated code: which makes me assume something odd is going on.)

PiperOrigin-RevId: 458755521
  • Loading branch information
graememorgan authored and Error Prone Team committed Jul 14, 2022
1 parent 49e4b34 commit dd6cb39
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -183,6 +183,9 @@ private static Optional<Symbol> getBetterImport(TypeSymbol classSymbol, String s
Symbol owner = classSymbol;
long dots = simpleName.chars().filter(c -> c == '.').count();
for (long i = 0; i < dots + 1; ++i) {
if (owner == null) {
return Optional.empty();
}
owner = owner.owner;
}
if (owner instanceof ClassSymbol) {
Expand Down

0 comments on commit dd6cb39

Please sign in to comment.