From 830bf62d94316ca19e7a6211dc50b707b554fa0b Mon Sep 17 00:00:00 2001 From: Vyacheslav Gerasimov Date: Fri, 10 Mar 2017 15:46:50 +0300 Subject: [PATCH] Fix SOE from UAST in containsLocalType containsLocalType now properly handles start projections #KT-16680 Fixed --- .../uast/kotlin/internal/kotlinInternalUastUtils.kt | 6 +----- plugins/uast-kotlin/testData/CycleInTypeParameters.kt | 4 ++++ .../testData/cycleInTypeParameters.types.txt | 10 ++++++++++ plugins/uast-kotlin/tests/KotlinUastTypesTest.kt | 2 ++ 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 plugins/uast-kotlin/testData/CycleInTypeParameters.kt create mode 100644 plugins/uast-kotlin/testData/cycleInTypeParameters.types.txt diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt index 254f8647a54..7bf5b9c7639 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt @@ -109,11 +109,7 @@ private fun KotlinType.containsLocalTypes(): Boolean { } } - if (arguments.any { it.type.containsLocalTypes() }) { - return true - } - - return false + return arguments.any { !it.isStarProjection && it.type.containsLocalTypes() } } internal fun KtTypeReference?.toPsiType(source: UElement, boxed: Boolean = false): PsiType { diff --git a/plugins/uast-kotlin/testData/CycleInTypeParameters.kt b/plugins/uast-kotlin/testData/CycleInTypeParameters.kt new file mode 100644 index 00000000000..89e7ce61dd1 --- /dev/null +++ b/plugins/uast-kotlin/testData/CycleInTypeParameters.kt @@ -0,0 +1,4 @@ + +class Device> + +val a = null as? Device<*> diff --git a/plugins/uast-kotlin/testData/cycleInTypeParameters.types.txt b/plugins/uast-kotlin/testData/cycleInTypeParameters.types.txt new file mode 100644 index 00000000000..abfb578c83c --- /dev/null +++ b/plugins/uast-kotlin/testData/cycleInTypeParameters.types.txt @@ -0,0 +1,10 @@ +UFile (package = ) [public final class CycleInTypeParametersKt {...] + UClass (name = CycleInTypeParametersKt) [public final class CycleInTypeParametersKt {...}] + UField (name = a) [private static final var a: Device = null as? Device] + UAnnotation (fqName = org.jetbrains.annotations.Nullable) [@org.jetbrains.annotations.Nullable] + UBinaryExpressionWithType [null as? Device] : PsiType:Device + ULiteralExpression (value = null) [null] : PsiType:Void + UTypeReferenceExpression (name = Device) [Device] + UAnnotationMethod (name = getA) [public static final fun getA() : Device = UastEmptyExpression] + UClass (name = Device) [public final class Device {...}] + UAnnotationMethod (name = Device) [public fun Device() = UastEmptyExpression] diff --git a/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt b/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt index 4f3dbd13be3..6a7c1895f3c 100644 --- a/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt +++ b/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt @@ -6,4 +6,6 @@ class KotlinUastTypesTest : AbstractKotlinTypesTest() { @Test fun testLocalDeclarations() = doTest("LocalDeclarations") @Test fun testUnexpectedContainerException() = doTest("UnexpectedContainerException") + + @Test fun testCycleInTypeParameters() = doTest("cycleInTypeParameters") } \ No newline at end of file