Fix generation of bridges for lambdas
#KT-8447 Fixed
This commit is contained in:
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.codegen;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.util.ArrayUtil;
|
import com.intellij.util.ArrayUtil;
|
||||||
|
import kotlin.KotlinPackage;
|
||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -268,17 +269,18 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
|
|||||||
|
|
||||||
iv.load(0, asmType);
|
iv.load(0, asmType);
|
||||||
|
|
||||||
ReceiverParameterDescriptor receiver = funDescriptor.getExtensionReceiverParameter();
|
Type[] myParameterTypes = bridge.getArgumentTypes();
|
||||||
int count = 1;
|
|
||||||
if (receiver != null) {
|
|
||||||
StackValue.local(count, bridge.getArgumentTypes()[count - 1]).put(typeMapper.mapType(receiver.getType()), iv);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ValueParameterDescriptor> params = funDescriptor.getValueParameters();
|
List<ParameterDescriptor> calleeParameters = KotlinPackage.plus(
|
||||||
for (ValueParameterDescriptor param : params) {
|
UtilsPackage.<ParameterDescriptor>singletonOrEmptyList(funDescriptor.getExtensionReceiverParameter()),
|
||||||
StackValue.local(count, bridge.getArgumentTypes()[count - 1]).put(typeMapper.mapType(param.getType()), iv);
|
funDescriptor.getValueParameters()
|
||||||
count++;
|
);
|
||||||
|
|
||||||
|
int slot = 1;
|
||||||
|
for (int i = 0; i < calleeParameters.size(); i++) {
|
||||||
|
Type type = myParameterTypes[i];
|
||||||
|
StackValue.local(slot, type).put(typeMapper.mapType(calleeParameters.get(i)), iv);
|
||||||
|
slot += type.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
iv.invokevirtual(asmType.getInternalName(), delegate.getName(), delegate.getDescriptor(), false);
|
iv.invokevirtual(asmType.getInternalName(), delegate.getName(), delegate.getDescriptor(), false);
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
interface GenericInterface<T> {
|
||||||
|
public T foo(double d, int i, long j, short s);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun getInterface(): GenericInterface<String> {
|
||||||
|
return GenericInterface { d, i, j, s ->
|
||||||
|
"OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return getInterface().foo(0.0, 0, 0, 0)
|
||||||
|
}
|
||||||
+6
@@ -597,6 +597,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod
|
|||||||
doTestAgainstJava(fileName);
|
doTestAgainstJava(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("doubleLongParameters.kt")
|
||||||
|
public void testDoubleLongParameters() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.kt");
|
||||||
|
doTestAgainstJava(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("fileFilter.kt")
|
@TestMetadata("fileFilter.kt")
|
||||||
public void testFileFilter() throws Exception {
|
public void testFileFilter() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/fileFilter.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/fileFilter.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user