FIR: fix calculation of type arguments for bare types
This commit is contained in:
+17
-9
@@ -448,19 +448,27 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
|||||||
|
|
||||||
private fun FirTypeRef.withTypeArgumentsForBareType(argument: FirExpression): FirTypeRef {
|
private fun FirTypeRef.withTypeArgumentsForBareType(argument: FirExpression): FirTypeRef {
|
||||||
// TODO: Everything should also work for case of checked-type itself is a type alias
|
// TODO: Everything should also work for case of checked-type itself is a type alias
|
||||||
|
val type = coneTypeSafe<ConeKotlinType>()
|
||||||
|
if (type !is ConeClassLikeType || type.typeArguments.isNotEmpty()) {
|
||||||
|
return this
|
||||||
|
}
|
||||||
val baseTypeArguments =
|
val baseTypeArguments =
|
||||||
argument.typeRef.coneTypeSafe<ConeKotlinType>()?.fullyExpandedType(session)?.typeArguments
|
argument.typeRef.coneTypeSafe<ConeKotlinType>()?.fullyExpandedType(session)?.typeArguments
|
||||||
val type = coneTypeSafe<ConeKotlinType>()
|
|
||||||
return if (
|
return if (baseTypeArguments?.isEmpty() != false) {
|
||||||
type?.typeArguments?.isEmpty() != true ||
|
|
||||||
type is ConeTypeParameterType ||
|
|
||||||
baseTypeArguments?.isEmpty() != false ||
|
|
||||||
(type is ConeClassLikeType &&
|
|
||||||
(type.lookupTag.toSymbol(session)?.fir as? FirTypeParameterRefsOwner)?.typeParameters?.isEmpty() == true)
|
|
||||||
) {
|
|
||||||
this
|
this
|
||||||
} else {
|
} else {
|
||||||
withReplacedConeType(type.withArguments(baseTypeArguments))
|
val typeParameters = (type.lookupTag.toSymbol(session)?.fir as? FirTypeParameterRefsOwner)?.typeParameters.orEmpty()
|
||||||
|
if (typeParameters.isEmpty()) {
|
||||||
|
this
|
||||||
|
} else {
|
||||||
|
withReplacedConeType(
|
||||||
|
type.withArguments(
|
||||||
|
if (baseTypeArguments.size > typeParameters.size) baseTypeArguments.take(typeParameters.size).toTypedArray()
|
||||||
|
else baseTypeArguments
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,6 +3,6 @@
|
|||||||
// SKIP_TXT
|
// SKIP_TXT
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
suspend {} is SuspendFunction0<*>
|
suspend {} is <!UNRESOLVED_REFERENCE!>SuspendFunction0<*><!>
|
||||||
suspend {} is kotlin.coroutines.SuspendFunction0<*>
|
suspend {} is kotlin.coroutines.SuspendFunction0<*>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user