diff options
author | 2017-07-27 12:59:51 +0200 | |
---|---|---|
committer | 2017-07-27 13:20:30 +0200 | |
commit | 983f6c4d7b4cda4e9926361ff2ae76dc6a7f3a6d (patch) | |
tree | b06b5675d9c3721e71aa4e09bcd58bce4cba5581 /src/main/java/com | |
parent | 562fcf9f5dfd14daea718f77da95b43b1400689b (diff) |
Fix a crash when Skylark rule re-exports SkylarkApiProvider.
Also PintoSourcesContextProvider should not be a SkylarkApiProvider: it
is not facade for anything but a provider in its own right.
RELNOTES: None.
PiperOrigin-RevId: 163323130
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTarget.java | 1 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/SkylarkApiProvider.java | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTarget.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTarget.java index 8f6b61cbc3..95d8f8260b 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTarget.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTarget.java @@ -63,6 +63,7 @@ public final class RuleConfiguredTarget extends AbstractConfiguredTarget { // Initialize every SkylarkApiProvider for (int i = 0; i < providers.getProviderCount(); i++) { + Object providerKeyAt = providers.getProviderKeyAt(i); Object obj = providers.getProviderInstanceAt(i); if (obj instanceof SkylarkApiProvider) { ((SkylarkApiProvider) obj).init(this); diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkApiProvider.java index b9fbdd07e0..83cdd438a0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkApiProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkApiProvider.java @@ -30,8 +30,12 @@ public abstract class SkylarkApiProvider { public final void init(TransitiveInfoCollection info) { if (this.info != null) { - // Allow multiple calls, but only consistent ones. - Preconditions.checkState(info == this.info); + // todo(dslomov): nuke this weird initialization mechanism. + + // Allow multiple calls. + // It is possible for the Skylark rule to get a SkylarkApiProvider such as `target.java` + // from its dependency and pass it on. It does not make a whole lot of sense, but we + // shouldn't crash. return; } this.info = Preconditions.checkNotNull(info); |