diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt index b4e2d3aa20e..a7311f8a7a2 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/KtSimpleNameReference.kt @@ -190,6 +190,16 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere val shortName = fqName.shortName().asString() val psiFactory = KtPsiFactory(this) val parent = parent + + if (parent is KtUserType && !fqName.isOneSegmentFQN()) { + val qualifier = parent.qualifier + val qualifierReference = qualifier?.referenceExpression as? KtNameReferenceExpression + if (qualifierReference != null && qualifier.typeArguments.isNotEmpty()) { + qualifierReference.changeQualifiedName(fqName.parent()) + return this + } + } + var parentDelimiter = "." val fqNameBase = when { parent is KtCallElement -> { diff --git a/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/after/source/dummy.txt b/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/after/source/dummy.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/after/target/Foo.kt b/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/after/target/Foo.kt new file mode 100644 index 00000000000..b4e8eaebedb --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/after/target/Foo.kt @@ -0,0 +1,11 @@ +package target + +class OuterClass { + inner class InnerClass + + class NestedClass + typealias NestedType = NestedClass +} +typealias OI = OuterClass.InnerClass // (1) +typealias ON1 = OuterClass.NestedClass // (2) +typealias ON2 = OuterClass.NestedType \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/before/source/Foo.kt b/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/before/source/Foo.kt new file mode 100644 index 00000000000..3ab8a81ff25 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/before/source/Foo.kt @@ -0,0 +1,11 @@ +package source + +class OuterClass { + inner class InnerClass + + class NestedClass + typealias NestedType = NestedClass +} +typealias OI = OuterClass.InnerClass // (1) +typealias ON1 = OuterClass.NestedClass // (2) +typealias ON2 = OuterClass.NestedType \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/before/source/dummy.txt b/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/before/source/dummy.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/typeRefWithArguments.test b/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/typeRefWithArguments.test new file mode 100644 index 00000000000..a8404d26806 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/typeRefWithArguments.test @@ -0,0 +1,5 @@ +{ + "mainFile": "source/Foo.kt", + "type": "MOVE_FILES", + "targetPackage": "target" +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java index 3143e2c1deb..373a6368a11 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java @@ -307,6 +307,12 @@ public class MoveTestGenerated extends AbstractMoveTest { doTest(fileName); } + @TestMetadata("kotlin/moveFile/typeRefWithArguments/typeRefWithArguments.test") + public void testKotlin_moveFile_typeRefWithArguments_TypeRefWithArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveFile/typeRefWithArguments/typeRefWithArguments.test"); + doTest(fileName); + } + @TestMetadata("kotlin/moveNestedClass/deepInnerToTopLevelWithOuterOuterThis/deepInnerToTopLevelWithOuterOuterThis.test") public void testKotlin_moveNestedClass_deepInnerToTopLevelWithOuterOuterThis_DeepInnerToTopLevelWithOuterOuterThis() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveNestedClass/deepInnerToTopLevelWithOuterOuterThis/deepInnerToTopLevelWithOuterOuterThis.test");