diff --git a/idea/testData/findUsages/kotlin/conventions/components/dataClass.0.java b/idea/testData/findUsages/kotlin/conventions/components/dataClass.0.java index 6eb94c71668..85b9159d78b 100644 --- a/idea/testData/findUsages/kotlin/conventions/components/dataClass.0.java +++ b/idea/testData/findUsages/kotlin/conventions/components/dataClass.0.java @@ -12,4 +12,10 @@ class JavaClass { } public void takeA(A a){} + + private A getAPrivate() { + return new A(1, "", ""); + } + + private void takeAPrivate(A a){} } diff --git a/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.0.kt b/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.0.kt new file mode 100644 index 00000000000..853ac91eb0a --- /dev/null +++ b/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.0.kt @@ -0,0 +1,35 @@ +// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtParameter +// OPTIONS: usages + +data class A(val n: Int, val s: String) + +data class B(val x: Int, val y: Int) + +fun condition(a: A) = true + +fun x(a: A, b: Boolean, list: List) { + val (x, y) = if (condition(a)) { + print(A(1, "").toString()) + B(1, 2) + } + else { + B(3, 4) + } + + val (x1, y1) = if (b) { + A(1, "").apply { val (x2, y2) = this } + } + else { + return + } + + if (list.any { it == 0 }) { + A(1, "") + } +} + +fun y1(a: A) = condition(a) +fun y2(a: A): Boolean = condition(a) +fun y3(a: A) { + condition(a) +} diff --git a/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.log b/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.log new file mode 100644 index 00000000000..b4790860e69 --- /dev/null +++ b/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.log @@ -0,0 +1,12 @@ +Checked type of (x1, y1) +Checked type of y1() +Searched inheritors of A +Searched references to A +Searched references to parameter a in condition() in Kotlin files +Searched references to parameter a in x() in Kotlin files +Searched references to parameter a in y1() in Kotlin files +Searched references to parameter a in y2() in Kotlin files +Searched references to parameter a in y3() in Kotlin files +Used plain search in LocalSearchScope: + CLASS:A + { val (x2, y2) = this } \ No newline at end of file diff --git a/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.results.txt b/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.results.txt new file mode 100644 index 00000000000..db6050293f0 --- /dev/null +++ b/idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.results.txt @@ -0,0 +1,2 @@ +Value read 19 val (x1, y1) = if (b) { +Value read 20 A(1, "").apply { val (x2, y2) = this } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/FindUsagesTestGenerated.java b/idea/tests/org/jetbrains/kotlin/findUsages/FindUsagesTestGenerated.java index 88a0bc73b42..7146f20c580 100644 --- a/idea/tests/org/jetbrains/kotlin/findUsages/FindUsagesTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/findUsages/FindUsagesTestGenerated.java @@ -242,6 +242,12 @@ public class FindUsagesTestGenerated extends AbstractFindUsagesTest { doTest(fileName); } + @TestMetadata("mayTypeAffectAncestors.0.kt") + public void testMayTypeAffectAncestors() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/conventions/components/mayTypeAffectAncestors.0.kt"); + doTest(fileName); + } + @TestMetadata("memberComponentFun.0.kt") public void testMemberComponentFun() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/conventions/components/memberComponentFun.0.kt");