Fix SAM wrapper generation in secondary constructor calls
Should simply invoke 'checkSamCall' in corresponding visitor method to check if call arguments should be wrapped.
This commit is contained in:
+2
@@ -648,6 +648,8 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
|||||||
@Override
|
@Override
|
||||||
public void visitConstructorDelegationCall(@NotNull KtConstructorDelegationCall call) {
|
public void visitConstructorDelegationCall(@NotNull KtConstructorDelegationCall call) {
|
||||||
withinUninitializedClass(call, () -> super.visitConstructorDelegationCall(call));
|
withinUninitializedClass(call, () -> super.visitConstructorDelegationCall(call));
|
||||||
|
|
||||||
|
checkSamCall(call);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void withinUninitializedClass(@NotNull KtElement element, @NotNull Runnable operation) {
|
private void withinUninitializedClass(@NotNull KtElement element, @NotNull Runnable operation) {
|
||||||
|
|||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
// FILE: test.kt
|
||||||
|
class Test : Base {
|
||||||
|
constructor(f: () -> String) : super(f)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = Test({ "OK" }).get()
|
||||||
|
|
||||||
|
// FILE: Supplier.java
|
||||||
|
public interface Supplier<T> {
|
||||||
|
T get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Base.java
|
||||||
|
public class Base {
|
||||||
|
private final Supplier<String> supplier;
|
||||||
|
|
||||||
|
public Base(Supplier<String> supplier) {
|
||||||
|
this.supplier = supplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get() {
|
||||||
|
return supplier.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -787,6 +787,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxAga
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("superInSecondaryConstructor.kt")
|
||||||
|
public void testSuperInSecondaryConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/superInSecondaryConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("superconstructor.kt")
|
@TestMetadata("superconstructor.kt")
|
||||||
public void testSuperconstructor() throws Exception {
|
public void testSuperconstructor() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/superconstructor.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/superconstructor.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user