[FIR] Fix non-serializable type argument at the end of resolve
This commit is contained in:
+2
-2
@@ -13,8 +13,8 @@ FILE: withInInitializer.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val list: R|kotlin/collections/List<it(kotlin/Comparable<*> & java/io/Serializable)>| = R|kotlin/collections/listOf|<R|it(kotlin/Comparable<*> & java/io/Serializable)|>(vararg(Int(1), Int(2), Int(3), String()))
|
||||
public get(): R|kotlin/collections/List<it(kotlin/Comparable<*> & java/io/Serializable)>|
|
||||
public final val list: R|kotlin/collections/List<kotlin/Any>| = R|kotlin/collections/listOf|<R|it(kotlin/Comparable<*> & java/io/Serializable)|>(vararg(Int(1), Int(2), Int(3), String()))
|
||||
public get(): R|kotlin/collections/List<kotlin/Any>|
|
||||
|
||||
public final val data: R|First| = R|/First.First|(Int(42))
|
||||
public get(): R|First|
|
||||
|
||||
+21
-14
@@ -968,6 +968,19 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
}
|
||||
}
|
||||
|
||||
private fun ConeKotlinType.requiresApproximationInPublicPosition(): Boolean {
|
||||
return when (this) {
|
||||
is ConeIntegerLiteralType,
|
||||
is ConeCapturedType,
|
||||
is ConeDefinitelyNotNullType,
|
||||
is ConeIntersectionType -> true
|
||||
is ConeClassLikeType -> typeArguments.any {
|
||||
it is ConeKotlinTypeProjection && it.type.requiresApproximationInPublicPosition()
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirTypeRef.approximateTypeIfNeeded(
|
||||
containingCallableVisibility: Visibility?,
|
||||
isInlineFunction: Boolean = false
|
||||
@@ -975,20 +988,14 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
val approximatedType = if (this is FirResolvedTypeRef &&
|
||||
(containingCallableVisibility == Public || containingCallableVisibility == Protected)
|
||||
) {
|
||||
when (this.type) {
|
||||
is ConeIntegerLiteralType,
|
||||
is ConeCapturedType,
|
||||
is ConeDefinitelyNotNullType,
|
||||
is ConeIntersectionType -> {
|
||||
this.withReplacedConeType(
|
||||
inferenceComponents.approximator.approximateToSuperType(
|
||||
this.type, TypeApproximatorConfiguration.PublicDeclaration
|
||||
) as ConeKotlinType
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
this
|
||||
}
|
||||
if (type.requiresApproximationInPublicPosition()) {
|
||||
this.withReplacedConeType(
|
||||
inferenceComponents.approximator.approximateToSuperType(
|
||||
this.type, TypeApproximatorConfiguration.PublicDeclaration
|
||||
) as? ConeKotlinType
|
||||
)
|
||||
} else {
|
||||
this
|
||||
}
|
||||
} else {
|
||||
this
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
interface In<in E>
|
||||
class A : In<A>
|
||||
class B : In<B>
|
||||
|
||||
+1
-1
@@ -20,5 +20,5 @@ fun <S> test(i: Int, s: S) {
|
||||
|
||||
c
|
||||
|
||||
takeInvInt(create(i))
|
||||
<!INAPPLICABLE_CANDIDATE!>takeInvInt<!>(create(i))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user