[Analysis API FIR] KtFirPsiTypeProvider: support type parameter position in asKtType
^KT-66530
This commit is contained in:
committed by
Space Team
parent
675bf36049
commit
ba421aa320
+9
-3
@@ -58,8 +58,10 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatform
|
||||
import org.jetbrains.kotlin.psi
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
||||
import org.jetbrains.kotlin.types.updateArgumentModeFromAnnotations
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import java.text.StringCharacterIterator
|
||||
|
||||
internal class KtFirPsiTypeProvider(
|
||||
@@ -144,7 +146,7 @@ internal class KtFirPsiTypeProvider(
|
||||
val javaTypeParameterStack = MutableJavaTypeParameterStack()
|
||||
|
||||
var psiClass = PsiTreeUtil.getContextOfType(useSitePosition, PsiClass::class.java, false)
|
||||
while (psiClass != null && psiClass.name == null) {
|
||||
while (psiClass != null && psiClass.name == null || psiClass is PsiTypeParameter) {
|
||||
psiClass = PsiTreeUtil.getContextOfType(psiClass, PsiClass::class.java, true)
|
||||
}
|
||||
if (psiClass != null) {
|
||||
@@ -161,9 +163,13 @@ internal class KtFirPsiTypeProvider(
|
||||
),
|
||||
javaClass
|
||||
)
|
||||
|
||||
if (containingClassSymbol != null) {
|
||||
val member =
|
||||
PsiTreeUtil.getContextOfType(useSitePosition, PsiTypeParameterListOwner::class.java, false, PsiClass::class.java)
|
||||
val member = useSitePosition.parentsWithSelf
|
||||
.filterNot { it is PsiTypeParameter }
|
||||
.takeWhile { it !is PsiClass }
|
||||
.firstIsInstanceOrNull<PsiTypeParameterListOwner>()
|
||||
|
||||
if (member != null) {
|
||||
val memberSymbol = containingClassSymbol.declarationSymbols.find { it.findPsi() == member } as? FirCallableSymbol<*>
|
||||
if (memberSymbol != null) {
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
PsiType: PsiType:TYPE
|
||||
KtType: TYPE
|
||||
KtType: TYPE?
|
||||
|
||||
Reference in New Issue
Block a user