diff --git a/plugins/uast-kotlin/testData/Resolve.kt b/plugins/uast-kotlin/testData/Resolve.kt index 4100a17ba41..162eeb2e154 100644 --- a/plugins/uast-kotlin/testData/Resolve.kt +++ b/plugins/uast-kotlin/testData/Resolve.kt @@ -1,4 +1,4 @@ -class A { +open class A { fun foo() {} inline fun inlineFoo() { @@ -17,3 +17,14 @@ fun bar() { intRange.contains(2 as Int) // extension-fun with @JvmName("longRangeContains") IntRange(1, 2) // constructor from stdlib } + +fun barT(t: T) { + t.foo() +} + +fun > barTL(listT: T) { + listT.isEmpty() + for (a in listT) { + a.foo() + } +} \ No newline at end of file diff --git a/plugins/uast-kotlin/tests/KotlinUastApiTest.kt b/plugins/uast-kotlin/tests/KotlinUastApiTest.kt index 67a6c72a561..3d374de7a1b 100644 --- a/plugins/uast-kotlin/tests/KotlinUastApiTest.kt +++ b/plugins/uast-kotlin/tests/KotlinUastApiTest.kt @@ -431,7 +431,6 @@ class KotlinUastApiTest : AbstractKotlinUastTest() { @Test fun testResolvedDeserializedMethod() = doTest("Resolve") { _, file -> - val barMethod = file.findElementByTextFromPsi("bar").getParentOfType()!! fun UElement.assertResolveCall(callText: String, methodName: String = callText.substringBefore("(")) { this.findElementByTextFromPsi(callText).let { @@ -439,14 +438,27 @@ class KotlinUastApiTest : AbstractKotlinUastTest() { assertEquals(methodName, resolve.name) } } - barMethod.assertResolveCall("foo()") - barMethod.assertResolveCall("inlineFoo()") - barMethod.assertResolveCall("forEach { println(it) }", "forEach") - barMethod.assertResolveCall("joinToString()") - barMethod.assertResolveCall("last()") - barMethod.assertResolveCall("setValue(\"123\")") - barMethod.assertResolveCall("contains(2 as Int)", "longRangeContains") - barMethod.assertResolveCall("IntRange(1, 2)") + + file.findElementByTextFromPsi("bar").getParentOfType()!!.let { barMethod -> + barMethod.assertResolveCall("foo()") + barMethod.assertResolveCall("inlineFoo()") + barMethod.assertResolveCall("forEach { println(it) }", "forEach") + barMethod.assertResolveCall("joinToString()") + barMethod.assertResolveCall("last()") + barMethod.assertResolveCall("setValue(\"123\")") + barMethod.assertResolveCall("contains(2 as Int)", "longRangeContains") + barMethod.assertResolveCall("IntRange(1, 2)") + } + + file.findElementByTextFromPsi("barT").getParentOfType()!!.let { barMethod -> + barMethod.assertResolveCall("foo()") + } + + file.findElementByTextFromPsi("listT").getParentOfType()!!.let { barMethod -> + barMethod.assertResolveCall("isEmpty()") + barMethod.assertResolveCall("foo()") + } + } @Test diff --git a/plugins/uast-kotlin/tests/KotlinUastApiTest.kt.191 b/plugins/uast-kotlin/tests/KotlinUastApiTest.kt.191 index b9dc2a90c68..8d328472a12 100644 --- a/plugins/uast-kotlin/tests/KotlinUastApiTest.kt.191 +++ b/plugins/uast-kotlin/tests/KotlinUastApiTest.kt.191 @@ -432,7 +432,6 @@ class KotlinUastApiTest : AbstractKotlinUastTest() { @Test fun testResolvedDeserializedMethod() = doTest("Resolve") { _, file -> - val barMethod = file.findElementByTextFromPsi("bar").getParentOfType()!! fun UElement.assertResolveCall(callText: String, methodName: String = callText.substringBefore("(")) { this.findElementByTextFromPsi(callText).let { @@ -440,14 +439,27 @@ class KotlinUastApiTest : AbstractKotlinUastTest() { assertEquals(methodName, resolve.name) } } - barMethod.assertResolveCall("foo()") - barMethod.assertResolveCall("inlineFoo()") - barMethod.assertResolveCall("forEach { println(it) }", "forEach") - barMethod.assertResolveCall("joinToString()") - barMethod.assertResolveCall("last()") - barMethod.assertResolveCall("setValue(\"123\")") - barMethod.assertResolveCall("contains(2 as Int)", "longRangeContains") - barMethod.assertResolveCall("IntRange(1, 2)") + + file.findElementByTextFromPsi("bar").getParentOfType()!!.let { barMethod -> + barMethod.assertResolveCall("foo()") + barMethod.assertResolveCall("inlineFoo()") + barMethod.assertResolveCall("forEach { println(it) }", "forEach") + barMethod.assertResolveCall("joinToString()") + barMethod.assertResolveCall("last()") + barMethod.assertResolveCall("setValue(\"123\")") + barMethod.assertResolveCall("contains(2 as Int)", "longRangeContains") + barMethod.assertResolveCall("IntRange(1, 2)") + } + + file.findElementByTextFromPsi("barT").getParentOfType()!!.let { barMethod -> + barMethod.assertResolveCall("foo()") + } + + file.findElementByTextFromPsi("listT").getParentOfType()!!.let { barMethod -> + barMethod.assertResolveCall("isEmpty()") + barMethod.assertResolveCall("foo()") + } + } @Test