[NI] Remove captured type approximation in type arguments of resolved call
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
421fda6e92
commit
65380f4eb4
+1
-1
@@ -674,7 +674,7 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
||||
typeArguments = resolvedCallAtom.substitutor.freshVariables.map {
|
||||
val substituted = (substitutor ?: FreshVariableNewTypeSubstitutor.Empty).safeSubstitute(it.defaultType)
|
||||
TypeApproximator(substituted.constructor.builtIns)
|
||||
.approximateToSuperType(substituted, TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation)
|
||||
.approximateToSuperType(substituted, TypeApproximatorConfiguration.IntegerLiteralsTypesApproximation)
|
||||
?: substituted
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,13 @@ open class TypeApproximatorConfiguration {
|
||||
object CapturedAndIntegerLiteralsTypesApproximation : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FROM_EXPRESSION) {
|
||||
override val integerLiteralType: Boolean get() = true
|
||||
}
|
||||
object IntegerLiteralsTypesApproximation : TypeApproximatorConfiguration.AllFlexibleSameValue() {
|
||||
override val integerLiteralType: Boolean get() = true
|
||||
override val allFlexible: Boolean get() = true
|
||||
override val intersection get() = ALLOWED
|
||||
override val typeVariable: (TypeVariableTypeConstructor) -> Boolean get() = { true }
|
||||
override val capturedType: (NewCapturedType) -> Boolean get() = { true }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -5,5 +5,5 @@ class A<F>
|
||||
inline fun <reified T> foo(x: A<T>) {}
|
||||
|
||||
fun test(x: A<out CharSequence>) {
|
||||
<!OI;REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo<!>(x)
|
||||
<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo<!>(x)
|
||||
}
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CapturedType
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
|
||||
class InsertExplicitTypeArgumentsIntention :
|
||||
SelfTargetingRangeIntention<KtCallExpression>(KtCallExpression::class.java, "Add explicit type arguments"), LowPriorityAction {
|
||||
@@ -47,7 +48,7 @@ class InsertExplicitTypeArgumentsIntention :
|
||||
|
||||
val resolvedCall = element.getResolvedCall(bindingContext) ?: return false
|
||||
val typeArgs = resolvedCall.typeArguments
|
||||
return typeArgs.isNotEmpty() && typeArgs.values.none { ErrorUtils.containsErrorType(it) || it is CapturedType }
|
||||
return typeArgs.isNotEmpty() && typeArgs.values.none { ErrorUtils.containsErrorType(it) || it is CapturedType || it is NewCapturedType }
|
||||
}
|
||||
|
||||
fun applyTo(element: KtCallElement, shortenReferences: Boolean = true) {
|
||||
|
||||
Reference in New Issue
Block a user