Fix UnusedImportRemover to traverse package annotations Previously we just noted the type of the annotation, but we then considered types from annotation properties as unused and removed the imports, resulting in errors downstream. Bug: issue 8425 Change-Id: Idfa9430fd60cc7dea2069a8d860d6de078b6ca16 (cherry picked from commit a1386874fea70e012a3817c8b36d700366513402)
diff --git a/dev/core/src/com/google/gwt/dev/javac/UnusedImportsRemover.java b/dev/core/src/com/google/gwt/dev/javac/UnusedImportsRemover.java index c269964..2608a10 100644 --- a/dev/core/src/com/google/gwt/dev/javac/UnusedImportsRemover.java +++ b/dev/core/src/com/google/gwt/dev/javac/UnusedImportsRemover.java
@@ -185,11 +185,7 @@ // the Compilation unit declaration. Hence we do it manually. if (cud.currentPackage != null && cud.currentPackage.annotations != null) { for (Annotation annotation : cud.currentPackage.annotations) { - if (annotation.type instanceof SingleTypeReference) { - astVisitor.addName((SingleTypeReference) annotation.type); - } else if (annotation.type instanceof QualifiedTypeReference) { - astVisitor.addName((QualifiedTypeReference) annotation.type); - } + annotation.traverse(astVisitor, (BlockScope) null); } }
diff --git a/user/test/com/google/gwt/dev/jjs/test/usedimports/package-info.java b/user/test/com/google/gwt/dev/jjs/test/usedimports/package-info.java index 4cef717..ad77621 100644 --- a/user/test/com/google/gwt/dev/jjs/test/usedimports/package-info.java +++ b/user/test/com/google/gwt/dev/jjs/test/usedimports/package-info.java
@@ -14,6 +14,9 @@ * the License. */ @ParametersAreNonnullByDefault +@CheckReturnValue(when = When.UNKNOWN) package com.google.gwt.dev.jjs.test.usedimports; +import javax.annotation.CheckReturnValue; import javax.annotation.ParametersAreNonnullByDefault; +import javax.annotation.meta.When;