diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java index cbcf21a95c..fb4f2457d4 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java @@ -362,23 +362,15 @@ public abstract class SkylarkList implements Iterable<Object> { if (elements.isEmpty()) { return EMPTY_LIST; } - return new SimpleSkylarkList( - ImmutableList.copyOf(elements), false, getContentType(elements, loc)); + return new SimpleSkylarkList(ImmutableList.copyOf(elements), false, getContentType(elements)); } - private static SkylarkType getContentType(Collection<?> elements, Location loc) + private static SkylarkType getContentType(Collection<?> elements) throws EvalException { SkylarkType type = SkylarkType.TOP; for (Object element : elements) { SkylarkType elementType = SkylarkType.typeOf(element); - SkylarkType inter = SkylarkType.intersection(type, elementType); - if (inter == SkylarkType.BOTTOM) { - throw new EvalException(loc, String.format( - "Incompatible types in list: found a %s but the previous elements were %ss", - elementType, type)); - } else { - type = inter; - } + type = SkylarkType.intersection(type, elementType); } return type; } @@ -399,10 +391,6 @@ public abstract class SkylarkList implements Iterable<Object> { return left; } SkylarkType type = SkylarkType.intersection(left.contentType, right.contentType); - if (type == SkylarkType.BOTTOM) { - throw new EvalException(loc, String.format("cannot concatenate list of %s with list of %s", - left.contentType, right.contentType)); - } return new ConcatenatedSkylarkList(left, right, left.isTuple(), type); } |