Best effort static on-demand type import handling
MOE_MIGRATED_REVID=137778572
diff --git a/java/com/google/turbine/binder/lookup/WildImportIndex.java b/java/com/google/turbine/binder/lookup/WildImportIndex.java
index 9e97847..0ef3ab5 100644
--- a/java/com/google/turbine/binder/lookup/WildImportIndex.java
+++ b/java/com/google/turbine/binder/lookup/WildImportIndex.java
@@ -45,12 +45,14 @@
ImmutableList<ImportDecl> imports) {
ImmutableList.Builder<Supplier<Scope>> packageScopes = ImmutableList.builder();
for (final ImportDecl i : imports) {
- if (i.stat()) {
- continue;
- }
if (!i.wild()) {
continue;
}
+
+ // Speculatively include static wildcard imports, in case the import is needed
+ // to resolve children of a static-imported canonical type.
+ // TODO(cushon): consider locking down static wildcard imports of types and backing this out
+
packageScopes.add(
Suppliers.memoize(
new Supplier<Scope>() {
diff --git a/javatests/com/google/turbine/lower/LowerIntegrationTest.java b/javatests/com/google/turbine/lower/LowerIntegrationTest.java
index 220c91e..00877a9 100644
--- a/javatests/com/google/turbine/lower/LowerIntegrationTest.java
+++ b/javatests/com/google/turbine/lower/LowerIntegrationTest.java
@@ -252,6 +252,7 @@
"annotation_scope.test",
"visible_package_private_toplevel.test",
"receiver_param.test",
+ "static_member_type_import.test",
};
List<Object[]> tests =
ImmutableList.copyOf(testCases).stream().map(x -> new Object[] {x}).collect(toList());
diff --git a/javatests/com/google/turbine/lower/testdata/static_member_type_import.test b/javatests/com/google/turbine/lower/testdata/static_member_type_import.test
new file mode 100644
index 0000000..f2f8d6f
--- /dev/null
+++ b/javatests/com/google/turbine/lower/testdata/static_member_type_import.test
@@ -0,0 +1,9 @@
+=== a/A.java ===
+package a;
+public class A {
+ public static class Inner {}
+}
+
+=== Test.java ===
+import static a.A.*;
+public class Test extends Inner {}