lightClassUtils: Fix CCE when trying to obtain KtLightTypeParameter
#KT-12259 Fixed
This commit is contained in:
@@ -104,7 +104,7 @@ fun KtTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
|
|||||||
val jetDeclaration = paramList.getNonStrictParentOfType<KtDeclaration>() ?: return listOf()
|
val jetDeclaration = paramList.getNonStrictParentOfType<KtDeclaration>() ?: return listOf()
|
||||||
val lightOwners = jetDeclaration.toLightElements()
|
val lightOwners = jetDeclaration.toLightElements()
|
||||||
|
|
||||||
return lightOwners.map { lightOwner -> (lightOwner as PsiTypeParameterListOwner).typeParameters[paramIndex] }
|
return lightOwners.mapNotNull { lightOwner -> (lightOwner as? PsiTypeParameterListOwner)?.typeParameters?.get(paramIndex) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns original declaration if given PsiElement is a Kotlin light element, and element itself otherwise
|
// Returns original declaration if given PsiElement is a Kotlin light element, and element itself otherwise
|
||||||
|
|||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtTypeParameter
|
||||||
|
val <T<caret>> foo: T
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
Class/object property type 2 val <T> foo: T
|
||||||
@@ -1079,6 +1079,12 @@ public class FindUsagesTestGenerated extends AbstractFindUsagesTest {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findTypeParameterUsages/kotlinFunctionTypeParameterUsages.0.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findTypeParameterUsages/kotlinFunctionTypeParameterUsages.0.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("propertyWithTypeParameter.0.kt")
|
||||||
|
public void testPropertyWithTypeParameter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findTypeParameterUsages/propertyWithTypeParameter.0.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/findUsages/kotlin/findWithFilteringImports")
|
@TestMetadata("idea/testData/findUsages/kotlin/findWithFilteringImports")
|
||||||
|
|||||||
Reference in New Issue
Block a user