aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/AbstractConfiguredTarget.java10
-rw-r--r--src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java6
2 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AbstractConfiguredTarget.java b/src/main/java/com/google/devtools/build/lib/analysis/AbstractConfiguredTarget.java
index b522bce19d..acaa4a8db6 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/AbstractConfiguredTarget.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/AbstractConfiguredTarget.java
@@ -149,15 +149,7 @@ public abstract class AbstractConfiguredTarget
"Type Target only supports querying by object constructors, got %s instead",
EvalUtils.getDataTypeName(key)));
}
- ClassObjectConstructor constructor = (ClassObjectConstructor) key;
- SkylarkProviders provider = getProvider(SkylarkProviders.class);
- if (provider != null) {
- Object declaredProvider = provider.getDeclaredProvider(constructor.getKey());
- if (declaredProvider != null) {
- return true;
- }
- }
- return false;
+ return get(((ClassObjectConstructor) key).getKey()) != null;
}
@Override
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java
index 0d4f74fe8c..8c4be30028 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java
@@ -867,6 +867,7 @@ public class SkylarkRuleImplementationFunctionsTest extends SkylarkTestCase {
"def _impl(ctx):",
" provider = ctx.attr.deps[0][DefaultInfo]",
" return struct(",
+ " is_provided = DefaultInfo in ctx.attr.deps[0],",
" provider = provider,",
" dir = str(sorted(dir(provider))),",
" rule_data_runfiles = provider.data_runfiles,",
@@ -889,6 +890,8 @@ public class SkylarkRuleImplementationFunctionsTest extends SkylarkTestCase {
ConfiguredTarget configuredTarget = getConfiguredTarget("//test:my_rule");
SkylarkProviders providers = configuredTarget.getProvider(SkylarkProviders.class);
+ assertThat((Boolean) providers.getValue("is_provided")).isTrue();
+
Object provider = providers.getValue("provider");
assertThat(provider).isInstanceOf(DefaultProvider.class);
assertThat(((DefaultProvider) provider).getConstructor().getPrintableName())
@@ -925,6 +928,7 @@ public class SkylarkRuleImplementationFunctionsTest extends SkylarkTestCase {
"def _impl(ctx):",
" provider = ctx.attr.deps[0][DefaultInfo]",
" return struct(",
+ " is_provided = DefaultInfo in ctx.attr.deps[0],",
" provider = provider,",
" dir = str(sorted(dir(provider))),",
" file_data_runfiles = provider.data_runfiles,",
@@ -945,6 +949,8 @@ public class SkylarkRuleImplementationFunctionsTest extends SkylarkTestCase {
ConfiguredTarget configuredTarget = getConfiguredTarget("//test:my_rule");
SkylarkProviders providers = configuredTarget.getProvider(SkylarkProviders.class);
+ assertThat((Boolean) providers.getValue("is_provided")).isTrue();
+
Object provider = providers.getValue("provider");
assertThat(provider).isInstanceOf(DefaultProvider.class);
assertThat(((DefaultProvider) provider).getConstructor().getPrintableName())