diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt index 4536df54909..55977a63d14 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt @@ -26,26 +26,26 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; public trait Callable { - public fun getOwner(): Type + public val owner: Type + + public val thisType: Type? + + public val receiverType: Type? + + public val generateCalleeType: Type? + + public val valueParameterTypes: List + + public val argumentTypes: Array + + public val returnType: Type public fun invokeWithNotNullAssertion(v: InstructionAdapter, state: GenerationState, resolvedCall: ResolvedCall<*>) public fun invokeWithoutAssertions(v: InstructionAdapter) - public fun getGenerateCalleeType(): Type? - - public fun getValueParameterTypes(): List - - public fun getArgumentTypes(): Array - - public fun getReturnType(): Type - public fun isStaticCall(): Boolean - public fun getThisType(): Type? - - public fun getReceiverClass(): Type? - public fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?) public fun invokeMethodWithArguments(resolvedCall: ResolvedCall<*>, receiver: StackValue, returnType: Type, codegen: ExpressionCodegen): StackValue diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt index d47a47e2717..ec7661463fb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt @@ -38,42 +38,31 @@ import org.jetbrains.org.objectweb.asm.util.Printer; import java.util.ArrayList; -public class CallableMethod(private val owner: Type, private val defaultImplOwner: Type?, private val defaultImplParam: Type?, private val signature: JvmMethodSignature, private val invokeOpcode: Int, private val thisClass: Type?, private val receiverParameterType: Type?, private val generateCalleeType: Type?) : Callable { +public class CallableMethod(override val owner: Type, private val defaultImplOwner: Type?, private val defaultImplParam: Type?, private val signature: JvmMethodSignature, private val invokeOpcode: Int, override val thisType: Type?, override val receiverType: Type?, override val generateCalleeType: Type?) : Callable { - override fun getOwner(): Type { - return owner - } public fun getValueParameters(): List { return signature.getValueParameters() } - override fun getValueParameterTypes(): List { - val valueParameters = signature.getValueParameters() - val result = ArrayList(valueParameters.size()) - for (parameter in valueParameters) { - if (parameter.getKind() == JvmMethodParameterKind.VALUE) { - result.add(parameter.getAsmType()) + override val valueParameterTypes: List + get() { + val valueParameters = signature.getValueParameters() + val result = ArrayList(valueParameters.size()) + for (parameter in valueParameters) { + if (parameter.getKind() == JvmMethodParameterKind.VALUE) { + result.add(parameter.getAsmType()) + } } + return result } - return result - } public fun getAsmMethod(): Method { return signature.getAsmMethod() } - override fun getArgumentTypes(): Array { - return signature.getAsmMethod().getArgumentTypes() - } - - override fun getThisType(): Type? { - return thisClass - } - - override fun getReceiverClass(): Type? { - return receiverParameterType - } + override val argumentTypes: Array + get() =signature.getAsmMethod().getArgumentTypes() private fun invoke(v: InstructionAdapter) { v.visitMethodInsn(invokeOpcode, owner.getInternalName(), getAsmMethod().getName(), getAsmMethod().getDescriptor()) @@ -89,10 +78,6 @@ public class CallableMethod(private val owner: Type, private val defaultImplOwne invoke(v) } - override fun getGenerateCalleeType(): Type? { - return generateCalleeType - } - private fun invokeDefault(v: InstructionAdapter) { if (defaultImplOwner == null || defaultImplParam == null) { throw IllegalStateException() @@ -100,8 +85,8 @@ public class CallableMethod(private val owner: Type, private val defaultImplOwne val method = getAsmMethod(); val desc = JetTypeMapper.getDefaultDescriptor(method, - if (invokeOpcode == INVOKESTATIC) null else defaultImplParam.getDescriptor(), - receiverParameterType != null); + if (invokeOpcode == INVOKESTATIC) null else defaultImplParam.getDescriptor(), + receiverType != null); if ("".equals(method.getName())) { v.aconst(null) @@ -118,9 +103,10 @@ public class CallableMethod(private val owner: Type, private val defaultImplOwne AsmUtil.genNotNullAssertionForMethod(v, state, resolvedCall) } - override fun getReturnType(): Type { - return signature.getReturnType() - } + override val returnType: Type + get() { + return signature.getReturnType() + } override fun toString(): String { return Printer.OPCODES[invokeOpcode] + " " + owner.getInternalName() + "." + signature @@ -130,7 +116,6 @@ public class CallableMethod(private val owner: Type, private val defaultImplOwne return invokeOpcode == INVOKESTATIC } - public override fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?) { } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt index fd3d5556d7e..12f55b2d305 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt @@ -136,7 +136,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) { val v = InstructionAdapter(mv) mv.visitCode() - val methodOwner = typeMapper.mapToCallableMethod(delegateFunctionDescriptor, false, context).getOwner() + val methodOwner = typeMapper.mapToCallableMethod(delegateFunctionDescriptor, false, context).owner if (!isStatic) { val thisIndex = frameMap.enterTemp(AsmTypes.OBJECT_TYPE) v.load(thisIndex, methodOwner) // Load this on stack diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index b311f0962cc..1857af9e269 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -1275,7 +1275,7 @@ public abstract class StackValue { ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter(); if (extensionReceiver != null) { - return callableMethod != null ? callableMethod.getReceiverClass() : typeMapper.mapType(extensionReceiver.getType()); + return callableMethod != null ? callableMethod.getReceiverType() : typeMapper.mapType(extensionReceiver.getType()); } else if (dispatchReceiver != null) { if (AnnotationsPackage.isPlatformStaticInObjectOrClass(descriptor)) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/TailRecursionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/TailRecursionCodegen.java index 71944edffed..f8877650b17 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/TailRecursionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/TailRecursionCodegen.java @@ -74,13 +74,13 @@ public class TailRecursionCodegen { throw new IllegalStateException("Failed to arrange value arguments by index: " + fd); } assignParameterValues(fd, callable, arguments); - if (callable.getReceiverClass() != null) { + if (callable.getReceiverType() != null) { if (resolvedCall.getExtensionReceiver() != fd.getExtensionReceiverParameter().getValue()) { StackValue expression = context.getReceiverExpression(codegen.typeMapper); - expression.store(StackValue.onStack(callable.getReceiverClass()), v, true); + expression.store(StackValue.onStack(callable.getReceiverType()), v, true); } else { - AsmUtil.pop(v, callable.getReceiverClass()); + AsmUtil.pop(v, callable.getReceiverType()); } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt index 6ef39355878..c45642b411e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt @@ -25,8 +25,8 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter public class ArraySet : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - val type = correctElementType(method.getThisType()) - return object: IntrinsicCallable(Type.VOID_TYPE, listOf(Type.INT_TYPE, type), method.getThisType(), method.getReceiverClass()) { + val type = correctElementType(method.thisType) + return object: IntrinsicCallable(Type.VOID_TYPE, listOf(Type.INT_TYPE, type), method.thisType, method.receiverType) { override fun invokeIntrinsic(v: InstructionAdapter) { v.astore(type) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt index ec460efb45a..587b23500f0 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt @@ -31,13 +31,13 @@ public class BinaryOp(private val opcode: Int) : IntrinsicMethod() { } override fun toCallable(method: CallableMethod): Callable { - val returnType = method.getReturnType() + val returnType = method.returnType assert(method.getValueParameters().size() == 1) val operandType = numberFunctionOperandType(returnType) val paramType = if (shift()) Type.INT_TYPE else operandType return IntrinsicCallable.binaryIntrinsic(operandType, paramType, operandType) { - v -> v.visitInsn(getReturnType().getOpcode(opcode)) + v -> v.visitInsn(returnType.getOpcode(opcode)) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt index 72017cb811f..ab4e00b9b5e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt @@ -43,8 +43,8 @@ public class CompareTo : IntrinsicMethod() { } override fun toCallable(method: CallableMethod): Callable { - val argumentType = comparisonOperandType(method.getThisType() ?: method.getReceiverClass(), method.getArgumentTypes().first()) - return IntrinsicCallable.binaryIntrinsic(method.getReturnType(), argumentType, argumentType, null) { + val argumentType = comparisonOperandType(method.thisType ?: method.receiverType, method.argumentTypes.first()) + return IntrinsicCallable.binaryIntrinsic(method.returnType, argumentType, argumentType, null) { genInvoke(argumentType, it) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt index 721390568c6..2d2598644d4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE public class Equals : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - return IntrinsicCallable.binaryIntrinsic(method.getReturnType(), OBJECT_TYPE, nullOrObject(method.getThisType()), nullOrObject(method.getReceiverClass())) { + return IntrinsicCallable.binaryIntrinsic(method.returnType, OBJECT_TYPE, nullOrObject(method.thisType), nullOrObject(method.receiverType)) { AsmUtil.genAreEqualCall(it) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt index 8e5d3fe82d1..c39aad3d3c9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt @@ -25,7 +25,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter public class HashCode : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - return object: IntrinsicCallable(Type.INT_TYPE, emptyList(), nullOrObject(method.getThisType()), nullOrObject(method.getReceiverClass())) { + return object: IntrinsicCallable(Type.INT_TYPE, emptyList(), nullOrObject(method.thisType), nullOrObject(method.receiverType)) { override fun invokeIntrinsic(v: InstructionAdapter) { v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "hashCode", "()I", false) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Increment.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Increment.kt index 7026c305cd6..d9cb8ef1407 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Increment.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Increment.kt @@ -30,7 +30,7 @@ public class Increment(private val myDelta: Int) : IntrinsicMethod() { return MappedCallable(method) { val jetExpression = resolvedCall.getCall().getCalleeExpression() assert(jetExpression !is JetPrefixExpression) { "There should be postfix increment ${jetExpression!!.getText()}" } - genIncrement(getReturnType(), myDelta, it) + genIncrement(returnType, myDelta, it) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt index d7bc9bcdf39..c643c51c87d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt @@ -25,10 +25,10 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -public abstract class IntrinsicCallable(val returnType1: Type, - val valueParametersTypes: List, - val thisType1: Type?, - val receiverType1: Type?) : Callable { +public abstract class IntrinsicCallable(override val returnType: Type, + override val valueParameterTypes: List, + override val thisType: Type?, + override val receiverType: Type?) : Callable { companion object { fun create(descriptor: FunctionDescriptor, context: CodegenContext<*>, state: GenerationState, lambda: IntrinsicCallable.(i: InstructionAdapter) -> Unit): IntrinsicCallable { @@ -36,7 +36,7 @@ public abstract class IntrinsicCallable(val returnType1: Type, } fun create(callableMethod: CallableMethod, lambda: IntrinsicCallable.(i: InstructionAdapter) -> Unit): IntrinsicCallable { - return object : IntrinsicCallable(callableMethod.getReturnType(), callableMethod.getValueParameterTypes(), callableMethod.getThisType(), callableMethod.getReceiverClass()) { + return object : IntrinsicCallable(callableMethod.returnType, callableMethod.valueParameterTypes, callableMethod.thisType, callableMethod.receiverType) { override fun invokeIntrinsic(v: InstructionAdapter) { lambda(v) } @@ -56,7 +56,7 @@ public abstract class IntrinsicCallable(val returnType1: Type, fun create(descriptor: FunctionDescriptor, context: CodegenContext<*>, state: GenerationState, receiverTransformer: Type.() -> Type, lambda: IntrinsicCallable.(i: InstructionAdapter) -> Unit): IntrinsicCallable { val callableMethod = state.getTypeMapper().mapToCallableMethod(descriptor, false, context) - return object : IntrinsicCallable(callableMethod.getReturnType(), callableMethod.getValueParameterTypes(), callableMethod.getThisType()?.receiverTransformer(), callableMethod.getReceiverClass()?.receiverTransformer()) { + return object : IntrinsicCallable(callableMethod.returnType, callableMethod.valueParameterTypes, callableMethod.thisType?.receiverTransformer(), callableMethod.receiverType?.receiverTransformer()) { override fun invokeIntrinsic(v: InstructionAdapter) { lambda(v) } @@ -64,11 +64,6 @@ public abstract class IntrinsicCallable(val returnType1: Type, } } - override fun getValueParameterTypes(): List { - return valueParametersTypes - } - - override fun invokeWithoutAssertions(v: InstructionAdapter) { invokeIntrinsic(v) } @@ -79,36 +74,27 @@ public abstract class IntrinsicCallable(val returnType1: Type, public abstract fun invokeIntrinsic(v: InstructionAdapter); - override fun getArgumentTypes(): Array { - throw UnsupportedOperationException() - } + override val argumentTypes: Array + get() { + throw UnsupportedOperationException() + } override fun isStaticCall(): Boolean { return false } - override fun getGenerateCalleeType(): Type? { - return null - } + override val generateCalleeType: Type? + get() { + return null + } - override fun getReturnType(): Type { - return returnType1 - } - - override fun getThisType(): Type? { - return thisType1 - } - - override fun getReceiverClass(): Type? { - return receiverType1 - } - - override fun getOwner(): Type { - throw UnsupportedOperationException() - } + override val owner: Type + get() { + throw UnsupportedOperationException() + } public fun calcReceiverType(): Type? { - return getReceiverClass() ?: getThisType() + return receiverType ?: thisType } override fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?) { @@ -124,13 +110,13 @@ public abstract class IntrinsicCallable(val returnType1: Type, public class UnaryIntrinsic(val callable: CallableMethod, val newReturnType: Type? = null, needPrimitiveCheck: Boolean = false, val newThisType: Type? = null, val invoke: UnaryIntrinsic.(v: InstructionAdapter) -> Unit) : - IntrinsicCallable(newReturnType ?: callable.getReturnType(), callable.getValueParameterTypes(), newThisType ?: callable.getThisType(), callable.getReceiverClass()) { + IntrinsicCallable(newReturnType ?: callable.returnType, callable.valueParameterTypes, newThisType ?: callable.thisType, callable.receiverType) { { if (needPrimitiveCheck) { - assert(AsmUtil.isPrimitive(getReturnType())) { "Return type of UnaryPlus intrinsic should be of primitive type : " + getReturnType() } + assert(AsmUtil.isPrimitive(returnType)) { "Return type of UnaryPlus intrinsic should be of primitive type : " + returnType } } - assert(getValueParameterTypes().size == 0, "Unary operation should not have any parameters") + assert(valueParameterTypes.size == 0, "Unary operation should not have any parameters") } override fun invokeIntrinsic(v: InstructionAdapter) { @@ -140,7 +126,7 @@ public class UnaryIntrinsic(val callable: CallableMethod, val newReturnType: Typ } public open class MappedCallable(val callable: CallableMethod, val invoke: MappedCallable.(v: InstructionAdapter) -> Unit = {}) : - IntrinsicCallable(callable.getReturnType(), callable.getValueParameterTypes(), callable.getThisType(), callable.getReceiverClass()) { + IntrinsicCallable(callable.returnType, callable.valueParameterTypes, callable.thisType, callable.receiverType) { override fun invokeIntrinsic(v: InstructionAdapter) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Inv.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Inv.kt index a355ce155d5..54097adad94 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Inv.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Inv.kt @@ -24,15 +24,15 @@ import org.jetbrains.org.objectweb.asm.Type public class Inv : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - val type = numberFunctionOperandType(method.getReturnType()) - return UnaryIntrinsic(method, method.getReturnType(), newThisType = type) { - if (getReturnType() == Type.LONG_TYPE) { + val type = numberFunctionOperandType(method.returnType) + return UnaryIntrinsic(method, method.returnType, newThisType = type) { + if (returnType == Type.LONG_TYPE) { it.lconst(-1) } else { it.iconst(-1) } - it.xor(getReturnType()) + it.xor(returnType) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt index ddd325be817..8253fef30d5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt @@ -63,7 +63,7 @@ public class IteratorNext : IntrinsicMethod() { val type = state.getTypeMapper().mapReturnType(fd) return object: IntrinsicCallable(type, listOf(), AsmTypes.OBJECT_TYPE, null) { override fun invokeIntrinsic(v: InstructionAdapter) { - val returnType = getReturnType() + val returnType = returnType val name = getIteratorName(returnType) v.invokevirtual(BUILT_INS_PACKAGE_FQ_NAME.toString() + "/" + name + "Iterator", "next" + name, "()" + returnType.getDescriptor(), false) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NumberCast.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NumberCast.kt index 027d2db14ab..61e6ce8d4d9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NumberCast.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/NumberCast.kt @@ -24,7 +24,7 @@ public class NumberCast : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { return UnaryIntrinsic(method) { - StackValue.coerce(calcReceiverType()!!, getReturnType(), it) + StackValue.coerce(calcReceiverType()!!, returnType, it) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt index 4ffc52edd65..776e5b5fdd7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt @@ -42,16 +42,16 @@ public class RangeTo : IntrinsicMethod() { override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable { val method = codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext()) - val argType = nameToPrimitive(method.getReturnType().getInternalName().substringAfter("kotlin/").substringBefore("Range")) - return object : IntrinsicCallable(method.getReturnType(), method.getValueParameterTypes().map { argType }, nullOr(method.getThisType(), argType), nullOr(method.getReceiverClass(), argType)) { + val argType = nameToPrimitive(method.returnType.getInternalName().substringAfter("kotlin/").substringBefore("Range")) + return object : IntrinsicCallable(method.returnType, method.valueParameterTypes.map { argType }, nullOr(method.thisType, argType), nullOr(method.receiverType, argType)) { override fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?) { - v.anew(getReturnType()) + v.anew(returnType) v.dup() value?.moveToTopOfStack(value!!.type, v, 2) } override fun invokeIntrinsic(v: InstructionAdapter) { - v.invokespecial(getReturnType().getInternalName(), "", Type.getMethodDescriptor(Type.VOID_TYPE, argType, argType), false) + v.invokespecial(returnType.getInternalName(), "", Type.getMethodDescriptor(Type.VOID_TYPE, argType, argType), false) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt index 6b21123aeb1..753047595e3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.codegen.CallableMethod public class ToString : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - val type = AsmUtil.stringValueOfType(method.getThisType() ?: method.getReceiverClass()) + val type = AsmUtil.stringValueOfType(method.thisType ?: method.receiverType) return UnaryIntrinsic(method, newThisType = type) { it.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;", false) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryMinus.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryMinus.kt index 0e721c5fbfd..6922228e9fb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryMinus.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/UnaryMinus.kt @@ -23,8 +23,8 @@ import org.jetbrains.kotlin.codegen.CallableMethod public class UnaryMinus : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - return UnaryIntrinsic(method, numberFunctionOperandType(method.getReturnType()), needPrimitiveCheck = true) { - it.neg(getReturnType()) + return UnaryIntrinsic(method, numberFunctionOperandType(method.returnType), needPrimitiveCheck = true) { + it.neg(returnType) } } }