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

[ksp2] Error Type in type argument does not have API for simple name #2221

Open
acejingbo opened this issue Nov 20, 2024 · 0 comments
Open

Comments

@acejingbo
Copy link

acejingbo commented Nov 20, 2024

In KSP2, if a type argument is error type (in java source file), for example Foo in ArrayList<Foo>, then the foo's KSType and KSTypeReference will appear as (<ERROR TYPE: Foo>..<ERROR TYPE: Foo>?). And there's no public API to retrieve the original simple name "Foo".

I end up have to use regex to extract the word Foo from (<ERROR TYPE: Foo>..<ERROR TYPE: Foo>?)

Repro

Example code in acejingbo@ba967e0

Run ksp1 (:compiler-plugin:test) you will get
Image

Run ksp2 (:kotlin-analysis-api:test) you will get
Image

See

  • Type argument was NonExistClass in ksp, but was (<ERROR TYPE: NonExistClass>..<ERROR TYPE: NonExistClass>?) in ksp2
  • In ksp2 the argumentType and resolvedArgumentType provide no API that can return its original text NonExistClass
    (ktType have it but it's not public!)

Image

Wishlist

Is it reasonable to request an API that can return error type's simple name / original text?
Or expose the inner KtType so we can retrieve from there?

Thanks!

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

1 participant