Fixed codegen for non-public SAM-adapters

This commit is contained in:
Valentin Kipyatkov
2015-07-29 23:22:15 +03:00
parent 5bceefe8df
commit 9150c53832
4 changed files with 28 additions and 0 deletions
@@ -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()
}
@@ -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");