[K/N] Get rid of work with lagacy descriptor-based types
This commit is contained in:
+2
-2
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.konan
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.ir.isTopLevel
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.findPackage
|
||||
import org.jetbrains.kotlin.backend.konan.ir.containsNull
|
||||
import org.jetbrains.kotlin.backend.konan.ir.getSuperClassNotAny
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
@@ -18,6 +17,7 @@ import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||
import org.jetbrains.kotlin.ir.types.isNullable
|
||||
import org.jetbrains.kotlin.ir.types.makeNullable
|
||||
import org.jetbrains.kotlin.ir.util.constructors
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
@@ -271,7 +271,7 @@ internal object KotlinTypeInlineClassesSupport : InlineClassesSupport<ClassDescr
|
||||
|
||||
internal object IrTypeInlineClassesSupport : InlineClassesSupport<IrClass, IrType>() {
|
||||
|
||||
override fun isNullable(type: IrType): Boolean = type.containsNull()
|
||||
override fun isNullable(type: IrType): Boolean = type.isNullable()
|
||||
|
||||
override fun makeNullable(type: IrType): IrType = type.makeNullable()
|
||||
|
||||
|
||||
+6
-6
@@ -126,7 +126,7 @@ internal fun KotlinStubs.generateCCall(expression: IrCall, builder: IrBuilderWit
|
||||
require(expression.dispatchReceiver == null) { renderCompilerError(expression) }
|
||||
targetPtrParameter = callBuilder.passThroughBridge(
|
||||
expression.extensionReceiver!!,
|
||||
symbols.interopCPointer.typeWithStarProjections,
|
||||
symbols.interopCPointer.starProjectedType,
|
||||
CTypes.voidPtr
|
||||
).name
|
||||
targetFunctionName = "targetPtr"
|
||||
@@ -336,7 +336,7 @@ internal fun KotlinStubs.generateObjCCall(
|
||||
|
||||
val targetPtrParameter = callBuilder.passThroughBridge(
|
||||
messenger,
|
||||
symbols.interopCPointer.typeWithStarProjections,
|
||||
symbols.interopCPointer.starProjectedType,
|
||||
CTypes.voidPtr
|
||||
).name
|
||||
val targetFunctionName = "targetPtr"
|
||||
@@ -402,7 +402,7 @@ internal fun KotlinStubs.generateObjCCall(
|
||||
internal fun IrBuilderWithScope.getObjCClass(symbols: KonanSymbols, symbol: IrClassSymbol): IrExpression {
|
||||
val classDescriptor = symbol.descriptor
|
||||
require(!classDescriptor.isObjCMetaClass())
|
||||
return irCall(symbols.interopGetObjCClass, symbols.nativePtrType, listOf(symbol.typeWithStarProjections))
|
||||
return irCall(symbols.interopGetObjCClass, symbols.nativePtrType, listOf(symbol.starProjectedType))
|
||||
}
|
||||
|
||||
private fun IrBuilderWithScope.irNullNativePtr(symbols: KonanSymbols) = irCall(symbols.getNativeNullPtr.owner)
|
||||
@@ -708,7 +708,7 @@ private fun KotlinStubs.mapType(
|
||||
type.isFloat() -> TrivialValuePassing(irBuiltIns.floatType, CTypes.float)
|
||||
type.isDouble() -> TrivialValuePassing(irBuiltIns.doubleType, CTypes.double)
|
||||
type.isCPointer(symbols) -> TrivialValuePassing(type, CTypes.voidPtr)
|
||||
type.isTypeOfNullLiteral() && variadic -> TrivialValuePassing(symbols.interopCPointer.typeWithStarProjections.makeNullable(), CTypes.voidPtr)
|
||||
type.isTypeOfNullLiteral() && variadic -> TrivialValuePassing(symbols.interopCPointer.starProjectedType.makeNullable(), CTypes.voidPtr)
|
||||
type.isUByte() -> TrivialValuePassing(type, CTypes.unsignedChar)
|
||||
type.isUShort() -> TrivialValuePassing(type, CTypes.unsignedShort)
|
||||
type.isUInt() -> TrivialValuePassing(type, CTypes.unsignedInt)
|
||||
@@ -867,7 +867,7 @@ private class StructValuePassing(private val kotlinClass: IrClass, override val
|
||||
override fun KotlinToCCallBuilder.passValue(expression: IrExpression): CExpression {
|
||||
val cBridgeValue = passThroughBridge(
|
||||
cValuesRefToPointer(expression),
|
||||
symbols.interopCPointer.typeWithStarProjections,
|
||||
symbols.interopCPointer.starProjectedType,
|
||||
CTypes.pointer(cType)
|
||||
).name
|
||||
|
||||
@@ -1314,7 +1314,7 @@ private object CValuesRefArgumentPassing : KotlinToCArgumentPassing {
|
||||
val bridgeArgument = cValuesRefToPointer(expression)
|
||||
val cBridgeValue = passThroughBridge(
|
||||
bridgeArgument,
|
||||
symbols.interopCPointer.typeWithStarProjections.makeNullable(),
|
||||
symbols.interopCPointer.starProjectedType.makeNullable(),
|
||||
CTypes.voidPtr
|
||||
)
|
||||
return CExpression(cBridgeValue.name, cBridgeValue.type)
|
||||
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.ir
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
|
||||
val IrClassifierSymbol.typeWithoutArguments: IrType
|
||||
get() = when (this) {
|
||||
is IrClassSymbol -> {
|
||||
require(this.descriptor.declaredTypeParameters.isEmpty())
|
||||
this.typeWith(arguments = emptyList())
|
||||
}
|
||||
is IrTypeParameterSymbol -> this.defaultType
|
||||
else -> error(this)
|
||||
}
|
||||
|
||||
val IrClassifierSymbol.typeWithStarProjections
|
||||
get() = when (this) {
|
||||
is IrClassSymbol -> createType(
|
||||
hasQuestionMark = false,
|
||||
arguments = this.descriptor.declaredTypeParameters.map { IrStarProjectionImpl }
|
||||
)
|
||||
is IrTypeParameterSymbol -> this.defaultType
|
||||
else -> error(this)
|
||||
}
|
||||
|
||||
val IrTypeParameterSymbol.defaultType: IrType get() = IrSimpleTypeImpl(
|
||||
this,
|
||||
false,
|
||||
emptyList(),
|
||||
emptyList()
|
||||
)
|
||||
|
||||
fun IrClass.typeWith(arguments: List<IrType>) = this.symbol.typeWith(arguments)
|
||||
|
||||
fun IrType.containsNull(): Boolean = if (this is IrSimpleType) {
|
||||
if (this.hasQuestionMark) {
|
||||
true
|
||||
} else {
|
||||
val classifier = this.classifier
|
||||
when (classifier) {
|
||||
is IrClassSymbol -> false
|
||||
is IrTypeParameterSymbol -> classifier.owner.superTypes.any { it.containsNull() }
|
||||
else -> error(classifier)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
||||
// TODO: get rid of these:
|
||||
fun IrType.isSubtypeOf(other: KotlinType): Boolean = this.toKotlinType().isSubtypeOf(other)
|
||||
fun IrType.isSubtypeOf(other: IrType): Boolean = this.isSubtypeOf(other.toKotlinType())
|
||||
+1
-3
@@ -24,9 +24,7 @@ import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IdSignatureValues
|
||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||
import org.jetbrains.kotlin.ir.types.isMarkedNullable
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
+1
-1
@@ -1565,7 +1565,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
functionGenerationContext.condBr(condition, bbNull, bbInstanceOf)
|
||||
|
||||
functionGenerationContext.positionAtEnd(bbNull)
|
||||
val resultNull = if (type.containsNull()) kTrue else kFalse
|
||||
val resultNull = if (type.isNullable()) kTrue else kFalse
|
||||
functionGenerationContext.br(bbExit)
|
||||
|
||||
functionGenerationContext.positionAtEnd(bbInstanceOf)
|
||||
|
||||
+3
-2
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrPropertySymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.transformStatement
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.isNullable
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -328,7 +329,7 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT
|
||||
|
||||
function.body = builder.irBlockBody(function) {
|
||||
val valueToBox = function.valueParameters[0]
|
||||
if (valueToBox.type.containsNull()) {
|
||||
if (valueToBox.type.isNullable()) {
|
||||
+irIfThen(
|
||||
condition = irIsNull(irGet(valueToBox)),
|
||||
thenPart = irReturn(irNull())
|
||||
@@ -371,7 +372,7 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT
|
||||
|
||||
function.body = builder.irBlockBody(function) {
|
||||
val boxParameter = function.valueParameters.single()
|
||||
if (boxParameter.type.containsNull()) {
|
||||
if (boxParameter.type.isNullable()) {
|
||||
+irIfThen(
|
||||
condition = irEqeqeq(irGet(boxParameter), irNull()),
|
||||
thenPart = irReturn(irNullPointerOrReference(function.returnType))
|
||||
|
||||
+5
-9
@@ -12,8 +12,6 @@ import org.jetbrains.kotlin.backend.common.lower.IrBuildingTransformer
|
||||
import org.jetbrains.kotlin.backend.common.lower.at
|
||||
import org.jetbrains.kotlin.backend.common.lower.irNot
|
||||
import org.jetbrains.kotlin.backend.konan.*
|
||||
import org.jetbrains.kotlin.backend.konan.ir.containsNull
|
||||
import org.jetbrains.kotlin.backend.konan.ir.isSubtypeOf
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltinOperatorDescriptor
|
||||
@@ -22,13 +20,11 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.makeNullable
|
||||
import org.jetbrains.kotlin.ir.builders.irGet
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.isNothing
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.util.defaultOrNullableType
|
||||
import org.jetbrains.kotlin.ir.util.isNullConst
|
||||
@@ -208,8 +204,8 @@ internal class BuiltinOperatorLowering(val context: Context) : FileLoweringPass,
|
||||
putValueArgument(0, rhs)
|
||||
}
|
||||
|
||||
val lhsIsNotNullable = !lhs.type.containsNull()
|
||||
val rhsIsNotNullable = !rhs.type.containsNull()
|
||||
val lhsIsNotNullable = !lhs.type.isNullable()
|
||||
val rhsIsNotNullable = !rhs.type.isNullable()
|
||||
|
||||
return if (symbol in ieee754EqualsSymbols()) {
|
||||
if (lhsIsNotNullable && rhsIsNotNullable)
|
||||
@@ -256,7 +252,7 @@ internal class BuiltinOperatorLowering(val context: Context) : FileLoweringPass,
|
||||
from.atMostOne {
|
||||
val leftParamType = it.owner.valueParameters[0].type
|
||||
val rightParamType = it.owner.valueParameters[1].type
|
||||
(lhsType.isSubtypeOf(leftParamType) || (allowNullable && lhsType.isSubtypeOf(leftParamType.makeNullable())))
|
||||
&& (rhsType.isSubtypeOf(rightParamType) || (allowNullable && rhsType.isSubtypeOf(rightParamType.makeNullable())))
|
||||
(lhsType.isSubtypeOf(leftParamType, context.typeSystem) || (allowNullable && lhsType.isSubtypeOf(leftParamType.makeNullable(), context.typeSystem)))
|
||||
&& (rhsType.isSubtypeOf(rightParamType, context.typeSystem) || (allowNullable && rhsType.isSubtypeOf(rightParamType.makeNullable(), context.typeSystem)))
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -391,7 +391,7 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
|
||||
}
|
||||
|
||||
private fun IrBuilderWithScope.interpretObjCPointer(expression: IrExpression, type: IrType): IrExpression {
|
||||
val callee: IrFunctionSymbol = if (type.containsNull()) {
|
||||
val callee: IrFunctionSymbol = if (type.isNullable()) {
|
||||
symbols.interopInterpretObjCPointerOrNull
|
||||
} else {
|
||||
symbols.interopInterpretObjCPointer
|
||||
@@ -572,7 +572,7 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor
|
||||
}
|
||||
|
||||
private fun IrBuilderWithScope.ensureObjCReferenceNotNull(expression: IrExpression): IrExpression =
|
||||
if (!expression.type.containsNull()) {
|
||||
if (!expression.type.isNullable()) {
|
||||
expression
|
||||
} else {
|
||||
irBlock(resultType = expression.type) {
|
||||
@@ -1095,10 +1095,10 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
|
||||
}
|
||||
|
||||
val receiverClass = symbols.integerClasses.single {
|
||||
receiver.type.isSubtypeOf(it.owner.defaultType)
|
||||
receiver.type.isSubtypeOf(it.owner.defaultType, context.typeSystem)
|
||||
}
|
||||
val targetClass = symbols.integerClasses.single {
|
||||
typeOperand.isSubtypeOf(it.owner.defaultType)
|
||||
typeOperand.isSubtypeOf(it.owner.defaultType, context.typeSystem)
|
||||
}
|
||||
|
||||
val conversionSymbol = receiverClass.functions.single {
|
||||
|
||||
+1
-2
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.konan.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.KonanBackendContext
|
||||
import org.jetbrains.kotlin.backend.konan.ir.getSuperClassNotAny
|
||||
import org.jetbrains.kotlin.backend.konan.ir.typeWithStarProjections
|
||||
import org.jetbrains.kotlin.backend.konan.isObjCClass
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.computeFullName
|
||||
import org.jetbrains.kotlin.backend.konan.reportCompilationError
|
||||
@@ -189,7 +188,7 @@ internal fun IrBuilderWithScope.irKClass(context: KonanBackendContext, symbol: I
|
||||
symbol.owner.isNativePointedChild() ->
|
||||
irKClassUnsupported(context, "KClass for interop types is not supported yet")
|
||||
|
||||
else -> irConstantObject(symbols.kClassImplIntrinsicConstructor, emptyList(), listOf(symbol.typeWithStarProjections))
|
||||
else -> irConstantObject(symbols.kClassImplIntrinsicConstructor, emptyList(), listOf(symbol.starProjectedType))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -5,18 +5,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.ir.addFakeOverrides
|
||||
import org.jetbrains.kotlin.backend.common.ir.createDispatchReceiverParameter
|
||||
import org.jetbrains.kotlin.backend.common.ir.createParameterDeclarations
|
||||
import org.jetbrains.kotlin.backend.common.ir.simpleFunctions
|
||||
import org.jetbrains.kotlin.backend.common.ir.*
|
||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||
import org.jetbrains.kotlin.backend.common.reportWarning
|
||||
import org.jetbrains.kotlin.backend.konan.Context
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isAbstract
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
|
||||
import org.jetbrains.kotlin.backend.konan.getIncludedLibraryDescriptors
|
||||
import org.jetbrains.kotlin.backend.konan.ir.typeWithStarProjections
|
||||
import org.jetbrains.kotlin.backend.konan.ir.typeWithoutArguments
|
||||
import org.jetbrains.kotlin.backend.konan.reportCompilationError
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
@@ -40,6 +35,8 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.util.SetDeclarationsParentVisitor
|
||||
import org.jetbrains.kotlin.ir.util.addChild
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||
@@ -123,7 +120,7 @@ internal class TestProcessor (val context: Context) {
|
||||
putValueArgument(0, IrGetEnumValueImpl(
|
||||
it.function.startOffset,
|
||||
it.function.endOffset,
|
||||
symbols.testFunctionKind.typeWithoutArguments,
|
||||
symbols.testFunctionKind.typeWithArguments(emptyList()),
|
||||
testKindEntry)
|
||||
)
|
||||
putValueArgument(1, IrFunctionReferenceImpl(
|
||||
@@ -349,7 +346,7 @@ internal class TestProcessor (val context: Context) {
|
||||
getterName,
|
||||
DescriptorVisibilities.PROTECTED,
|
||||
Modality.FINAL,
|
||||
objectSymbol.typeWithStarProjections,
|
||||
objectSymbol.starProjectedType,
|
||||
isInline = false,
|
||||
isExternal = false,
|
||||
isTailrec = false,
|
||||
@@ -368,7 +365,7 @@ internal class TestProcessor (val context: Context) {
|
||||
overriddenSymbols += superFunction.symbol
|
||||
|
||||
body = context.createIrBuilder(symbol, symbol.owner.startOffset, symbol.owner.endOffset).irBlockBody {
|
||||
+irReturn(irGetObjectValue(objectSymbol.typeWithoutArguments, objectSymbol)
|
||||
+irReturn(irGetObjectValue(objectSymbol.typeWithArguments(emptyList()), objectSymbol)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -387,7 +384,7 @@ internal class TestProcessor (val context: Context) {
|
||||
getterName,
|
||||
DescriptorVisibilities.PROTECTED,
|
||||
Modality.FINAL,
|
||||
classSymbol.typeWithStarProjections,
|
||||
classSymbol.starProjectedType,
|
||||
isInline = false,
|
||||
isExternal = false,
|
||||
isTailrec = false,
|
||||
@@ -435,7 +432,7 @@ internal class TestProcessor (val context: Context) {
|
||||
IrConstructorSymbolImpl(),
|
||||
Name.special("<init>"),
|
||||
DescriptorVisibilities.PUBLIC,
|
||||
testSuite.typeWithStarProjections,
|
||||
testSuite.starProjectedType,
|
||||
isInline = false,
|
||||
isExternal = false,
|
||||
isPrimary = true,
|
||||
@@ -479,8 +476,10 @@ internal class TestProcessor (val context: Context) {
|
||||
*/
|
||||
private fun buildClassSuite(testClass: IrClass,
|
||||
testCompanion: IrClass?,
|
||||
functions: Collection<TestFunction>): IrClass =
|
||||
IrClassImpl(
|
||||
functions: Collection<TestFunction>,
|
||||
irFile: IrFile
|
||||
): IrClass {
|
||||
return IrClassImpl(
|
||||
testClass.startOffset, testClass.endOffset,
|
||||
TEST_SUITE_CLASS,
|
||||
IrClassSymbolImpl(),
|
||||
@@ -496,6 +495,7 @@ internal class TestProcessor (val context: Context) {
|
||||
isExpect = false,
|
||||
isFun = false
|
||||
).apply {
|
||||
irFile.addChild(this)
|
||||
createParameterDeclarations()
|
||||
|
||||
val testClassType = testClass.defaultType
|
||||
@@ -530,12 +530,12 @@ internal class TestProcessor (val context: Context) {
|
||||
superTypes += symbols.baseClassSuite.typeWith(listOf(testClassType, testCompanionType))
|
||||
addFakeOverrides(context.typeSystem)
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
|
||||
// region IR generation methods
|
||||
private fun generateClassSuite(irFile: IrFile, testClass: TestClass) =
|
||||
with(buildClassSuite(testClass.ownerClass, testClass.companion,testClass.functions)) {
|
||||
irFile.addChild(this)
|
||||
with(buildClassSuite(testClass.ownerClass, testClass.companion, testClass.functions, irFile)) {
|
||||
val irConstructor = constructors.single()
|
||||
val irBuilder = context.createIrBuilder(irFile.symbol, testClass.ownerClass.startOffset, testClass.ownerClass.endOffset)
|
||||
irBuilder.irCall(irConstructor)
|
||||
|
||||
+2
-4
@@ -8,8 +8,6 @@ package org.jetbrains.kotlin.backend.konan.lower
|
||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.lower.*
|
||||
import org.jetbrains.kotlin.backend.konan.ir.containsNull
|
||||
import org.jetbrains.kotlin.backend.konan.ir.isSubtypeOf
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
@@ -64,9 +62,9 @@ internal class TypeOperatorLowering(val context: CommonBackendContext) : FileLow
|
||||
// TODO: consider the case when expression type is wrong e.g. due to generics-related unchecked casts.
|
||||
|
||||
return when {
|
||||
expression.argument.type.isSubtypeOf(typeOperand) -> expression.argument
|
||||
expression.argument.type.isSubtypeOf(typeOperand, context.typeSystem) -> expression.argument
|
||||
|
||||
expression.argument.type.containsNull() -> {
|
||||
expression.argument.type.isNullable() -> {
|
||||
with(builder) {
|
||||
irLetS(expression.argument) { argument ->
|
||||
irIfThenElse(
|
||||
|
||||
Reference in New Issue
Block a user