aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2016-09-06 14:54:22 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-09-06 15:39:59 +0000
commitcb3d799cc89276c9b1d9185e5556df870abec1c9 (patch)
tree84766f86959474ca9844b0c9c208c285d578200f /src/main/java/com/google/devtools/build/lib/packages
parent304f5cbfac3c8cc272a0c43d3077a4cff0e1cc5a (diff)
Skylark no longer crashes when the default value of an attribute is a label string that points to a remote repository.
Fixes #1442. -- MOS_MIGRATED_REVID=132320130
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/Attribute.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
index fed7bd4c67..80bba9bde3 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
@@ -620,14 +620,24 @@ public final class Attribute implements Comparable<Attribute> {
/**
* See value(TYPE) above. This method is only meant for Skylark usage.
+ *
+ * <p>The parameter {@code context} is relevant iff the default value is a Label string.
+ * In this case, {@code context} must point to the parent Label in order to be able to convert
+ * the default value string to a proper Label.
*/
- public Builder<TYPE> defaultValue(Object defaultValue) throws ConversionException {
+ public Builder<TYPE> defaultValue(Object defaultValue, Object context)
+ throws ConversionException {
Preconditions.checkState(!valueSet, "the default value is already set");
- value = type.convert(defaultValue, "attribute " + name);
+ value = type.convert(defaultValue, "attribute " + name, context);
valueSet = true;
return this;
}
+ /** See value(TYPE) above. This method is only meant for Skylark usage. */
+ public Builder<TYPE> defaultValue(Object defaultValue) throws ConversionException {
+ return defaultValue(defaultValue, null);
+ }
+
public boolean isValueSet() {
return valueSet;
}