Skip to content

KSTypeReference.toTypeName losses parameter annotations #1946

Open
@milis92

Description

@milis92

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions