Fix for KT-13890: IllegalAccessError when invoking protected method with default arguments
#KT-13890 Fixed
This commit is contained in:
@@ -845,14 +845,13 @@ public class FunctionCodegen {
|
||||
return;
|
||||
}
|
||||
|
||||
int flags = getVisibilityAccessFlag(functionDescriptor) |
|
||||
getDeprecatedAccessFlag(functionDescriptor) |
|
||||
ACC_SYNTHETIC;
|
||||
// $default methods are never private to be accessible from other class files (e.g. inner) without the need of synthetic accessors
|
||||
// $default methods are never protected to be accessible from subclass nested classes
|
||||
int visibilityFlag = Visibilities.isPrivate(functionDescriptor.getVisibility()) ? AsmUtil.NO_FLAG_PACKAGE_PRIVATE : Opcodes.ACC_PUBLIC;
|
||||
int flags = visibilityFlag | getDeprecatedAccessFlag(functionDescriptor) | ACC_SYNTHETIC;
|
||||
if (!(functionDescriptor instanceof ConstructorDescriptor)) {
|
||||
flags |= ACC_STATIC | ACC_BRIDGE;
|
||||
}
|
||||
// $default methods are never private to be accessible from other class files (e.g. inner) without the need of synthetic accessors
|
||||
flags &= ~ACC_PRIVATE;
|
||||
|
||||
Method defaultMethod = typeMapper.mapDefaultMethod(functionDescriptor, kind);
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// FILE: Foo.kt
|
||||
|
||||
package foo
|
||||
|
||||
open class Foo() {
|
||||
protected fun foo(value: Boolean = false) = if (!value) "OK" else "fail5"
|
||||
}
|
||||
|
||||
// FILE: Bar.kt
|
||||
|
||||
package bar
|
||||
|
||||
import foo.Foo
|
||||
|
||||
class Bar() : Foo() {
|
||||
fun execute(): String {
|
||||
return { foo() } ()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Bar().execute()
|
||||
}
|
||||
+6
@@ -5113,6 +5113,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("protected.kt")
|
||||
public void testProtected() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/protected.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleFromOtherFile.kt")
|
||||
public void testSimpleFromOtherFile() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/simpleFromOtherFile.kt");
|
||||
|
||||
@@ -5113,6 +5113,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("protected.kt")
|
||||
public void testProtected() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/protected.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleFromOtherFile.kt")
|
||||
public void testSimpleFromOtherFile() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/simpleFromOtherFile.kt");
|
||||
|
||||
Reference in New Issue
Block a user