From f575e2710f42d76a33e2fa20417ca789caba170d Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 20 Apr 2017 15:18:45 +0300 Subject: [PATCH] Move: Fix processing of implicit extension 'invoke' calls Also fix bogus "unused import" inspection reported on such calls #KT-17496 Fixed --- .../kotlin/idea/references/referenceUtil.kt | 11 +++++++- .../kotlin/idea/refactoring/move/moveUtils.kt | 28 ++++++++++++------- ...rtyWithExtensionFunctionType.Dependency.kt | 7 +++++ .../propertyWithExtensionFunctionType.kt | 10 +++++++ .../differentSource/after/bar/test.kt | 4 +++ .../differentSource/after/foo/test.kt | 17 +++++++++++ .../differentSource/after/foo/vals.kt | 9 ++++++ .../differentSource/before/bar/test.kt | 19 +++++++++++++ .../differentSource/before/foo/vals.kt | 9 ++++++ .../differentSource/differentSource.test | 5 ++++ .../after/bar/test.kt | 4 +++ .../after/baz/test.kt | 21 ++++++++++++++ .../after/foo/vals.kt | 9 ++++++ .../before/bar/test.kt | 19 +++++++++++++ .../before/foo/vals.kt | 9 ++++++ .../differentSourceAndTarget.test | 5 ++++ .../differentTarget/after/bar/test.kt | 21 ++++++++++++++ .../differentTarget/after/foo/test.kt | 9 ++++++ .../differentTarget/before/foo/test.kt | 22 +++++++++++++++ .../differentTarget/differentTarget.test | 5 ++++ .../refactoring/move/MoveTestGenerated.java | 18 ++++++++++++ 21 files changed, 250 insertions(+), 11 deletions(-) create mode 100644 idea/testData/inspections/unusedImport/propertyWithExtensionFunctionType.Dependency.kt create mode 100644 idea/testData/inspections/unusedImport/propertyWithExtensionFunctionType.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/bar/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/foo/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/foo/vals.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/before/bar/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/before/foo/vals.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/differentSource.test create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/bar/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/baz/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/foo/vals.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/before/bar/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/before/foo/vals.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/differentSourceAndTarget.test create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/after/bar/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/after/foo/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/before/foo/test.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/differentTarget.test diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt index b79930905b3..25d1ed98ad5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt @@ -18,7 +18,9 @@ package org.jetbrains.kotlin.idea.references import com.intellij.psi.* import org.jetbrains.kotlin.asJava.unwrapped +import org.jetbrains.kotlin.builtins.isExtensionFunctionType import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.imports.canBeReferencedViaImport import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention @@ -232,8 +234,15 @@ fun KtReference.canBeResolvedViaImport(target: DeclarationDescriptor): Boolean { if (target.isExtension) return true // assume that any type of reference can use imports when resolved to extension val referenceExpression = this.element as? KtNameReferenceExpression ?: return false - if (CallTypeAndReceiver.detect(referenceExpression).receiver != null) return false + val callTypeAndReceiver = CallTypeAndReceiver.detect(referenceExpression) + + if (callTypeAndReceiver.receiver != null) { + if (target !is PropertyDescriptor || !target.type.isExtensionFunctionType) return false + if (callTypeAndReceiver !is CallTypeAndReceiver.DOT && callTypeAndReceiver !is CallTypeAndReceiver.SAFE) return false + } + if (element.parent is KtThisExpression || element.parent is KtSuperExpression) return false // TODO: it's a bad design of PSI tree, we should change it + return true } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt index e9735284b03..dccbcfd516e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt @@ -29,9 +29,10 @@ import com.intellij.usageView.UsageInfo import com.intellij.util.IncorrectOperationException import com.intellij.util.SmartList import com.intellij.util.containers.MultiMap -import org.jetbrains.kotlin.asJava.namedUnwrappedElement +import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.KotlinFileType +import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde @@ -47,10 +48,9 @@ import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall -import org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor -import org.jetbrains.kotlin.resolve.descriptorUtil.isAncestorOf -import org.jetbrains.kotlin.resolve.descriptorUtil.isCompanionObject -import org.jetbrains.kotlin.resolve.descriptorUtil.parents +import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall +import org.jetbrains.kotlin.resolve.descriptorUtil.* +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver import org.jetbrains.kotlin.utils.addIfNotNull @@ -120,7 +120,7 @@ fun KtElement.processInternalReferencesToUpdateOnPackageNameChange( if (descriptor is ClassDescriptor && descriptor.isInner && refExpr.parent is KtCallExpression) return null val isCallable = descriptor is CallableDescriptor - val isExtension = isCallable && (descriptor as CallableDescriptor).extensionReceiverParameter != null + val isExtension = isCallable && refExpr.isExtensionRef(bindingContext) val isCallableReference = isCallableReference(refExpr.mainReference) if (isCallable) { @@ -238,18 +238,26 @@ private enum class ReferenceKind { IRRELEVANT } +private fun KtSimpleNameExpression.isExtensionRef(bindingContext: BindingContext? = null): Boolean { + val resolvedCall = getResolvedCall(bindingContext ?: analyze(BodyResolveMode.PARTIAL)) ?: return false + if (resolvedCall is VariableAsFunctionResolvedCall) { + return resolvedCall.variableCall.candidateDescriptor.isExtension || resolvedCall.functionCall.candidateDescriptor.isExtension + } + return resolvedCall.candidateDescriptor.isExtension +} + private fun getReferenceKind(reference: PsiReference, referencedElement: PsiElement): ReferenceKind { + val target = referencedElement.unwrapped val element = reference.element as? KtSimpleNameExpression ?: return ReferenceKind.QUALIFIABLE if (element.getStrictParentOfType() != null) return ReferenceKind.IRRELEVANT - if ((referencedElement.namedUnwrappedElement as? KtDeclaration)?.isExtensionDeclaration() ?: false - && reference.element.getNonStrictParentOfType() == null) return ReferenceKind.UNQUALIFIABLE + if (element.isExtensionRef() && reference.element.getNonStrictParentOfType() == null) return ReferenceKind.UNQUALIFIABLE element.getParentOfTypeAndBranch { callableReference }?.let { if (it.receiverExpression != null) return ReferenceKind.IRRELEVANT - if (referencedElement is KtDeclaration && referencedElement.parent is KtFile) return ReferenceKind.UNQUALIFIABLE - if (referencedElement is PsiMember && referencedElement.getContainingClass() == null) return ReferenceKind.UNQUALIFIABLE + if (target is KtDeclaration && target.parent is KtFile) return ReferenceKind.UNQUALIFIABLE + if (target is PsiMember && target.containingClass == null) return ReferenceKind.UNQUALIFIABLE } return ReferenceKind.QUALIFIABLE diff --git a/idea/testData/inspections/unusedImport/propertyWithExtensionFunctionType.Dependency.kt b/idea/testData/inspections/unusedImport/propertyWithExtensionFunctionType.Dependency.kt new file mode 100644 index 00000000000..b0ba4d4e69c --- /dev/null +++ b/idea/testData/inspections/unusedImport/propertyWithExtensionFunctionType.Dependency.kt @@ -0,0 +1,7 @@ +package foo + +class CrExtended + +val funExtension = fun CrExtended.(): Unit {} + +// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/inspections/unusedImport/propertyWithExtensionFunctionType.kt b/idea/testData/inspections/unusedImport/propertyWithExtensionFunctionType.kt new file mode 100644 index 00000000000..fa895ffd5b0 --- /dev/null +++ b/idea/testData/inspections/unusedImport/propertyWithExtensionFunctionType.kt @@ -0,0 +1,10 @@ +package bar + +import foo.CrExtended +import foo.funExtension + +fun test() { + CrExtended().funExtension() +} + +// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/bar/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/bar/test.kt new file mode 100644 index 00000000000..f437b3c0612 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/bar/test.kt @@ -0,0 +1,4 @@ +package bar + +class CrExtended + diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/foo/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/foo/test.kt new file mode 100644 index 00000000000..39f8a1ff29a --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/foo/test.kt @@ -0,0 +1,17 @@ +package foo + +import bar.CrExtended + +fun test(ce: CrExtended) { + valWithFunType() + ce.valWithExtFunType() + with(1) { + extValWithFunType() + ce.extValWithExtFunType() + } + + ::valWithFunType + ::valWithExtFunType + 1::extValWithFunType + 1::extValWithExtFunType +} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/foo/vals.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/foo/vals.kt new file mode 100644 index 00000000000..0aadd873d5d --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/after/foo/vals.kt @@ -0,0 +1,9 @@ +package foo + +import bar.CrExtended + +val valWithFunType = fun (): Unit {} +val valWithExtFunType = fun CrExtended.(): Unit {} +val Int.extValWithFunType get() = fun (): Unit {} +val Int.extValWithExtFunType get() = fun CrExtended.(): Unit {} + diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/before/bar/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/before/bar/test.kt new file mode 100644 index 00000000000..ae1a7c98d29 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/before/bar/test.kt @@ -0,0 +1,19 @@ +package bar + +import foo.* + +class CrExtended + +fun test(ce: CrExtended) { + valWithFunType() + ce.valWithExtFunType() + with(1) { + extValWithFunType() + ce.extValWithExtFunType() + } + + ::valWithFunType + ::valWithExtFunType + 1::extValWithFunType + 1::extValWithExtFunType +} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/before/foo/vals.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/before/foo/vals.kt new file mode 100644 index 00000000000..0aadd873d5d --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/before/foo/vals.kt @@ -0,0 +1,9 @@ +package foo + +import bar.CrExtended + +val valWithFunType = fun (): Unit {} +val valWithExtFunType = fun CrExtended.(): Unit {} +val Int.extValWithFunType get() = fun (): Unit {} +val Int.extValWithExtFunType get() = fun CrExtended.(): Unit {} + diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/differentSource.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/differentSource.test new file mode 100644 index 00000000000..ddb7811ca2d --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/differentSource.test @@ -0,0 +1,5 @@ +{ + "mainFile": "bar/test.kt", + "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS", + "targetPackage": "foo" +} diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/bar/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/bar/test.kt new file mode 100644 index 00000000000..f437b3c0612 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/bar/test.kt @@ -0,0 +1,4 @@ +package bar + +class CrExtended + diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/baz/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/baz/test.kt new file mode 100644 index 00000000000..7587e2b951a --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/baz/test.kt @@ -0,0 +1,21 @@ +package baz + +import bar.CrExtended +import foo.extValWithExtFunType +import foo.extValWithFunType +import foo.valWithExtFunType +import foo.valWithFunType + +fun test(ce: CrExtended) { + valWithFunType() + ce.valWithExtFunType() + with(1) { + extValWithFunType() + ce.extValWithExtFunType() + } + + ::valWithFunType + ::valWithExtFunType + 1::extValWithFunType + 1::extValWithExtFunType +} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/foo/vals.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/foo/vals.kt new file mode 100644 index 00000000000..0aadd873d5d --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/after/foo/vals.kt @@ -0,0 +1,9 @@ +package foo + +import bar.CrExtended + +val valWithFunType = fun (): Unit {} +val valWithExtFunType = fun CrExtended.(): Unit {} +val Int.extValWithFunType get() = fun (): Unit {} +val Int.extValWithExtFunType get() = fun CrExtended.(): Unit {} + diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/before/bar/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/before/bar/test.kt new file mode 100644 index 00000000000..ae1a7c98d29 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/before/bar/test.kt @@ -0,0 +1,19 @@ +package bar + +import foo.* + +class CrExtended + +fun test(ce: CrExtended) { + valWithFunType() + ce.valWithExtFunType() + with(1) { + extValWithFunType() + ce.extValWithExtFunType() + } + + ::valWithFunType + ::valWithExtFunType + 1::extValWithFunType + 1::extValWithExtFunType +} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/before/foo/vals.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/before/foo/vals.kt new file mode 100644 index 00000000000..0aadd873d5d --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/before/foo/vals.kt @@ -0,0 +1,9 @@ +package foo + +import bar.CrExtended + +val valWithFunType = fun (): Unit {} +val valWithExtFunType = fun CrExtended.(): Unit {} +val Int.extValWithFunType get() = fun (): Unit {} +val Int.extValWithExtFunType get() = fun CrExtended.(): Unit {} + diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/differentSourceAndTarget.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/differentSourceAndTarget.test new file mode 100644 index 00000000000..0c39ea71e3d --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/differentSourceAndTarget.test @@ -0,0 +1,5 @@ +{ + "mainFile": "bar/test.kt", + "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS", + "targetPackage": "baz" +} diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/after/bar/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/after/bar/test.kt new file mode 100644 index 00000000000..9052eb06cf7 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/after/bar/test.kt @@ -0,0 +1,21 @@ +package bar + +import foo.CrExtended +import foo.extValWithExtFunType +import foo.extValWithFunType +import foo.valWithExtFunType +import foo.valWithFunType + +fun test(ce: CrExtended) { + valWithFunType() + ce.valWithExtFunType() + with(1) { + extValWithFunType() + ce.extValWithExtFunType() + } + + ::valWithFunType + ::valWithExtFunType + 1::extValWithFunType + 1::extValWithExtFunType +} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/after/foo/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/after/foo/test.kt new file mode 100644 index 00000000000..d7a438bbd71 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/after/foo/test.kt @@ -0,0 +1,9 @@ +package foo + +val valWithFunType = fun (): Unit {} +val valWithExtFunType = fun CrExtended.(): Unit {} +val Int.extValWithFunType get() = fun (): Unit {} +val Int.extValWithExtFunType get() = fun CrExtended.(): Unit {} + +class CrExtended + diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/before/foo/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/before/foo/test.kt new file mode 100644 index 00000000000..b5ea41daec0 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/before/foo/test.kt @@ -0,0 +1,22 @@ +package foo + +val valWithFunType = fun (): Unit {} +val valWithExtFunType = fun CrExtended.(): Unit {} +val Int.extValWithFunType get() = fun (): Unit {} +val Int.extValWithExtFunType get() = fun CrExtended.(): Unit {} + +class CrExtended + +fun test(ce: CrExtended) { + valWithFunType() + ce.valWithExtFunType() + with(1) { + extValWithFunType() + ce.extValWithExtFunType() + } + + ::valWithFunType + ::valWithExtFunType + 1::extValWithFunType + 1::extValWithExtFunType +} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/differentTarget.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/differentTarget.test new file mode 100644 index 00000000000..3e3d7eb8a06 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/differentTarget.test @@ -0,0 +1,5 @@ +{ + "mainFile": "foo/test.kt", + "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS", + "targetPackage": "bar" +} 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 0cc3a889fbb..ff5cad26f1c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java @@ -468,6 +468,24 @@ public class MoveTestGenerated extends AbstractMoveTest { doTest(fileName); } + @TestMetadata("kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/differentSource.test") + public void testKotlin_moveTopLevelDeclarations_implicitInvokeCalls_differentSource_DifferentSource() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSource/differentSource.test"); + doTest(fileName); + } + + @TestMetadata("kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/differentSourceAndTarget.test") + public void testKotlin_moveTopLevelDeclarations_implicitInvokeCalls_differentSourceAndTarget_DifferentSourceAndTarget() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentSourceAndTarget/differentSourceAndTarget.test"); + doTest(fileName); + } + + @TestMetadata("kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/differentTarget.test") + public void testKotlin_moveTopLevelDeclarations_implicitInvokeCalls_differentTarget_DifferentTarget() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/implicitInvokeCalls/differentTarget/differentTarget.test"); + doTest(fileName); + } + @TestMetadata("kotlin/moveTopLevelDeclarations/misc/companionExtensionMemberRef/companionExtensionMemberRef.test") public void testKotlin_moveTopLevelDeclarations_misc_companionExtensionMemberRef_CompanionExtensionMemberRef() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/companionExtensionMemberRef/companionExtensionMemberRef.test");