Skip to content

Commit

Permalink
Fix a bug in the component validation (#54)
Browse files Browse the repository at this point in the history
If the inferred component and the installIn component were the same,
then validation would fail.
  • Loading branch information
ansman authored Jun 5, 2023
1 parent 1dd62a7 commit ab7b42f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ class AutoBindProcessor<N, TypeName : Any, ClassName : TypeName, AnnotationSpec,
inferredComponent: ClassName,
): Boolean {
var c = inferredComponent
while (c != installInComponent) {
do {
c = resolver.lookupType(c)
.getAnnotation(DefineComponent::class)
?.getValue<ClassDeclaration<N, TypeName, ClassName, AnnotationSpec>>("parent")
?.className
?: return false
}
} while (c != installInComponent)
return true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package tests.auto_bind.child_component
package tests.auto_bind.component_validation

import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.components.FragmentComponent
import dagger.hilt.components.SingletonComponent
import se.ansman.dagger.auto.AutoBind
import javax.inject.Inject
import javax.inject.Singleton

interface Repository

@AutoBind
@AutoBind(inComponent = SingletonComponent::class)
@Singleton
class GlobalRepository @Inject constructor() : Repository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Code generated by Auto Dagger. Do not edit.
package tests.auto_bind.child_component;
package tests.auto_bind.component_validation;

import dagger.Binds;
import dagger.Module;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Code generated by Auto Dagger. Do not edit.
package tests.auto_bind.child_component;
package tests.auto_bind.component_validation;

import dagger.Binds;
import dagger.Module;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Code generated by Auto Dagger. Do not edit.
package tests.auto_bind.child_component;
package tests.auto_bind.component_validation;

import dagger.Binds;
import dagger.Module;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Code generated by Auto Dagger. Do not edit.
package tests.auto_bind.child_component
package tests.auto_bind.component_validation

import dagger.Binds
import dagger.Module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Code generated by Auto Dagger. Do not edit.
package tests.auto_bind.child_component
package tests.auto_bind.component_validation

import dagger.Binds
import dagger.Module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Code generated by Auto Dagger. Do not edit.
package tests.auto_bind.child_component
package tests.auto_bind.component_validation

import dagger.Binds
import dagger.Module
Expand Down

0 comments on commit ab7b42f

Please sign in to comment.