Fix for KT-6383: Can't access a private static member of class object

#KT-6383 Fixed
This commit is contained in:
Michael Bogdanov
2014-12-02 14:51:38 +03:00
parent fda7f63957
commit 328dedc415
3 changed files with 33 additions and 5 deletions
@@ -30,11 +30,10 @@ class PlatformStaticGenerator(
val state: GenerationState
) : Function2<ImplementationBodyCodegen, ClassBuilder, Unit> {
override fun invoke(p1: ImplementationBodyCodegen, p2: ClassBuilder) {
override fun invoke(codegen: ImplementationBodyCodegen, classBuilder: ClassBuilder) {
val typeMapper = state.getTypeMapper()
val callable = typeMapper.mapToCallableMethod(descriptor, false, p1.getContext())
val asmMethod = callable.getAsmMethod()
val methodVisitor = p2.newMethod(
val asmMethod = typeMapper.mapSignature(descriptor).getAsmMethod()
val methodVisitor = classBuilder.newMethod(
Synthetic(declarationOrigin.element, descriptor),
Opcodes.ACC_STATIC or AsmUtil.getMethodAsmFlags(descriptor, OwnerKind.IMPLEMENTATION),
asmMethod.getName()!!,
@@ -55,7 +54,13 @@ class PlatformStaticGenerator(
iv.load(index, paramType);
index += paramType.getSize();
}
callable.invokeWithoutAssertions(iv)
val syntheticOrOriginalMethod = typeMapper.mapToCallableMethod(
codegen.getContext().accessibleFunctionDescriptor(descriptor),
false,
codegen.getContext()
)
syntheticOrOriginalMethod.invokeWithoutAssertions(iv)
iv.areturn(asmMethod.getReturnType());
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()
}
@@ -1763,6 +1763,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/simple.kt");
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")