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

[KSP] KSP mode does not check for @Provides on interface methods #4346

Open
ZacSweers opened this issue Jul 4, 2024 · 1 comment
Open

[KSP] KSP mode does not check for @Provides on interface methods #4346

ZacSweers opened this issue Jul 4, 2024 · 1 comment

Comments

@ZacSweers
Copy link

This is a slight behavior change from apt to KSP. The following snippet is an error in apt but has no error in KSP

@Module
interface DaggerModule1 {
  @Provides fun provideString(): String = ""
}

It may be intentional if the intention is to support the default value, but I can't find any docs that confirm this.

@bcorso
Copy link

bcorso commented Jul 12, 2024

Thanks for reporting! No, this was not intentional.

In KAPT, this would turn into an abstract method + static DefaultImpls implementation in the Java stub, so I think things just happened to fail since we don't allow @Provides on an abstract method. My guess is that KSP represents this case more accurately and the method isn't considered abstract due to the default implementation.

In any case, I think the "fix" for this to make it behave the same as KAPT (i.e. fail the build).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants