Skip to content

Commit

Permalink
Adjust plugin expression types changes comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lupuuss committed Feb 28, 2024
1 parent 130c127 commit ed372d0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import org.jetbrains.kotlin.ir.util.properties
import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.isSubpackageOf
import kotlin.contracts.ExperimentalContracts
import kotlin.reflect.KClass
import kotlin.time.TimeSource

Expand Down Expand Up @@ -140,6 +139,7 @@ class MokkeryTransformer(compilerPluginScope: CompilerPluginScope) : CoreTransfo
block.transformChildren(transformer, null)
+irCall(function) {
block as IrFunctionExpression
// make return type nullable to avoid runtime checks for primitive types (required by Wasm-JS)
if (block.function.returnType.isPlatformDependent()) {
putTypeArgument(0, getTypeArgument(0)?.makeNullable())
block.function.returnType = block.function.returnType.makeNullable()
Expand Down Expand Up @@ -190,7 +190,6 @@ class MokkeryTransformer(compilerPluginScope: CompilerPluginScope) : CoreTransfo
.referenceClass(ClassId.fromString(cls.qualifiedName!!.replace(".", "/")))!!
.owner

@OptIn(ExperimentalContracts::class)
private fun IrExpression.assertFunctionExpressionThatOriginatesLambda(function: IrSimpleFunctionSymbol): Boolean {
if (this !is IrFunctionExpression) {
mokkeryErrorAt(this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TemplatingScopeCallsTransformer(
val cls = receiver.type.getClass() ?: return super.visitCall(expression)
if (cls.isFinalClass) return super.visitCall(expression)
super.visitCall(expression)
// make return type nullable to avoid runtime checks on non-primitive types (e.g. suspend fun on K/N)
// make return type Any? to avoid runtime checks on non-primitive types (required by Wasm-JS and K/N to work)
if (expression.symbol.owner.returnType.run { !isPrimitiveType(nullable = false) && !isNothing() }) {
expression.type = pluginContext.irBuiltIns.anyNType
}
Expand Down

0 comments on commit ed372d0

Please sign in to comment.