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

KSTypeReference.toTypeName losses parameter annotations #1946

Open
milis92 opened this issue Jul 17, 2024 · 2 comments
Open

KSTypeReference.toTypeName losses parameter annotations #1946

milis92 opened this issue Jul 17, 2024 · 2 comments
Labels

Comments

@milis92
Copy link

milis92 commented Jul 17, 2024

Describe the bug
Consider the following function

interface Factory

fun doSomething(factories: Set<@JvmSuppressWildcards Factory>) {
}
 // or
fun doSomething(factories: @JvmSuppressWildcards Set<Factory>) {
}

And later in the processor

// Where functionDeclaration is the doSomething function decleration
functionDeclaration.parameters.map(KSValueParameter::toParameterSpec)
 
fun KSValueParameter.toParameterSpec(): ParameterSpec {
    return ParameterSpec.builder(
        name = name?.asString().orEmpty(),
        type = type.toTypeName(),
    ).build()
}

Produced ParameterSpec will lose the annotations applied to the original function.

Expected behavior
I would expect the KSTypeReference.toTypeName to preserve annotations applied to function parameters and TypeArguments if any.

@milis92 milis92 added the bug label Jul 17, 2024
@milis92
Copy link
Author

milis92 commented Jul 17, 2024

As an extension to the bug report, consider adding KSValueParameter.toParameterSpec() to the public API.

@ZacSweers
Copy link
Collaborator

As an extension to the bug report, consider adding KSValueParameter.toParameterSpec() to the public API.

Please file a separate issue

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

2 participants