Navigation: Resolve typealiased SAM-references to type alias declaration
#KT-15302 Fixed
This commit is contained in:
+8
-3
@@ -17,17 +17,22 @@
|
|||||||
package org.jetbrains.kotlin.load.java.sam
|
package org.jetbrains.kotlin.load.java.sam
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
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.TypeAliasDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||||
|
|
||||||
interface SamTypeAliasConstructorDescriptor : SamConstructorDescriptor {
|
interface SamTypeAliasConstructorDescriptor : SamConstructorDescriptor, DeclarationDescriptorWithNavigationSubstitute {
|
||||||
val typeAliasDescriptor: TypeAliasDescriptor
|
val typeAliasDescriptor: TypeAliasDescriptor
|
||||||
|
|
||||||
|
override val substitute: DeclarationDescriptor
|
||||||
|
get() = typeAliasDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
class SamTypeAliasConstructorDescriptorImpl(
|
class SamTypeAliasConstructorDescriptorImpl(
|
||||||
override val typeAliasDescriptor: TypeAliasDescriptor,
|
override val typeAliasDescriptor: TypeAliasDescriptor,
|
||||||
private val samInterfaceConstructorDescriptor: SamConstructorDescriptor
|
private val samInterfaceConstructorDescriptor: SamConstructorDescriptor
|
||||||
) : SimpleFunctionDescriptorImpl(
|
) : SimpleFunctionDescriptorImpl(
|
||||||
typeAliasDescriptor.containingDeclaration,
|
typeAliasDescriptor.containingDeclaration,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ import java.util.*
|
|||||||
|
|
||||||
object DescriptorToSourceUtils {
|
object DescriptorToSourceUtils {
|
||||||
private fun collectEffectiveReferencedDescriptors(result: MutableList<DeclarationDescriptor>, descriptor: DeclarationDescriptor) {
|
private fun collectEffectiveReferencedDescriptors(result: MutableList<DeclarationDescriptor>, descriptor: DeclarationDescriptor) {
|
||||||
|
if (descriptor is DeclarationDescriptorWithNavigationSubstitute) {
|
||||||
|
collectEffectiveReferencedDescriptors(result, descriptor.substitute)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (descriptor is CallableMemberDescriptor) {
|
if (descriptor is CallableMemberDescriptor) {
|
||||||
val kind = descriptor.kind
|
val kind = descriptor.kind
|
||||||
if (kind != DECLARATION && kind != SYNTHESIZED) {
|
if (kind != DECLARATION && kind != SYNTHESIZED) {
|
||||||
|
|||||||
+10
@@ -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
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
public interface Runnable {
|
||||||
|
public abstract void run();
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
typealias S = Runnable
|
||||||
|
val r1 = S {}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
public interface Runnable {
|
||||||
|
public abstract void run();
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
typealias /*rename*/R = Runnable
|
||||||
|
val r1 = R {}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"type": "MARKED_ELEMENT",
|
||||||
|
"mainFile": "test/test.kt",
|
||||||
|
"newName": "S",
|
||||||
|
"withRuntime": "true"
|
||||||
|
}
|
||||||
+6
@@ -1285,6 +1285,12 @@ public class RenameTestGenerated extends AbstractRenameTest {
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("secondaryCnstructorParameterRedeclaration/secondaryConstructorParameterRedeclaration.test")
|
||||||
public void testSecondaryCnstructorParameterRedeclaration_SecondaryConstructorParameterRedeclaration() throws Exception {
|
public void testSecondaryCnstructorParameterRedeclaration_SecondaryConstructorParameterRedeclaration() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/secondaryCnstructorParameterRedeclaration/secondaryConstructorParameterRedeclaration.test");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/secondaryCnstructorParameterRedeclaration/secondaryConstructorParameterRedeclaration.test");
|
||||||
|
|||||||
Reference in New Issue
Block a user