Use wrapper class of an inline one as a result for javaClass
#KT-28185 Fixed #KT-28246 Open
This commit is contained in:
@@ -24,6 +24,8 @@ import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.isInlineClassType
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.UNIT_TYPE
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.getType
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
@@ -42,13 +44,29 @@ object JavaClassProperty : IntrinsicPropertyGetter() {
|
||||
}
|
||||
|
||||
fun generateImpl(v: InstructionAdapter, receiver: StackValue): Type {
|
||||
fun invokeVirtualGetClassMethod() {
|
||||
v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;", false)
|
||||
}
|
||||
|
||||
val type = receiver.type
|
||||
val kotlinType = receiver.kotlinType
|
||||
when {
|
||||
type == Type.VOID_TYPE -> {
|
||||
receiver.put(Type.VOID_TYPE, v)
|
||||
StackValue.unit().put(UNIT_TYPE, v)
|
||||
v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;", false)
|
||||
invokeVirtualGetClassMethod()
|
||||
}
|
||||
|
||||
kotlinType?.isInlineClassType() == true -> {
|
||||
receiver.put(type, kotlinType, v)
|
||||
StackValue.coerce(
|
||||
type, kotlinType,
|
||||
AsmTypes.OBJECT_TYPE, kotlinType.constructor.builtIns.nullableAnyType,
|
||||
v
|
||||
)
|
||||
invokeVirtualGetClassMethod()
|
||||
}
|
||||
|
||||
isPrimitive(type) -> {
|
||||
if (!StackValue.couldSkipReceiverOnStaticCall(receiver)) {
|
||||
receiver.put(type, v)
|
||||
@@ -56,9 +74,10 @@ object JavaClassProperty : IntrinsicPropertyGetter() {
|
||||
}
|
||||
v.getstatic(boxType(type).internalName, "TYPE", "Ljava/lang/Class;")
|
||||
}
|
||||
|
||||
else -> {
|
||||
receiver.put(type, v)
|
||||
v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;", false)
|
||||
invokeVirtualGetClassMethod()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user