Fixed codegen for non-public SAM-adapters
This commit is contained in:
@@ -2329,6 +2329,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
@NotNull
|
||||
private FunctionDescriptor accessibleFunctionDescriptor(@NotNull ResolvedCall<?> resolvedCall) {
|
||||
FunctionDescriptor descriptor = (FunctionDescriptor) resolvedCall.getResultingDescriptor();
|
||||
FunctionDescriptor originalIfSamAdapter = SamCodegenUtil.getOriginalIfSamAdapter(descriptor);
|
||||
if (originalIfSamAdapter != null) {
|
||||
descriptor = originalIfSamAdapter;
|
||||
}
|
||||
// $default method is not private, so you need no accessor to call it
|
||||
return usesDefaultArguments(resolvedCall) ? descriptor : context.accessibleFunctionDescriptor(descriptor);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class JavaClass<T> {
|
||||
protected void execute(T t, Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class KotlinClass : JavaClass<String>() {
|
||||
fun doIt(): String {
|
||||
var result = ""
|
||||
execute("") {
|
||||
result = "OK"
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return KotlinClass().doIt()
|
||||
}
|
||||
+6
@@ -705,6 +705,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("protectedFromBase.kt")
|
||||
public void testProtectedFromBase() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/protectedFromBase.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("severalSamParameters.kt")
|
||||
public void testSeveralSamParameters() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.kt");
|
||||
|
||||
Reference in New Issue
Block a user