[JS IR BE] Get rid of usages of KotlinType
This commit is contained in:
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.Scope
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
|
||||
@@ -289,3 +290,30 @@ fun IrClass.simpleFunctions(): List<IrSimpleFunction> = this.declarations.flatMa
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
fun Scope.createTmpVariable(
|
||||
irExpression: IrExpression,
|
||||
nameHint: String? = null,
|
||||
isMutable: Boolean = false,
|
||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE,
|
||||
irType: IrType? = null
|
||||
): IrVariable {
|
||||
val varType = irType ?: irExpression.type
|
||||
val descriptor = WrappedVariableDescriptor()
|
||||
val symbol = IrVariableSymbolImpl(descriptor)
|
||||
return IrVariableImpl(
|
||||
irExpression.startOffset,
|
||||
irExpression.endOffset,
|
||||
origin,
|
||||
symbol,
|
||||
Name.identifier(nameHint ?: "tmp"),
|
||||
varType,
|
||||
isMutable,
|
||||
false,
|
||||
false
|
||||
).apply {
|
||||
initializer = irExpression
|
||||
parent = getLocalDeclarationParent()
|
||||
descriptor.bind(this)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -62,7 +62,7 @@ class AutoboxingTransformer(val context: JsIrBackendContext) : AbstractValueUsag
|
||||
}
|
||||
|
||||
// // TODO: Default parameters are passed as nulls and they need not to be unboxed. Fix this
|
||||
if (actualType.makeNotNull().isNothing())
|
||||
if (actualType.makeNotNull(false).isNothing())
|
||||
return this
|
||||
|
||||
val expectedType = type
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.createTmpVariable
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
@@ -286,10 +287,10 @@ class EnumClassTransformer(val context: JsIrBackendContext, private val irClass:
|
||||
}
|
||||
|
||||
private fun createEnumEntryInstanceVariables() = enumEntries.map { enumEntry ->
|
||||
val type = enumEntry.getType(irClass).makeNullable()
|
||||
val type = enumEntry.getType(irClass).makeNullable(false)
|
||||
val name = "${enumName}_${enumEntry.name.identifier}_instance"
|
||||
builder.run {
|
||||
scope.createTemporaryVariable(irImplicitCast(irNull(), type), name)
|
||||
scope.createTmpVariable(irImplicitCast(irNull(), type), name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.isNullable
|
||||
|
||||
|
||||
class EqualityAndComparisonCallsTransformer(context: JsIrBackendContext) : CallsTransformer {
|
||||
@@ -93,7 +92,7 @@ class EqualityAndComparisonCallsTransformer(context: JsIrBackendContext) : Calls
|
||||
isLhsPrimitive && lhsJsType == rhsJsType && lhsJsType != PrimitiveType.FLOATING_POINT_NUMBER ->
|
||||
chooseEqualityOperatorForPrimitiveTypes(call)
|
||||
|
||||
!isLhsPrimitive && !lhs.type.toKotlinType().isNullable() && equalsMethod != null ->
|
||||
!isLhsPrimitive && !lhs.type.isNullable() && equalsMethod != null ->
|
||||
irCall(call, equalsMethod.symbol, firstArgumentAsDispatchReceiver = true)
|
||||
|
||||
else ->
|
||||
|
||||
Reference in New Issue
Block a user