IR: Avoid "raw" IrTypes
The ir type checker cannot deal with types with an incorrect number of arguments. On the other hand, the JVM IR backend sometimes produces "raw types" - types with generic parameters but without arguments. This commit removes such raw types as much as possible, by replacing calls to "typeWith()" with calls to "defaultType" for classes without type parametes (defaultType doesn't allocate, unlike typeWith) and with calls to "starProjectedType" for classes with type parameters.
This commit is contained in:
committed by
Alexander Udalov
parent
4d67803f04
commit
2db8471dd7
@@ -104,6 +104,17 @@ val IrTypeParameter.defaultType: IrType
|
||||
annotations = emptyList()
|
||||
)
|
||||
|
||||
val IrClassSymbol.starProjectedType: IrSimpleType
|
||||
get() = IrSimpleTypeImpl(
|
||||
this,
|
||||
hasQuestionMark = false,
|
||||
arguments = owner.typeParameters.map { IrStarProjectionImpl },
|
||||
annotations = emptyList()
|
||||
)
|
||||
|
||||
fun IrClassifierSymbol.typeWithParameters(parameters: List<IrTypeParameter>): IrSimpleType =
|
||||
typeWith(parameters.map { it.defaultType })
|
||||
|
||||
fun IrClassifierSymbol.typeWith(vararg arguments: IrType): IrSimpleType = typeWith(arguments.toList())
|
||||
|
||||
fun IrClassifierSymbol.typeWith(arguments: List<IrType>): IrSimpleType =
|
||||
|
||||
Reference in New Issue
Block a user