Skip to content
Permalink
Browse files
Fix enclosingPackage after 3ac0471
PiperOrigin-RevId: 441783482
  • Loading branch information
cushon authored and Error Prone Team committed Apr 14, 2022
1 parent f6323b2 commit 8fa64d48f3a1d8df852ed2546ba02b0e2b7585af
Showing 1 changed file with 2 additions and 1 deletion.
@@ -1163,10 +1163,11 @@ public static ClassSymbol enclosingClass(Symbol sym) {
@Nullable
public static PackageSymbol enclosingPackage(Symbol sym) {
Symbol curr = sym;
for (; curr != null && curr.owner != null; curr = curr.owner) {
while (curr != null) {
if (curr.getKind().equals(ElementKind.PACKAGE)) {
return (PackageSymbol) curr;
}
curr = curr.owner;
}
return null;
}

0 comments on commit 8fa64d4

Please sign in to comment.