Repository: square/AssistedInject (kotlin)

Issue:
Nested AssistedModule compilation fails with missing include error
Given the following module:
```java
class Outer {
  @AssistedModule
  @Module(includes = AssistedInject_TestModule.class)
  public abstract class TestModule {}
}
```

Compilation fails with:
```
error: @AssistedModule's @Module must include AssistedInject_TestModule
```

I am not certain if nested module not being allowed is intentional or not but it seems it should either be allowed or have a specific error as output.

I have a failing unit test and will open a PR with that once I have this issue link.

Pull request description:
This uses a similar naming scheme to AutoValue and Dagger where the enclosing types must be listed.

Closes #108. Closes #109.

Patch:
diff --git a/assisted-inject-processor-dagger2/src/main/java/com/squareup/inject/assisted/dagger2/processor/AssistedInjectionModule.kt b/assisted-inject-processor-dagger2/src/main/java/com/squareup/inject/assisted/dagger2/processor/AssistedInjectionModule.kt
index b791638..f05f789 100644
--- a/assisted-inject-processor-dagger2/src/main/java/com/squareup/inject/assisted/dagger2/processor/AssistedInjectionModule.kt
+++ b/assisted-inject-processor-dagger2/src/main/java/com/squareup/inject/assisted/dagger2/processor/AssistedInjectionModule.kt
@@ -53,7 +53,9 @@ data class AssistedInjectionModule(
   }
 }
 
-fun ClassName.assistedInjectModuleName(): ClassName = peerClass("AssistedInject_" + simpleName())
+fun ClassName.assistedInjectModuleName(): ClassName {
+  return ClassName.get(packageName(), simpleNames().joinToString("_", prefix = "AssistedInject_"))
+}
 
 private inline fun <T : Any, K, V> T.applyEach(items: Map<K, V>, func: T.(K, V) -> Unit): T {
   items.forEach { (key, value) -> func(key, value) }


Test patch:
diff --git a/assisted-inject-processor-dagger2/src/test/java/com/squareup/inject/assisted/dagger2/processor/AssistedInjectDagger2ProcessorTest.kt b/assisted-inject-processor-dagger2/src/test/java/com/squareup/inject/assisted/dagger2/processor/AssistedInjectDagger2ProcessorTest.kt
index e7f0656..0cb1272 100644
--- a/assisted-inject-processor-dagger2/src/test/java/com/squareup/inject/assisted/dagger2/processor/AssistedInjectDagger2ProcessorTest.kt
+++ b/assisted-inject-processor-dagger2/src/test/java/com/squareup/inject/assisted/dagger2/processor/AssistedInjectDagger2ProcessorTest.kt
@@ -366,6 +366,59 @@ class AssistedInjectDagger2ProcessorTest {
         .`in`(moduleOne).onLine(7)
   }
 
+  @Test fun nestedModule() {
+    val test = JavaFileObjects.forSourceString("test.Test", """
+      package test;
+
+      import com.squareup.inject.assisted.Assisted;
+      import com.squareup.inject.assisted.AssistedInject;
+
+      class Test {
+        @AssistedInject
+        Test(Long foo, @Assisted String bar) {}
+
+        @AssistedInject.Factory
+        interface Factory {}
+      }
+
+      class Test_AssistedFactory implements Test.Factory {}
+    """)
+    val module = JavaFileObjects.forSourceString("test.TestModule", """
+      package test;
+
+      import com.squareup.inject.assisted.dagger2.AssistedModule;
+      import dagger.Module;
+
+      class Outer {
+          @AssistedModule
+          @Module(includes = AssistedInject_Outer_TestModule.class)
+          public abstract class TestModule {}
+      }
+    """)
+    val expected = JavaFileObjects.forSourceString("test.AssistedInject_TestModule", """
+      package test;
+
+      import dagger.Binds;
+      import dagger.Module;
+      import $GENERATED_TYPE;
+
+      @Module
+      $GENERATED_ANNOTATION
+      public abstract class AssistedInject_Outer_TestModule {
+        private AssistedInject_Outer_TestModule() {}
+
+        @Binds abstract Test.Factory generatedFactory(Test_AssistedFactory factory);
+      }
+    """)
+
+    assertAbout(javaSources())
+      .that(listOf(test, module))
+      .processedWith(AssistedInjectDagger2Processor())
+      .compilesWithoutError()
+      .and()
+      .generatesSources(expected)
+  }
+
   @Test fun moduleWithNoIncludesFails() {
     val moduleOne = JavaFileObjects.forSourceString("test.OneModule", """
       package test;