Skip to content

Commit 28bfb86

Browse files
trexemDagger Team
authored andcommitted
Internal Changes
RELNOTES=Introduced @asalias to allow @BINDS methods to "float" PiperOrigin-RevId: 875335080
1 parent 3185f63 commit 28bfb86

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

dagger-compiler/main/java/dagger/internal/codegen/base/ComponentKind.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ public ImmutableSet<ComponentKind> legalSubcomponentKinds() {
9898
public boolean isProducer() {
9999
return PRODUCER_KINDS.contains(this);
100100
}
101+
102+
public boolean isSubcomponent() {
103+
return this.equals(SUBCOMPONENT) || this.equals(PRODUCTION_SUBCOMPONENT);
104+
}
101105
}

dagger-compiler/main/java/dagger/internal/codegen/binding/BindingGraphFactory.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ private final class RequiresResolutionChecker {
677677

678678
boolean requiresResolution(BindingNode binding) {
679679
// If we're not allowed to float then the binding cannot be re-resolved in this component.
680-
if (isNotAllowedToFloat(binding)) {
680+
if (!isAllowedToFloat(binding)) {
681681
return false;
682682
}
683683
if (hasLocalBindings(binding)) {
@@ -692,14 +692,16 @@ boolean requiresResolution(BindingNode binding) {
692692
&& (dependsOnLocalBinding(binding) || dependsOnMissingBinding(binding));
693693
}
694694

695-
private boolean isNotAllowedToFloat(BindingNode binding) {
695+
private boolean isAllowedToFloat(BindingNode binding) {
696+
if(binding.kind() == BindingKind.INJECTION
697+
|| binding.kind() == BindingKind.ASSISTED_INJECTION) {
698+
return true;
699+
}
696700
// In general, @Provides/@Binds/@Production bindings are allowed to float to get access to
697701
// multibinding contributions that are contributed in subcomponents. However, they aren't
698702
// allowed to float to get access to missing bindings that are installed in subcomponents,
699703
// so we prevent floating if these bindings depend on a missing binding.
700-
return binding.kind() != BindingKind.INJECTION
701-
&& binding.kind() != BindingKind.ASSISTED_INJECTION
702-
&& dependsOnMissingBinding(binding);
704+
return !dependsOnMissingBinding(binding);
703705
}
704706

705707
private boolean dependsOnMissingBinding(BindingNode binding) {

dagger-compiler/main/java/dagger/internal/codegen/bindinggraphvalidation/BindingGraphValidationModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static ImmutableSet<ValidationBindingGraphPlugin> providePlugins(
4444
ProvisionDependencyOnProducerBindingValidator validation9,
4545
InvalidProductionBindingScopeValidator validation10,
4646
SetMultibindingValidator validation11,
47-
SubcomponentFactoryMethodValidator validation12) {
47+
SubcomponentFactoryMethodValidator validation12) {
4848
ImmutableSet.Builder<ValidationBindingGraphPlugin> builder =
4949
ImmutableSet.<ValidationBindingGraphPlugin>builder()
5050
.add(validation1)

0 commit comments

Comments
 (0)