Skip to content

Commit

Permalink
Update entry class specification to export both the class and associa…
Browse files Browse the repository at this point in the history
…ted members.

PiperOrigin-RevId: 366359998
  • Loading branch information
Dino Oliva authored and copybara-github committed Apr 2, 2021
1 parent a58e44f commit ffa780e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,9 @@ private MemberInfo popMethodScope() {

private void startMethodDeclaration(
String methodName, boolean isConstructor, boolean isStatic) {
boolean isExported = exportedMethods.contains(
getQualifiedMethodName(currentTypeNameScope.peek(), methodName));
boolean isExported =
exportedMethods.contains(getQualifiedMethodName(currentTypeNameScope.peek(), methodName))
|| currentTypeInfoScope.peek().getExported();
logger.atFine().log("Start Method: %s.%s : isConstructor: %s : isStatic: %s, exported: %b",
currentTypeNameScope.peek(), methodName, isConstructor, isStatic, isExported);
pushMethodScope(methodName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ public void testExportedClass() throws IOException {
assertThat(getUnusedClasses(unused)).containsNoneOf("A", "b.c.C");
assertThat(getUnusedClasses(unused)).containsExactly("b.B");

assertThat(getUnusedMethods(unused)).containsExactly(
assertThat(getUnusedMethods(unused)).containsNoneOf(
getMethodName("A", "A", "()V"),
getMethodName("A", "main", "([Ljava/lang/String;)V"),
getMethodName("b.c.C", "C", "()V"),
getMethodName("b.c.C", "c", "(Ljava/lang/String;)V"));

assertThat(getUnusedMethods(unused)).isEmpty();
}

public void testConstructorOverloads() throws IOException {
Expand Down Expand Up @@ -677,8 +679,8 @@ public void testWriteUnusedClasses() throws IOException {
}

public void testWriteUnusedConstructor() throws IOException {
addTreeShakerRootsFile("A");
addSourceFile("A.java", "class A { }");
addTreeShakerRootsFile("A:\n a()");
addSourceFile("A.java", "class A { static void a() {}}");
String output = writeUnused(findUnusedCode());

assertThat(output).startsWith("A:\n");
Expand Down

0 comments on commit ffa780e

Please sign in to comment.