Make native class object members delegate to static methods in the outer class

This commit is contained in:
Andrey Breslav
2014-11-19 18:24:02 +03:00
parent d20651b881
commit 27d403ee23
4 changed files with 48 additions and 13 deletions
@@ -1,27 +1,34 @@
package foo
import kotlin.jvm.*
import kotlin.platform.*
class WithNative {
class object {
platformStatic native fun bar() {}
platformStatic native fun bar(l: Long, s: String): Double = null!!
}
}
object ObjWithNative {
platformStatic native fun bar() {}
platformStatic native fun bar(l: Long, s: String): Double = null!!
}
fun box(): String {
var d = 0.0
try {
WithNative.bar()
d = WithNative.bar(1, "")
return "Link error expected"
}
catch (e: java.lang.UnsatisfiedLinkError) {}
catch (e: java.lang.UnsatisfiedLinkError) {
if (e.getMessage() != "foo.WithNative.bar(JLjava/lang/String;)D") return "Fail 1: " + e.getMessage()
}
try {
ObjWithNative.bar()
d = ObjWithNative.bar(1, "")
return "Link error expected on object"
}
catch (e: java.lang.UnsatisfiedLinkError) {}
catch (e: java.lang.UnsatisfiedLinkError) {
if (e.getMessage() != "foo.ObjWithNative.bar(JLjava/lang/String;)D") return "Fail 2: " + e.getMessage()
}
return "OK"
}