[LC] preserve type annotations from wildcard bound

^KT-66603
This commit is contained in:
Dmitrii Gridin
2024-03-14 18:34:10 +01:00
committed by Space Team
parent 96575a0bdb
commit 54aee57fec
6 changed files with 28 additions and 21 deletions
@@ -1,2 +1,2 @@
KtType: @foo.MyAnno(s = "outer") kotlin.collections.List<@foo.MyAnno(s = "middle") kotlin.collections.List<@foo.AnotherAnnotation(k = foo.Nested::class) kotlin.String>>
PsiType: java.util.@foo.MyAnno("outer") List<@foo.MyAnno("middle") ? extends java.util.List<? extends java.lang.String>>
PsiType: java.util.@foo.MyAnno("outer") List<? extends java.util.@foo.MyAnno("middle") List<? extends java.lang.@foo.AnotherAnnotation(Nested::class) String>>
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -96,6 +96,13 @@ fun PsiType.annotateByTypeAnnotationProvider(
fun recursiveAnnotator(psiType: PsiType) {
if (!annotationsIterator.hasNext()) return
if (psiType is PsiWildcardType) {
// Wildcard itself cannot have annotations
psiType.bound?.let(::recursiveAnnotator)
return
}
val typeAnnotations = annotationsIterator.next()
when (psiType) {