Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factory generation: nested class with lowercase name #96

Closed
Dkhusainov opened this issue Sep 2, 2020 · 2 comments · Fixed by #105
Closed

Factory generation: nested class with lowercase name #96

Dkhusainov opened this issue Sep 2, 2020 · 2 comments · Fixed by #105
Labels
bug Something isn't working dagger factory Happens when generateDaggerFactories is set to true

Comments

@Dkhusainov
Copy link

Anvil: 2.0,2

Reproducer:

class MyClass @Inject constructor(a: asg) {
  class asg @Inject constructor()
}

Exception:

e: java.lang.IllegalArgumentException: couldn't make a guess for com.example.myapplication.MyClass.asg
        at com.squareup.kotlinpoet.ClassName$Companion.bestGuess(TypeName.kt:465)
        at com.squareup.anvil.compiler.codegen.KotlinPoetKt.requireTypeName(KotlinPoet.kt:65)
        at com.squareup.anvil.compiler.codegen.KotlinPoetKt.mapToParameter(KotlinPoet.kt:110)
        at com.squareup.anvil.compiler.codegen.dagger.InjectConstructorFactoryGenerator.generateFactoryClass(InjectConstructorFactoryGenerator.kt:63)
@vRallev
Copy link
Collaborator

vRallev commented Sep 2, 2020

I don't want to implement another workaround within Anvil. Instead I filed: square/kotlinpoet#978

In the meantime I suggest to follow Kotlin's convention that classes should start with an uppercase letter.

@vRallev vRallev added bug Something isn't working dagger factory Happens when generateDaggerFactories is set to true waiting for response labels Sep 2, 2020
@Dkhusainov
Copy link
Author

There is always exceptions to conventions(that's my case).

Plus there's the case of code you have no control over(like some generator that for some reason generates classes in lowercase).

vRallev added a commit that referenced this issue Sep 4, 2020
…ting factories for inject constructors.

Fixes #96
vRallev added a commit that referenced this issue Sep 4, 2020
…ting factories for inject constructors.

Fixes #96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dagger factory Happens when generateDaggerFactories is set to true
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants