Moved method getSmartCastVariantsWithLessSpecificExcluded() into IDE
This commit is contained in:
-12
@@ -55,18 +55,6 @@ class SmartCastManager {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSmartCastVariantsWithLessSpecificExcluded(
|
|
||||||
receiverToCast: ReceiverValue,
|
|
||||||
bindingContext: BindingContext,
|
|
||||||
containingDeclarationOrModule: DeclarationDescriptor,
|
|
||||||
dataFlowInfo: DataFlowInfo
|
|
||||||
): List<KotlinType> {
|
|
||||||
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
|
* @return variants @param receiverToCast may be cast to according to context dataFlowInfo, receiverToCast itself is NOT included
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,8 +16,15 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.util
|
package org.jetbrains.kotlin.idea.util
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.*
|
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<Name?, KtCallExpression?> {
|
fun KtFunctionLiteral.findLabelAndCall(): Pair<Name?, KtCallExpression?> {
|
||||||
val literalParent = (this.parent as KtLambdaExpression).parent
|
val literalParent = (this.parent as KtLambdaExpression).parent
|
||||||
@@ -44,3 +51,15 @@ fun KtFunctionLiteral.findLabelAndCall(): Pair<Name?, KtCallExpression?> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun SmartCastManager.getSmartCastVariantsWithLessSpecificExcluded(
|
||||||
|
receiverToCast: ReceiverValue,
|
||||||
|
bindingContext: BindingContext,
|
||||||
|
containingDeclarationOrModule: DeclarationDescriptor,
|
||||||
|
dataFlowInfo: DataFlowInfo
|
||||||
|
): List<KotlinType> {
|
||||||
|
val variants = getSmartCastVariants(receiverToCast, bindingContext, containingDeclarationOrModule, dataFlowInfo).distinct()
|
||||||
|
return variants.filter { type ->
|
||||||
|
variants.none { another -> another !== type && KotlinTypeChecker.DEFAULT.isSubtypeOf(another, type) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
class X {
|
||||||
|
void f(){}
|
||||||
|
}
|
||||||
|
|
||||||
|
class JavaClass {
|
||||||
|
public void setFoo(X value) {
|
||||||
|
}
|
||||||
|
public X getFoo() {
|
||||||
|
return new X();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
class JavaClass {
|
|
||||||
public void setFoo(String value) {
|
|
||||||
}
|
|
||||||
public String getFoo() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
|
inline fun <T> T.apply(block: T.() -> Unit): T { block(); return this }
|
||||||
|
|
||||||
val v = JavaClass().apply {
|
val v = JavaClass().apply {
|
||||||
foo = ""
|
foo = X()
|
||||||
foo.<caret>
|
foo.<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXIST: length
|
// EXIST: f
|
||||||
// EXIST: substring
|
|
||||||
|
|||||||
Reference in New Issue
Block a user