[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|>()
|
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 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<it(kotlin/Comparable<*> & java/io/Serializable)>|
|
public get(): R|kotlin/collections/List<kotlin/Any>|
|
||||||
|
|
||||||
public final val data: R|First| = R|/First.First|(Int(42))
|
public final val data: R|First| = R|/First.First|(Int(42))
|
||||||
public get(): R|First|
|
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(
|
private fun FirTypeRef.approximateTypeIfNeeded(
|
||||||
containingCallableVisibility: Visibility?,
|
containingCallableVisibility: Visibility?,
|
||||||
isInlineFunction: Boolean = false
|
isInlineFunction: Boolean = false
|
||||||
@@ -975,20 +988,14 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
val approximatedType = if (this is FirResolvedTypeRef &&
|
val approximatedType = if (this is FirResolvedTypeRef &&
|
||||||
(containingCallableVisibility == Public || containingCallableVisibility == Protected)
|
(containingCallableVisibility == Public || containingCallableVisibility == Protected)
|
||||||
) {
|
) {
|
||||||
when (this.type) {
|
if (type.requiresApproximationInPublicPosition()) {
|
||||||
is ConeIntegerLiteralType,
|
this.withReplacedConeType(
|
||||||
is ConeCapturedType,
|
inferenceComponents.approximator.approximateToSuperType(
|
||||||
is ConeDefinitelyNotNullType,
|
this.type, TypeApproximatorConfiguration.PublicDeclaration
|
||||||
is ConeIntersectionType -> {
|
) as? ConeKotlinType
|
||||||
this.withReplacedConeType(
|
)
|
||||||
inferenceComponents.approximator.approximateToSuperType(
|
} else {
|
||||||
this.type, TypeApproximatorConfiguration.PublicDeclaration
|
this
|
||||||
) as ConeKotlinType
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
this
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this
|
this
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
interface In<in E>
|
interface In<in E>
|
||||||
class A : In<A>
|
class A : In<A>
|
||||||
class B : In<B>
|
class B : In<B>
|
||||||
|
|||||||
+1
-1
@@ -20,5 +20,5 @@ fun <S> test(i: Int, s: S) {
|
|||||||
|
|
||||||
c
|
c
|
||||||
|
|
||||||
takeInvInt(create(i))
|
<!INAPPLICABLE_CANDIDATE!>takeInvInt<!>(create(i))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user