diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamTypeAliasConstructorDescriptor.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamTypeAliasConstructorDescriptor.kt index 0367505543e..c08bb01e0e1 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamTypeAliasConstructorDescriptor.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamTypeAliasConstructorDescriptor.kt @@ -17,17 +17,22 @@ package org.jetbrains.kotlin.load.java.sam import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithNavigationSubstitute import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor -interface SamTypeAliasConstructorDescriptor : SamConstructorDescriptor { +interface SamTypeAliasConstructorDescriptor : SamConstructorDescriptor, DeclarationDescriptorWithNavigationSubstitute { val typeAliasDescriptor: TypeAliasDescriptor + + override val substitute: DeclarationDescriptor + get() = typeAliasDescriptor } class SamTypeAliasConstructorDescriptorImpl( - override val typeAliasDescriptor: TypeAliasDescriptor, - private val samInterfaceConstructorDescriptor: SamConstructorDescriptor + override val typeAliasDescriptor: TypeAliasDescriptor, + private val samInterfaceConstructorDescriptor: SamConstructorDescriptor ) : SimpleFunctionDescriptorImpl( typeAliasDescriptor.containingDeclaration, null, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorToSourceUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorToSourceUtils.kt index c881258a8ac..34cbf0996c8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorToSourceUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorToSourceUtils.kt @@ -31,6 +31,11 @@ import java.util.* object DescriptorToSourceUtils { private fun collectEffectiveReferencedDescriptors(result: MutableList, descriptor: DeclarationDescriptor) { + if (descriptor is DeclarationDescriptorWithNavigationSubstitute) { + collectEffectiveReferencedDescriptors(result, descriptor.substitute) + return + } + if (descriptor is CallableMemberDescriptor) { val kind = descriptor.kind if (kind != DECLARATION && kind != SYNTHESIZED) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/DeclarationDescriptorWithNavigationSubstitute.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/DeclarationDescriptorWithNavigationSubstitute.kt new file mode 100644 index 00000000000..f243024bc06 --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/DeclarationDescriptorWithNavigationSubstitute.kt @@ -0,0 +1,10 @@ +/* + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.descriptors + +interface DeclarationDescriptorWithNavigationSubstitute : DeclarationDescriptor { + val substitute: DeclarationDescriptor +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/samConstructorTypeAlias/after/test/Runnable.java b/idea/testData/refactoring/rename/samConstructorTypeAlias/after/test/Runnable.java new file mode 100644 index 00000000000..0759a81f4f7 --- /dev/null +++ b/idea/testData/refactoring/rename/samConstructorTypeAlias/after/test/Runnable.java @@ -0,0 +1,3 @@ +public interface Runnable { + public abstract void run(); +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/samConstructorTypeAlias/after/test/test.kt b/idea/testData/refactoring/rename/samConstructorTypeAlias/after/test/test.kt new file mode 100644 index 00000000000..b8e72f76fb2 --- /dev/null +++ b/idea/testData/refactoring/rename/samConstructorTypeAlias/after/test/test.kt @@ -0,0 +1,2 @@ +typealias S = Runnable +val r1 = S {} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/samConstructorTypeAlias/before/test/Runnable.java b/idea/testData/refactoring/rename/samConstructorTypeAlias/before/test/Runnable.java new file mode 100644 index 00000000000..0759a81f4f7 --- /dev/null +++ b/idea/testData/refactoring/rename/samConstructorTypeAlias/before/test/Runnable.java @@ -0,0 +1,3 @@ +public interface Runnable { + public abstract void run(); +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/samConstructorTypeAlias/before/test/test.kt b/idea/testData/refactoring/rename/samConstructorTypeAlias/before/test/test.kt new file mode 100644 index 00000000000..c9de42ff821 --- /dev/null +++ b/idea/testData/refactoring/rename/samConstructorTypeAlias/before/test/test.kt @@ -0,0 +1,2 @@ +typealias /*rename*/R = Runnable +val r1 = R {} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/samConstructorTypeAlias/samConstructorTypeAlias.test b/idea/testData/refactoring/rename/samConstructorTypeAlias/samConstructorTypeAlias.test new file mode 100644 index 00000000000..9bebc6a9bbb --- /dev/null +++ b/idea/testData/refactoring/rename/samConstructorTypeAlias/samConstructorTypeAlias.test @@ -0,0 +1,6 @@ +{ + "type": "MARKED_ELEMENT", + "mainFile": "test/test.kt", + "newName": "S", + "withRuntime": "true" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java index 50d09836019..34c72ff186f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java @@ -1285,6 +1285,12 @@ public class RenameTestGenerated extends AbstractRenameTest { doTest(fileName); } + @TestMetadata("samConstructorTypeAlias/samConstructorTypeAlias.test") + public void testSamConstructorTypeAlias_SamConstructorTypeAlias() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/samConstructorTypeAlias/samConstructorTypeAlias.test"); + doTest(fileName); + } + @TestMetadata("secondaryCnstructorParameterRedeclaration/secondaryConstructorParameterRedeclaration.test") public void testSecondaryCnstructorParameterRedeclaration_SecondaryConstructorParameterRedeclaration() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/secondaryCnstructorParameterRedeclaration/secondaryConstructorParameterRedeclaration.test");