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
diff --git a/core/src/com/google/inject/internal/Annotations.java b/core/src/com/google/inject/internal/Annotations.java
index dfc6936..4c994a9 100644
--- a/core/src/com/google/inject/internal/Annotations.java
+++ b/core/src/com/google/inject/internal/Annotations.java
@@ -201,6 +201,17 @@
     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 @@
     }
 
     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);
     }
   }
diff --git a/core/test/com/google/inject/ScopesTest.java b/core/test/com/google/inject/ScopesTest.java
index fd7a4eb..59aa596 100644
--- a/core/test/com/google/inject/ScopesTest.java
+++ b/core/test/com/google/inject/ScopesTest.java
@@ -162,6 +162,22 @@
   interface A {}
   static class AImpl implements A {}
 
+  @Retention(RUNTIME)
+  @interface Component {}
+
+  @Component
+  @Singleton
+  interface ComponentAnnotationTest {}
+  static class ComponentAnnotationTestImpl implements ComponentAnnotationTest {}
+
+  public void testScopingAnnotationsOnAbstractTypeIsValidForComponent() {
+    Guice.createInjector(new AbstractModule() {
+      @Override protected void configure() {
+        bind(ComponentAnnotationTest.class).to(ComponentAnnotationTestImpl.class);
+      }
+    });
+  }
+
   public void testScopingAnnotationsOnAbstractTypeViaImplementedBy() {
     try {
       Guice.createInjector().getInstance(D.class);