[IR] Simplify logic of constructing unsigned number in interpreter
This way it is a little less "hacky". We are looking only for "data" property, and as long as this property is declared in constructor, we can safely assume we will get the correct one even if it is renamed.
This commit is contained in:
+8
-6
@@ -19,7 +19,10 @@ import org.jetbrains.kotlin.ir.interpreter.intrinsics.IntrinsicEvaluator
|
||||
import org.jetbrains.kotlin.ir.interpreter.proxy.wrap
|
||||
import org.jetbrains.kotlin.ir.interpreter.stack.CallStack
|
||||
import org.jetbrains.kotlin.ir.interpreter.state.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.types.isArray
|
||||
import org.jetbrains.kotlin.ir.types.isUnsignedType
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -89,11 +92,10 @@ internal class DefaultCallInterceptor(override val interpreter: IrInterpreter) :
|
||||
verify(handleIntrinsicMethods(irConstructor)) { "Unsupported intrinsic constructor: ${irConstructor.render()}" }
|
||||
}
|
||||
irClass.defaultType.isUnsignedType() -> {
|
||||
// Check for type is a hack needed for Native;
|
||||
// in UInt, for example, we may have (after lowerings, I guess) additional property "$companion".
|
||||
// Check for fake overrides is a hack needed for Wasm;
|
||||
// in UInt, for example, we may have additional typeInfo and hashCode properties declared in "Any"
|
||||
val propertySymbol = irClass.declarations.single { it is IrProperty && !it.isFakeOverride && it.getter?.returnType?.isPrimitiveType() == true }.symbol
|
||||
val propertyName = irClass.inlineClassRepresentation?.underlyingPropertyName
|
||||
val propertySymbol = irClass.declarations.filterIsInstance<IrProperty>()
|
||||
.single { it.name == propertyName && it.getter?.extensionReceiverParameter == null }
|
||||
.symbol
|
||||
callStack.pushState(receiver.apply { this.setField(propertySymbol, args.single()) })
|
||||
}
|
||||
else -> defaultAction()
|
||||
|
||||
Reference in New Issue
Block a user