Support native on [platformStatic] functions
This commit is contained in:
@@ -33,9 +33,10 @@ class PlatformStaticGenerator(
|
||||
override fun invoke(codegen: ImplementationBodyCodegen, classBuilder: ClassBuilder) {
|
||||
val typeMapper = state.getTypeMapper()
|
||||
val asmMethod = typeMapper.mapSignature(descriptor).getAsmMethod()
|
||||
val flags = Opcodes.ACC_STATIC or AsmUtil.getMethodAsmFlags(descriptor, OwnerKind.IMPLEMENTATION)
|
||||
val methodVisitor = classBuilder.newMethod(
|
||||
Synthetic(declarationOrigin.element, descriptor),
|
||||
Opcodes.ACC_STATIC or AsmUtil.getMethodAsmFlags(descriptor, OwnerKind.IMPLEMENTATION),
|
||||
flags,
|
||||
asmMethod.getName()!!,
|
||||
asmMethod.getDescriptor()!!,
|
||||
typeMapper.mapSignature(descriptor).getGenericsSignature(),
|
||||
@@ -43,7 +44,7 @@ class PlatformStaticGenerator(
|
||||
|
||||
AnnotationCodegen.forMethod(methodVisitor, typeMapper)!!.genAnnotations(descriptor, asmMethod.getReturnType())
|
||||
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.FULL && flags and Opcodes.ACC_NATIVE == 0) {
|
||||
methodVisitor.visitCode();
|
||||
val iv = InstructionAdapter(methodVisitor)
|
||||
val classDescriptor = descriptor.getContainingDeclaration() as ClassDescriptor
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import kotlin.jvm.*
|
||||
import kotlin.platform.*
|
||||
|
||||
class WithNative {
|
||||
class object {
|
||||
platformStatic native fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
object ObjWithNative {
|
||||
platformStatic native fun bar() {}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
WithNative.bar()
|
||||
return "Link error expected"
|
||||
}
|
||||
catch (e: java.lang.UnsatisfiedLinkError) {}
|
||||
|
||||
try {
|
||||
ObjWithNative.bar()
|
||||
return "Link error expected on object"
|
||||
}
|
||||
catch (e: java.lang.UnsatisfiedLinkError) {}
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -1824,6 +1824,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/native/simpleNative.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("staticNative.kt")
|
||||
public void testStaticNative() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/native/staticNative.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/nonLocalReturns")
|
||||
|
||||
Reference in New Issue
Block a user