[Wasm] Don't wrap single null expression into composite in WasmNullCoercingLowering
Otherwise, it breaks check/assert inside DeclarationGenerator::visitField (DeclarationGenerator.kt:458) #KT-56166 In-Progress
This commit is contained in:
+9
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.backend.wasm.lower
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.backend.wasm.WasmBackendContext
|
import org.jetbrains.kotlin.backend.wasm.WasmBackendContext
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
|
||||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||||
import org.jetbrains.kotlin.ir.backend.js.lower.AbstractValueUsageLowering
|
import org.jetbrains.kotlin.ir.backend.js.lower.AbstractValueUsageLowering
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
||||||
@@ -27,10 +27,13 @@ import org.jetbrains.kotlin.ir.types.makeNotNull
|
|||||||
class WasmNullCoercingLowering(private val contextx: WasmBackendContext) : AbstractValueUsageLowering(contextx) {
|
class WasmNullCoercingLowering(private val contextx: WasmBackendContext) : AbstractValueUsageLowering(contextx) {
|
||||||
override fun IrExpression.useExpressionAsType(actualType: IrType, expectedType: IrType): IrExpression =
|
override fun IrExpression.useExpressionAsType(actualType: IrType, expectedType: IrType): IrExpression =
|
||||||
if (actualType.makeNotNull().isNothing() && actualType.isNullable() && !expectedType.makeNotNull().isNothing() && expectedType != contextx.wasmSymbols.voidType)
|
if (actualType.makeNotNull().isNothing() && actualType.isNullable() && !expectedType.makeNotNull().isNothing() && expectedType != contextx.wasmSymbols.voidType)
|
||||||
JsIrBuilder.buildComposite(
|
if (this is IrConst<*> && this.kind == IrConstKind.Null)
|
||||||
expectedType,
|
IrConstImpl(this.startOffset, this.endOffset, expectedType, IrConstKind.Null, null)
|
||||||
listOf(this, IrConstImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, expectedType, IrConstKind.Null, null))
|
else
|
||||||
)
|
JsIrBuilder.buildComposite(
|
||||||
|
expectedType,
|
||||||
|
listOf(this, IrConstImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, expectedType, IrConstKind.Null, null))
|
||||||
|
)
|
||||||
else
|
else
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user