Adding Java compilation to java_lite_proto_library Skylark version.
--
PiperOrigin-RevId: 144608820
MOS_MIGRATED_REVID=144608820
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
index bb859c9..387b565 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
@@ -157,12 +157,28 @@
|| c.equals(String.class) // basic values
|| c.equals(Integer.class)
|| c.equals(Boolean.class)
- || c.isAnnotationPresent(SkylarkModule.class) // registered Skylark class
+ // there is a registered Skylark ancestor class (useful e.g. when using AutoValue)
+ || hasSkylarkAcceptableAncestor(c)
|| ImmutableMap.class.isAssignableFrom(c) // will be converted to SkylarkDict
|| NestedSet.class.isAssignableFrom(c) // will be converted to SkylarkNestedSet
|| c.equals(PathFragment.class); // other known class
}
+ private static boolean hasSkylarkAcceptableAncestor(Class<?> c) {
+ if (c == null) {
+ return false;
+ }
+ if (c.isAnnotationPresent(SkylarkModule.class)) {
+ return true;
+ }
+ for (Class<?> inter : c.getInterfaces()) {
+ if (hasSkylarkAcceptableAncestor(inter)) {
+ return true;
+ }
+ }
+ return hasSkylarkAcceptableAncestor(c.getSuperclass());
+ }
+
// TODO(bazel-team): move the following few type-related functions to SkylarkType
/**
* Return the Skylark-type of {@code c}