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
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.backend.common.ir
|
||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.DumpIrTreeWithDescriptorsVisitor
|
||||
import org.jetbrains.kotlin.backend.common.deepCopyWithVariables
|
||||
import org.jetbrains.kotlin.backend.common.lower.VariableRemapper
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
@@ -369,7 +368,7 @@ fun IrClass.createImplicitParameterDeclarationWithWrappedDescriptor() {
|
||||
IrValueParameterSymbolImpl(thisReceiverDescriptor),
|
||||
Name.identifier("<this>"),
|
||||
index = -1,
|
||||
type = this.symbol.typeWith(this.typeParameters.map { it.defaultType }),
|
||||
type = symbol.typeWithParameters(typeParameters),
|
||||
varargElementType = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false
|
||||
@@ -407,7 +406,7 @@ fun IrClass.createParameterDeclarations() {
|
||||
IrValueParameterSymbolImpl(it),
|
||||
Name.special("<this>"),
|
||||
0,
|
||||
symbol.typeWith(typeParameters.map { it.defaultType }),
|
||||
symbol.typeWithParameters(typeParameters),
|
||||
null,
|
||||
false,
|
||||
false
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ internal class StepHandler(
|
||||
private val symbols = context.ir.symbols
|
||||
|
||||
override val matcher = SimpleCalleeMatcher {
|
||||
singleArgumentExtension(FqName("kotlin.ranges.step"), symbols.progressionClasses.map { it.typeWith() })
|
||||
singleArgumentExtension(FqName("kotlin.ranges.step"), symbols.progressionClasses.map { it.owner.defaultType })
|
||||
parameter(0) { it.type.isInt() || it.type.isLong() }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user