FIR: use FROM_EXPRESSION, not FOR_SUBTYPING capt. types in substitution
This commit is contained in:
@@ -67,7 +67,7 @@ fun createSubstitution(
|
|||||||
type: ConeClassLikeType,
|
type: ConeClassLikeType,
|
||||||
session: FirSession
|
session: FirSession
|
||||||
): Map<FirTypeParameterSymbol, ConeKotlinType> {
|
): Map<FirTypeParameterSymbol, ConeKotlinType> {
|
||||||
val capturedOrType = session.typeContext.captureFromArguments(type, CaptureStatus.FOR_SUBTYPING) ?: type
|
val capturedOrType = session.typeContext.captureFromArguments(type, CaptureStatus.FROM_EXPRESSION) ?: type
|
||||||
val typeArguments = (capturedOrType as ConeClassLikeType).typeArguments
|
val typeArguments = (capturedOrType as ConeClassLikeType).typeArguments
|
||||||
return typeParameters.zip(typeArguments) { typeParameter, typeArgument ->
|
return typeParameters.zip(typeArguments) { typeParameter, typeArgument ->
|
||||||
val typeParameterSymbol = typeParameter.symbol
|
val typeParameterSymbol = typeParameter.symbol
|
||||||
|
|||||||
+1
-1
@@ -151,7 +151,7 @@ data class ConeSubstitutorByMap(val substitution: Map<FirTypeParameterSymbol, Co
|
|||||||
val session = type.lookupTag.symbol.fir.session
|
val session = type.lookupTag.symbol.fir.session
|
||||||
if (type.isUnsafeVarianceType(session)) {
|
if (type.isUnsafeVarianceType(session)) {
|
||||||
return session.inferenceComponents.approximator.approximateToSuperType(
|
return session.inferenceComponents.approximator.approximateToSuperType(
|
||||||
result, TypeApproximatorConfiguration.SubtypeCapturedTypesApproximation
|
result, TypeApproximatorConfiguration.FinalApproximationAfterResolutionAndInference
|
||||||
) as? ConeKotlinType ?: result
|
) as? ConeKotlinType ?: result
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
+2
-2
@@ -132,13 +132,13 @@ class FirClassSubstitutionScope(
|
|||||||
|
|
||||||
private fun ConeKotlinType.approximateCapturedCovariant(): ConeKotlinType {
|
private fun ConeKotlinType.approximateCapturedCovariant(): ConeKotlinType {
|
||||||
return session.inferenceComponents.approximator.approximateToSuperType(
|
return session.inferenceComponents.approximator.approximateToSuperType(
|
||||||
this, TypeApproximatorConfiguration.SubtypeCapturedTypesApproximation
|
this, TypeApproximatorConfiguration.FinalApproximationAfterResolutionAndInference
|
||||||
) as? ConeKotlinType ?: this
|
) as? ConeKotlinType ?: this
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinType.approximateCapturedContravariant(): ConeKotlinType {
|
private fun ConeKotlinType.approximateCapturedContravariant(): ConeKotlinType {
|
||||||
return session.inferenceComponents.approximator.approximateToSubType(
|
return session.inferenceComponents.approximator.approximateToSubType(
|
||||||
this, TypeApproximatorConfiguration.SubtypeCapturedTypesApproximation
|
this, TypeApproximatorConfiguration.FinalApproximationAfterResolutionAndInference
|
||||||
) as? ConeKotlinType ?: this
|
) as? ConeKotlinType ?: this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@ fun foo2(a: A<out CharSequence>, b: A<in CharSequence>) {
|
|||||||
a.foo1(Out())
|
a.foo1(Out())
|
||||||
a.foo1(Out<Nothing>())
|
a.foo1(Out<Nothing>())
|
||||||
|
|
||||||
a.<!INAPPLICABLE_CANDIDATE!>foo2<!>(Inv())
|
a.foo2(Inv())
|
||||||
a.<!INAPPLICABLE_CANDIDATE!>foo2<!>(Inv<CharSequence>())
|
a.<!INAPPLICABLE_CANDIDATE!>foo2<!>(Inv<CharSequence>())
|
||||||
a.<!INAPPLICABLE_CANDIDATE!>foo2<!><Inv<CharSequence>>(Inv())
|
a.<!INAPPLICABLE_CANDIDATE!>foo2<!><Inv<CharSequence>>(Inv())
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ fun foo2(a: A<out CharSequence>, b: A<in CharSequence>) {
|
|||||||
b.foo1(Out<CharSequence>())
|
b.foo1(Out<CharSequence>())
|
||||||
b.foo1<Out<CharSequence>>(Out())
|
b.foo1<Out<CharSequence>>(Out())
|
||||||
|
|
||||||
b.<!INAPPLICABLE_CANDIDATE!>foo2<!>(Inv())
|
b.foo2(Inv())
|
||||||
b.<!INAPPLICABLE_CANDIDATE!>foo2<!>(Inv<CharSequence>())
|
b.<!INAPPLICABLE_CANDIDATE!>foo2<!>(Inv<CharSequence>())
|
||||||
b.<!INAPPLICABLE_CANDIDATE!>foo2<!><Inv<CharSequence>>(Inv())
|
b.<!INAPPLICABLE_CANDIDATE!>foo2<!><Inv<CharSequence>>(Inv())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user