Unify Skylark and BUILD lists
Use SkylarkList everywhere rather than either List or GlobList.
Keep a GlobList underneath a MutableList, where applicable.
--
MOS_MIGRATED_REVID=105864035
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index f356f25..6551730 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -44,6 +44,7 @@
import com.google.devtools.build.lib.syntax.FuncallExpression;
import com.google.devtools.build.lib.syntax.GlobList;
import com.google.devtools.build.lib.syntax.Runtime;
+import com.google.devtools.build.lib.syntax.SkylarkList;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.util.StringUtil;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -1350,13 +1351,22 @@
private void checkAttrValNonEmpty(
Rule rule, EventHandler eventHandler, Object attributeValue, Integer attrIndex) {
- if (attributeValue instanceof List<?>) {
- Attribute attr = getAttribute(attrIndex);
- if (attr.isNonEmpty() && ((List<?>) attributeValue).isEmpty()) {
- rule.reportError(rule.getLabel() + ": non empty " + "attribute '" + attr.getName()
- + "' in '" + name + "' rule '" + rule.getLabel() + "' has to have at least one value",
- eventHandler);
- }
+ List<?> list;
+
+ if (attributeValue instanceof SkylarkList) {
+ list = ((SkylarkList) attributeValue).getList();
+ } else if (attributeValue instanceof List<?>) {
+ list = (List<?>) attributeValue;
+ } else {
+ // TODO(bazel-team): Test maps, not just lists, as being non-empty.
+ return;
+ }
+
+ Attribute attr = getAttribute(attrIndex);
+ if (attr.isNonEmpty() && list.isEmpty()) {
+ rule.reportError(rule.getLabel() + ": non empty " + "attribute '" + attr.getName()
+ + "' in '" + name + "' rule '" + rule.getLabel() + "' has to have at least one value",
+ eventHandler);
}
}