[IR] Transfer type annotations when substituting via IR substitutor
Other type substitutors (classic, cone-based) respect the type annotations and copy them to the resulting type for all cases, including type parameters. Without this change we cannot correctly match expect/actuals when we replace actual type parameters with expect ones in case the actual type parameter has type enhancement annotations (e.g., `@FlexibleNullability`). We transfer all annotations (and not conservatively copy only type enhancement annotations), as 1) other substitutors do that 2) other IR type substitution utilities (e.g., `IrType.substitute`) do that. As we will attempt reimplementing all IR type substitution utilities via IrTypeSubstitutor, it also makes sense to completely align the behavior.
This commit is contained in:
@@ -38,6 +38,7 @@ abstract class BaseIrTypeSubstitutor(private val irBuiltIns: IrBuiltIns) : Abstr
|
||||
when (val typeArgument = getSubstitutionArgument(it)) {
|
||||
is IrStarProjection -> irBuiltIns.anyNType // TODO upper bound for T
|
||||
is IrTypeProjection -> typeArgument.type.mergeNullability(irType)
|
||||
.addAnnotations(irType.annotations)
|
||||
}
|
||||
}
|
||||
if (substitutedTypeParameter != null) {
|
||||
|
||||
Reference in New Issue
Block a user