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

No TypeParameter found for index T #2065

Open
Scogun opened this issue Jan 22, 2025 · 4 comments
Open

No TypeParameter found for index T #2065

Scogun opened this issue Jan 22, 2025 · 4 comments
Labels

Comments

@Scogun
Copy link

Scogun commented Jan 22, 2025

Describe the bug
After upgrade from 1.18.1 version to 2.0.0 I started to face an issue No TypeParameter found for index T

To Reproduce
I had next code:

(this.declaration as KSClassDeclaration).getAllSuperTypes().any { it.toClassName() == ITERABLE }

I started to face next issue:

KSType 'Comparable<String>' has type arguments, which are not supported for ClassName conversion. Use KSType.toTypeName().

After switching on toTypeName I face No TypeParameter found for index T

(this.declaration as KSClassDeclaration).getAllSuperTypes().any { it.toTypeName() == ITERABLE }

Expected behavior
toTypeName should work for wide generic classes.

Additional context
Maybe I don't see the reason why toTypeName requests TypeParameterResolver.

@Scogun Scogun added the bug label Jan 22, 2025
@ZacSweers
Copy link
Collaborator

Can you offer a minimally reproducing sample? This isn't really actionable on the current details offered

@Scogun
Copy link
Author

Scogun commented Jan 22, 2025

The problem is introduced here.
I used toClassName for any classes. Right now it fails for generic ones.
I can change this code:

(this.declaration as KSClassDeclaration).getAllSuperTypes().any { it.toClassName() == ITERABLE }

to

(this.declaration as KSClassDeclaration).getAllSuperTypes().any { (it.declaration as KSClassDeclaration).toClassName() == ITERABLE }

but it also will fail here:

sourceType.toClassName() == STRING

if sourceType is generic.
It brings a lot of additional checkings.

@JakeWharton
Copy link
Collaborator

What we are asking for is a minimally-reproducing sample for the toTypeName crash.

@Scogun
Copy link
Author

Scogun commented Jan 22, 2025

I know. It's just hard to make a small sample while it happens into kotlinpoet-ksp. So, I tried to explain.

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

No branches or pull requests

3 participants