aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skylarkinterface
diff options
context:
space:
mode:
authorGravatar cparsons <cparsons@google.com>2018-07-09 14:09:43 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-09 14:11:23 -0700
commit0e32b31b8ff94ece1f7987ee3e5a5532c6c45212 (patch)
tree7b629231459bf972cb04924743f7c3b595f5cdbc /src/main/java/com/google/devtools/build/lib/skylarkinterface
parent2bea6c6eefc1fbf3e0bd14f201ce2031e126ee4c (diff)
Fix CcCompilationInfo to appropriately subclass Struct, and improve upon error messaging and commenting when there's an unresolvable skylark type.
RELNOTES: None. PiperOrigin-RevId: 203826504
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skylarkinterface')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java
index 3f25c32598..a4279e4b81 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java
@@ -58,8 +58,17 @@ public class SkylarkInterfaceUtils {
} else if (yClass.isAssignableFrom(xClass)) {
return x;
} else {
+ // If this exception occurs, it indicates the following error scenario:
+ //
+ // Suppose class A is a subclass of both B and C, where B and C are annotated with
+ // @SkylarkModule annotations (and are thus considered "skylark types"). If B is not a
+ // subclass of C (nor visa versa), then it's impossible to resolve whether A is of type
+ // B or if A is of type C. It's both! The way to resolve this is usually to have A be its own
+ // type (annotated with @SkylarkModule), and thus have the explicit type of A be semantically
+ // "B and C".
+ // TODO(cparsons): Verify in a test, and thus not rely solely on a runtime check.
throw new IllegalArgumentException(String.format(
- "Expected one of %s and %s to be assignable to each other",
+ "Expected one of %s and %s to be a subclass of the other",
xClass, yClass));
}
}