Skip to content

Commit

Permalink
Fix a crash in NonCanonicalType on module symbols
Browse files Browse the repository at this point in the history
Fixes #3639

PiperOrigin-RevId: 498646740
  • Loading branch information
cushon authored and Error Prone Team committed Dec 31, 2022
1 parent 145138b commit 721096f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ private static String canonicalName(MemberSelectTree tree) {
if (!(sym instanceof Symbol.TypeSymbol)) {
return null;
}
return sym.owner.getQualifiedName() + "." + sym.getSimpleName();
Symbol owner = sym.owner;
if (owner == null) {
// module symbols don't have owners
return null;
}
return owner.getQualifiedName() + "." + sym.getSimpleName();
}

private static final Pattern PACKAGE_CLASS_NAME_SPLITTER = Pattern.compile("(.*?)\\.([A-Z].*)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,16 @@ public void innerArray() {
"}")
.doTest();
}

// see https://github.com/google/error-prone/issues/3639
@Test
public void moduleInfo() {
compilationHelper
.addSourceLines(
"module-info.java", //
"module testmodule {",
" requires java.base;",
"}")
.doTest();
}
}

0 comments on commit 721096f

Please sign in to comment.