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/SelectorList.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java b/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java index 7ec367cb89..3180483777 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SelectorList.java @@ -20,8 +20,6 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter; import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; import com.google.devtools.build.lib.util.Preconditions; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -86,12 +84,22 @@ public final class SelectorList implements SkylarkValue { */ public static SelectorList concat(Location location, Object value1, Object value2) throws EvalException { - return of(location, Arrays.asList(value1, value2)); + return of(location, value1, value2); } /** - * Creates a list from the given sequence of values, which must be non-empty. Each value may be - * a native type, a select over that type, or a selector list over that type. + * Creates a list from the given sequence of values, which must be non-empty. Each value may be a + * native type, a select over that type, or a selector list over that type. + * + * @throws EvalException if all values don't have the same underlying type + */ + public static SelectorList of(Location location, Object... values) throws EvalException { + return SelectorList.of(location, ImmutableList.copyOf(values)); + } + + /** + * Creates a list from the given sequence of values, which must be non-empty. Each value may be a + * native type, a select over that type, or a selector list over that type. * * @throws EvalException if all values don't have the same underlying type */ @@ -122,9 +130,7 @@ public final class SelectorList implements SkylarkValue { return new SelectorList(getNativeType(firstValue), elements.build()); } - // TODO(bazel-team): match on the List interface, not the actual implementation. For now, - // we verify this is the right class through test coverage. - private static final Class<?> NATIVE_LIST_TYPE = ArrayList.class; + private static final Class<?> NATIVE_LIST_TYPE = List.class; private static Class<?> getNativeType(Object value) { if (value instanceof SelectorList) { @@ -137,7 +143,7 @@ public final class SelectorList implements SkylarkValue { } private static boolean isListType(Class<?> type) { - return type == NATIVE_LIST_TYPE + return NATIVE_LIST_TYPE.isAssignableFrom(type) || type.getSuperclass() == SkylarkList.class || type == GlobList.class; } |