PSI Unifier: Unify references which correspond to the same declaration
#KT-5996 Fixed
This commit is contained in:
@@ -160,6 +160,7 @@ public class JetPsiUnifier(
|
||||
val decl1 = DescriptorToSourceUtils.descriptorToDeclaration(d1) as? JetDeclaration
|
||||
val decl2 = DescriptorToSourceUtils.descriptorToDeclaration(d2) as? JetDeclaration
|
||||
if (decl1 == null || decl2 == null) return false
|
||||
if (decl1 == decl2) return true
|
||||
|
||||
if ((decl1 in originalTarget && decl2 in originalPattern) || (decl2 in originalTarget && decl1 in originalPattern)) {
|
||||
return matchDeclarations(decl1, decl2, d1, d2) == MATCHED
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
trait T {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
trait U: T
|
||||
|
||||
fun test(t: T): Int {
|
||||
return if (t is U)
|
||||
<selection>t.foo()</selection> + 1
|
||||
else t.foo()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
trait T {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
trait U: T
|
||||
|
||||
fun test(t: T): Int {
|
||||
val i = t.foo()
|
||||
return if (t is U)
|
||||
i + 1
|
||||
else i
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
trait T {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
trait U: T
|
||||
|
||||
fun test(t: T): Int {
|
||||
return if (t is U)
|
||||
<selection>t.foo()</selection> + 1
|
||||
else t.foo()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
t.foo()
|
||||
|
||||
t.foo()
|
||||
+6
@@ -49,6 +49,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
|
||||
doIntroduceVariableTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("callUnderSmartCast.kt")
|
||||
public void testCallUnderSmartCast() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/callUnderSmartCast.kt");
|
||||
doIntroduceVariableTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ClassBody.kt")
|
||||
public void testClassBody() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/ClassBody.kt");
|
||||
|
||||
@@ -425,6 +425,12 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("callUnderSmartCast.kt")
|
||||
public void testCallUnderSmartCast() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/calls/callUnderSmartCast.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("externalArgumentsRuntime.kt")
|
||||
public void testExternalArgumentsRuntime() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/calls/externalArgumentsRuntime.kt");
|
||||
|
||||
Reference in New Issue
Block a user