Skip to content

Commit

Permalink
restore annotations on type alias
Browse files Browse the repository at this point in the history
(cherry picked from commit 024b17a)
  • Loading branch information
neetopia authored and KSP Auto Pick committed Jan 18, 2024
1 parent e7b4b2f commit 57bb735
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import org.jetbrains.kotlin.builtins.isKFunctionType
import org.jetbrains.kotlin.builtins.isKSuspendFunctionType
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
import org.jetbrains.kotlin.descriptors.NotFoundClasses
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
Expand Down Expand Up @@ -145,8 +144,7 @@ fun getKSTypeCached(
KSTypeImpl.getCached(
kotlinType,
ksTypeArguments,
annotations + kotlinType.annotations
.filter { it.source == SourceElement.NO_SOURCE }
kotlinType.annotations
.map { KSAnnotationDescriptorImpl.getCached(it, null) }
.asSequence()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ class TypeAnnotationProcessor : AbstractTestProcessor() {
}

override fun process(resolver: Resolver): List<KSAnnotated> {
val myList = resolver.getClassDeclarationByName("MyClass")!!.getDeclaredProperties().single()
val myList = resolver.getClassDeclarationByName("MyClass")!!.getDeclaredProperties().single {
it.simpleName.asString() == "myList"
}
val myAlias = resolver.getClassDeclarationByName("MyClass")!!.getDeclaredProperties().single {
it.simpleName.asString() == "myAlias"
}
val myStringClass = resolver.getClassDeclarationByName("MyStringClass")!!.asStarProjectedType()
result.add(myList.type.resolve().annotations.joinToString())
result.add(myAlias.type.resolve().annotations.joinToString())
result.add(myList.asMemberOf(myStringClass).annotations.joinToString())
result.add(myList.type.resolve().let { it.replace(it.arguments) }.annotations.joinToString())
result.add(myList.type.resolve().starProjection().annotations.joinToString())
Expand Down
5 changes: 4 additions & 1 deletion test-utils/testData/api/typeAnnotation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
// TEST PROCESSOR: TypeAnnotationProcessor
// EXPECTED:
// @JvmSuppressWildcards
// @JvmWildcard
// @JvmSuppressWildcards
// @JvmSuppressWildcards
// @JvmSuppressWildcards
// END

interface MyType
typealias MyAlias = @JvmWildcard MyType
class MyClass<T> {
var myList: @JvmSuppressWildcards List<Foo> = TODO()
var myAlias: MyAlias = TODO()
}

class MyStringClass: MyClass<String> {}

0 comments on commit 57bb735

Please sign in to comment.