Do not wrap callable references when a special option is enabled

This commit is contained in:
Alexander Udalov
2015-11-06 00:33:13 +03:00
parent 1576160390
commit 75bb15a9fc
2 changed files with 6 additions and 2 deletions
@@ -260,8 +260,10 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
} }
if (functionReferenceTarget != null) { if (functionReferenceTarget != null) {
if (!"true".equalsIgnoreCase(System.getProperty("kotlin.jvm.optimize.callable.references"))) {
v.invokestatic(REFLECTION, "function", Type.getMethodDescriptor(K_FUNCTION, FUNCTION_REFERENCE), false); v.invokestatic(REFLECTION, "function", Type.getMethodDescriptor(K_FUNCTION, FUNCTION_REFERENCE), false);
} }
}
return Unit.INSTANCE$; return Unit.INSTANCE$;
} }
@@ -90,8 +90,10 @@ public class PropertyReferenceCodegen(
// TODO: ImplementationBodyCodegen.markLineNumberForSyntheticFunction? // TODO: ImplementationBodyCodegen.markLineNumberForSyntheticFunction?
override fun generateBody() { override fun generateBody() {
generateConstInstance(asmType, wrapperMethod.getReturnType()) { iv -> generateConstInstance(asmType, wrapperMethod.getReturnType()) { iv ->
if (!"true".equals(System.getProperty("kotlin.jvm.optimize.callable.references"), ignoreCase = true)) {
iv.invokestatic(REFLECTION, wrapperMethod.getName(), wrapperMethod.getDescriptor(), false) iv.invokestatic(REFLECTION, wrapperMethod.getName(), wrapperMethod.getDescriptor(), false)
} }
}
generateMethod("property reference init", 0, method("<init>", Type.VOID_TYPE)) { generateMethod("property reference init", 0, method("<init>", Type.VOID_TYPE)) {
load(0, OBJECT_TYPE) load(0, OBJECT_TYPE)