You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We track a number of issues that stem from the fact that introspecting Kotlin code through mirrors or reflection is unreliable (#86, #236, #828). Now that there's proper support for processing @Metadata, existing API that has been ported from JavaPoet needs to be deprecated and eventually removed in 2.0. We might need to look into providing more documentation or migration recipes.
The text was updated successfully, but these errors were encountered:
In short: cases like TypeMirror.asTypeName() or Type.asTypeName() will never work as intended for Kotlin compiler intrinsic types. APIs like this simply cannot look at individual types in isolation and have enough context to understand them. You must have access to the appropriate metadata that describes them in context. There are no silver bullets here, this is how Kotlin works.
What would the scope of this be? I think it makes sense for cases like overriding but for plain old String::class.asTypeName() is fine. The problem is narrowing it down for intrinsic types, where we may want to check at runtime and ask them to explicitly declare which type to use?
I don't think fixing these APIs is the right solution since the safest APIs still are Metadata-based. Of course in an out-of-context snippet of code it's easier to do asTypeName() than to navigate up to find Metadata, but this is unsafe and will yield incorrect results.
We track a number of issues that stem from the fact that introspecting Kotlin code through mirrors or reflection is unreliable (#86, #236, #828). Now that there's proper support for processing
@Metadata
, existing API that has been ported from JavaPoet needs to be deprecated and eventually removed in 2.0. We might need to look into providing more documentation or migration recipes.The text was updated successfully, but these errors were encountered: