Fix for KT-6383: Can't access a private static member of class object
#KT-6383 Fixed
This commit is contained in:
@@ -30,11 +30,10 @@ class PlatformStaticGenerator(
|
|||||||
val state: GenerationState
|
val state: GenerationState
|
||||||
) : Function2<ImplementationBodyCodegen, ClassBuilder, Unit> {
|
) : Function2<ImplementationBodyCodegen, ClassBuilder, Unit> {
|
||||||
|
|
||||||
override fun invoke(p1: ImplementationBodyCodegen, p2: ClassBuilder) {
|
override fun invoke(codegen: ImplementationBodyCodegen, classBuilder: ClassBuilder) {
|
||||||
val typeMapper = state.getTypeMapper()
|
val typeMapper = state.getTypeMapper()
|
||||||
val callable = typeMapper.mapToCallableMethod(descriptor, false, p1.getContext())
|
val asmMethod = typeMapper.mapSignature(descriptor).getAsmMethod()
|
||||||
val asmMethod = callable.getAsmMethod()
|
val methodVisitor = classBuilder.newMethod(
|
||||||
val methodVisitor = p2.newMethod(
|
|
||||||
Synthetic(declarationOrigin.element, descriptor),
|
Synthetic(declarationOrigin.element, descriptor),
|
||||||
Opcodes.ACC_STATIC or AsmUtil.getMethodAsmFlags(descriptor, OwnerKind.IMPLEMENTATION),
|
Opcodes.ACC_STATIC or AsmUtil.getMethodAsmFlags(descriptor, OwnerKind.IMPLEMENTATION),
|
||||||
asmMethod.getName()!!,
|
asmMethod.getName()!!,
|
||||||
@@ -55,7 +54,13 @@ class PlatformStaticGenerator(
|
|||||||
iv.load(index, paramType);
|
iv.load(index, paramType);
|
||||||
index += paramType.getSize();
|
index += paramType.getSize();
|
||||||
}
|
}
|
||||||
callable.invokeWithoutAssertions(iv)
|
|
||||||
|
val syntheticOrOriginalMethod = typeMapper.mapToCallableMethod(
|
||||||
|
codegen.getContext().accessibleFunctionDescriptor(descriptor),
|
||||||
|
false,
|
||||||
|
codegen.getContext()
|
||||||
|
)
|
||||||
|
syntheticOrOriginalMethod.invokeWithoutAssertions(iv)
|
||||||
iv.areturn(asmMethod.getReturnType());
|
iv.areturn(asmMethod.getReturnType());
|
||||||
methodVisitor.visitEnd();
|
methodVisitor.visitEnd();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import kotlin.platform.*
|
||||||
|
|
||||||
|
class C {
|
||||||
|
class object {
|
||||||
|
private platformStatic fun foo(): String {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(): String {
|
||||||
|
return foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return C().bar()
|
||||||
|
}
|
||||||
+6
@@ -1763,6 +1763,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
|||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/simple.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/simple.kt");
|
||||||
doTestWithStdlib(fileName);
|
doTestWithStdlib(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("syntheticAccessor.kt")
|
||||||
|
public void testSyntheticAccessor() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/syntheticAccessor.kt");
|
||||||
|
doTestWithStdlib(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/platformTypes")
|
@TestMetadata("compiler/testData/codegen/boxWithStdlib/platformTypes")
|
||||||
|
|||||||
Reference in New Issue
Block a user