[FIR] Completely unwrap original argument when computing type arguments

When computing the conversion type for a type operator call, the
argument needs to be fully unwrapped before getting the resolved type.
This avoids the situation when the argument is a when-subject and the
assumed original type is not correct. Before, only smart-casts were
unwrapped, and this change will also unwrap when-subjects (as well as a
few other FirExpressions).

^KT-62114 Fixed
This commit is contained in:
Brian Norman
2023-10-04 16:48:49 -05:00
committed by Space Team
parent 23bdfd226f
commit 2e6dbbe020
5 changed files with 88 additions and 1 deletions
@@ -839,7 +839,7 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
val firClass = type.lookupTag.toSymbol(session)?.fir ?: return this
if (firClass.typeParameters.isEmpty()) return this
val originalType = argument.unwrapSmartcastExpression().resolvedType
val originalType = argument.unwrapExpression().resolvedType
val newType = components.computeRepresentativeTypeForBareType(type, originalType)
?: if (firClass.isLocal && (operation == FirOperation.AS || operation == FirOperation.SAFE_AS)) {
(firClass as FirClass).defaultType()