lightClassUtils: Fix CCE when trying to obtain KtLightTypeParameter

#KT-12259 Fixed
This commit is contained in:
Pavel V. Talanov
2016-05-23 16:40:45 +03:00
parent 62421bbf7b
commit 710e920df7
4 changed files with 10 additions and 1 deletions
@@ -104,7 +104,7 @@ fun KtTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
val jetDeclaration = paramList.getNonStrictParentOfType<KtDeclaration>() ?: return listOf()
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
@@ -0,0 +1,2 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtTypeParameter
val <T<caret>> foo: T
@@ -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");
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")