aboutsummaryrefslogtreecommitdiff
path: root/core/src/com/google/inject
diff options
context:
space:
mode:
authordweis <dweis@google.com>2015-01-26 18:17:50 -0800
committerSam Berlin <sameb@google.com>2015-02-03 18:07:07 -0500
commitf11bf2d26ccd07e72805b789b33d855e223b1ed7 (patch)
tree02079944304ba9f88c7285698217a2b4c94327e5 /core/src/com/google/inject
parentb605a34702d8d8112983aca891e3e2b6987ec45e (diff)
downloadguice-f11bf2d26ccd07e72805b789b33d855e223b1ed7.tar.gz
Make Guice ignore validation of scope annotations on abstract types for types annotated with @Component. This allows one to provide Dagger Components with Guice Injectors.
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=84836495
Diffstat (limited to 'core/src/com/google/inject')
-rw-r--r--core/src/com/google/inject/internal/Annotations.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/src/com/google/inject/internal/Annotations.java b/core/src/com/google/inject/internal/Annotations.java
index dfc69361..4c994a95 100644
--- a/core/src/com/google/inject/internal/Annotations.java
+++ b/core/src/com/google/inject/internal/Annotations.java
@@ -201,6 +201,17 @@ public class Annotations {
return found;
}
+ static boolean containsComponentAnnotation(Annotation[] annotations) {
+ for (Annotation annotation : annotations) {
+ // TODO(user): Should we scope this down to dagger.Component?
+ if (annotation.annotationType().getSimpleName().equals("Component")) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Checks for the presence of annotations. Caches results because Android doesn't.
*/
@@ -256,7 +267,9 @@ public class Annotations {
}
Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type);
- if (scopeAnnotation != null) {
+ if (scopeAnnotation != null
+ // We let Dagger Components through to aid migrations.
+ && !containsComponentAnnotation(type.getAnnotations())) {
errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source);
}
}