diff options
author | 2015-09-25 00:03:48 +0000 | |
---|---|---|
committer | 2015-09-25 14:40:48 +0000 | |
commit | 290a295cb684b1c3486fd983686e44b54989d7a0 (patch) | |
tree | 9cc8dd09025b4112619d1f45c02ca9100af11e91 /src | |
parent | de281a77a68490dba35063d901055ef248138d37 (diff) |
Clarify contract of EvaluationResult -- the same key can never be present in both an "error" and "success" state.
--
MOS_MIGRATED_REVID=103897656
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java b/src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java index aa081a33dc..8da2094b4b 100644 --- a/src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java +++ b/src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java @@ -32,6 +32,9 @@ import javax.annotation.Nullable; * for the first value that failed to evaluate (in the non-keep-going case), or any remaining values * that failed to evaluate (in the keep-going case) will be retrievable. * + * <p>A node can never be successfully evaluated and fail to evaluate. Thus, if {@link #get} returns + * non-null for some key, there is no stored error for that key, and vice versa. + * * @param <T> The type of the values that the caller has requested. */ public class EvaluationResult<T extends SkyValue> { @@ -98,7 +101,8 @@ public class EvaluationResult<T extends SkyValue> { } /** - * @return Names of all values that were successfully evaluated. + * @return Names of all values that were successfully evaluated. This collection is disjoint from + * the keys in {@link #errorMap}. */ public <S> Collection<? extends S> keyNames() { return this.<S>getNames(resultMap.keySet()); @@ -150,14 +154,20 @@ public class EvaluationResult<T extends SkyValue> { private boolean hasError = false; private WalkableGraph walkableGraph = null; + /** Adds a value to the result. An error for this key must not already be present. */ @SuppressWarnings("unchecked") public Builder<T> addResult(SkyKey key, SkyValue value) { result.put(key, Preconditions.checkNotNull((T) value, key)); + Preconditions.checkState( + !errors.containsKey(key), "%s in both result and errors: %s %s", value, errors); return this; } + /** Adds an error to the result. A successful value for this key must not already be present. */ public Builder<T> addError(SkyKey key, ErrorInfo error) { errors.put(key, Preconditions.checkNotNull(error, key)); + Preconditions.checkState( + !result.containsKey(key), "%s in both result and errors: %s %s", error, result); return this; } |