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

Compiler crash when ContributesBinding boundType has type parameters #97

Open
eygraber opened this issue Dec 31, 2024 · 1 comment
Open
Labels
bug Something isn't working enhancement New feature or request

Comments

@eygraber
Copy link
Contributor

If I have an interface with type parameters:

interface Foo<T, R>

and I use ContributesBinding on a concrete implementation of it:

class Bar
class Baz

@ContributesBinding(MyScope::class)
class RealFoo : Foo<Bar, Baz>

I get the following crash:

[ksp] java.lang.IllegalStateException: KSType 'Foo<Bar, Baz>' has type arguments, which are not supported for ClassName conversion. Use KSType.toTypeName().
	at com.squareup.kotlinpoet.ksp.KsTypesKt.toClassName(KsTypes.kt:44)
	at software.amazon.lastmile.kotlin.inject.anvil.processor.ContributesBindingProcessor$GeneratedFunction.bindingMethodReturnType_delegate$lambda$0(ContributesBindingProcessor.kt:220)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:83)
	at software.amazon.lastmile.kotlin.inject.anvil.processor.ContributesBindingProcessor$GeneratedFunction.getBindingMethodReturnType(ContributesBindingProcessor.kt:219)
	at software.amazon.lastmile.kotlin.inject.anvil.processor.ContributesBindingProcessor.generateComponentInterface(ContributesBindingProcessor.kt:93)
	at software.amazon.lastmile.kotlin.inject.anvil.processor.ContributesBindingProcessor.process(ContributesBindingProcessor.kt:72)
	at software.amazon.lastmile.kotlin.inject.anvil.CompositeSymbolProcessor.process(CompositeSymbolProcessor.kt:17)
@vRallev
Copy link
Contributor

vRallev commented Dec 31, 2024

We should make this work, but it will start to fail if there are multiple super types:

@ContributesBinding(MyScope::class)
class RealFoo : Foo<Bar, Baz>, SecondSuperType

In this case you have to use the boundType parameter, but with that you cannot specify the type parameters:

@ContributesBinding(MyScope::class, boundType = Foo::class)
class RealFoo : Foo<Bar, Baz>, SecondSuperType

@vRallev vRallev added bug Something isn't working enhancement New feature or request labels Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants