diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.kt index b19dc1e16d5..ac1aa4fc898 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.kt @@ -55,18 +55,6 @@ class SmartCastManager { return result } - fun getSmartCastVariantsWithLessSpecificExcluded( - receiverToCast: ReceiverValue, - bindingContext: BindingContext, - containingDeclarationOrModule: DeclarationDescriptor, - dataFlowInfo: DataFlowInfo - ): List { - val variants = getSmartCastVariants(receiverToCast, bindingContext, containingDeclarationOrModule, dataFlowInfo).distinct() - return variants.filter { type -> - variants.none { another -> another !== type && KotlinTypeChecker.DEFAULT.isSubtypeOf(another, type) } - } - } - /** * @return variants @param receiverToCast may be cast to according to context dataFlowInfo, receiverToCast itself is NOT included */ diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt index 8d68b1f0c30..0ebd9af7caa 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt @@ -16,8 +16,15 @@ package org.jetbrains.kotlin.idea.util +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo +import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager +import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.checker.KotlinTypeChecker fun KtFunctionLiteral.findLabelAndCall(): Pair { val literalParent = (this.parent as KtLambdaExpression).parent @@ -44,3 +51,15 @@ fun KtFunctionLiteral.findLabelAndCall(): Pair { } } } + +fun SmartCastManager.getSmartCastVariantsWithLessSpecificExcluded( + receiverToCast: ReceiverValue, + bindingContext: BindingContext, + containingDeclarationOrModule: DeclarationDescriptor, + dataFlowInfo: DataFlowInfo +): List { + val variants = getSmartCastVariants(receiverToCast, bindingContext, containingDeclarationOrModule, dataFlowInfo).distinct() + return variants.filter { type -> + variants.none { another -> another !== type && KotlinTypeChecker.DEFAULT.isSubtypeOf(another, type) } + } +} diff --git a/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.dependency.java b/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.dependency.java new file mode 100644 index 00000000000..451cab29fb2 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.dependency.java @@ -0,0 +1,11 @@ +class X { + void f(){} +} + +class JavaClass { + public void setFoo(X value) { + } + public X getFoo() { + return new X(); + } +} diff --git a/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.java b/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.java deleted file mode 100644 index b694859ec3d..00000000000 --- a/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.java +++ /dev/null @@ -1,7 +0,0 @@ -class JavaClass { - public void setFoo(String value) { - } - public String getFoo() { - return ""; - } -} diff --git a/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.kt b/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.kt index 8fea6b37818..30736d13ccd 100644 --- a/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.kt +++ b/idea/idea-completion/testData/basic/multifile/KT12124/KT12124.kt @@ -1,7 +1,8 @@ +inline fun T.apply(block: T.() -> Unit): T { block(); return this } + val v = JavaClass().apply { - foo = "" + foo = X() foo. } -// EXIST: length -// EXIST: substring +// EXIST: f