-
Notifications
You must be signed in to change notification settings - Fork 268
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
Can't differentiate between @A(int.class) and @A(Integer.class) #870
Comments
As of now, KSP behaves exactly as pure Kotlin here, meaning there's no such thing as The problem in this issue is, in fact, broader - there's no way to distinguish between Java's primitive and wrapper types not only in annotation arguments, but also in methods' and fields' originating from Java. This knowledge is required when overriding Java methods in Java code (there's an obscure way to recover this information by using experimental As I understand it, to resolve the issue KSP needs to model Java's primitive and wrapper types as separate objects. In fact, I see that could be at least three equivalence classes for such types:
It looks very similar to nullability information, where Kotlin type has explicit mark and Java types are assumed "platform" (flexible). Also maybe we could add this information on Anyway, I would be glad to discuss a way to solve this, as I'm also affected. |
The Java |
From Kotlin's point of view, primitive types can be distinguished from their boxed alternatives by nullability. In KSP, primitive types are Unfortunately, the information was lost in annotations in #703. I need to run some more tests to see if mapping boxed types would be OK. |
Good point, but can this criteria be reliably used to tell boxed/primitve types apart? Is there a guarantee, that this will always be the case? What if one uses |
Yes, it is documented so KSP needs to follow.
It'll be non-null
It'll be non-null |
The |
Given the following Java code:
and the following KSP code
equal
istrue
, which is surprising given that the underlying code is not andint.class == Integer.class
would return false.The text was updated successfully, but these errors were encountered: