Files
kotlin-fork/compiler/testData/codegen/box/external/withDefaultArg.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

48 lines
1.2 KiB
Kotlin
Vendored

// TARGET_BACKEND: JVM
// IGNORE_BACKEND: ANDROID
// WITH_STDLIB
// FULL_JDK
package foo
object ObjWithNative {
external fun foo(x: Int = 1): Double
@JvmStatic external fun bar(l: Long, s: String = ""): Double
}
external fun topLevel(x: Int = 1): Double
fun box(): String {
var d = 0.0
try {
d = ObjWithNative.bar(1)
return "Link error expected on object"
}
catch (e: java.lang.UnsatisfiedLinkError) {
if (e.message != "foo.ObjWithNative.bar(JLjava/lang/String;)D" &&
e.message != "'double foo.ObjWithNative.bar(long, java.lang.String)'") return "Fail 1: " + e.message
}
try {
d = ObjWithNative.foo()
return "Link error expected on object"
}
catch (e: java.lang.UnsatisfiedLinkError) {
if (e.message != "foo.ObjWithNative.foo(I)D" &&
e.message != "'double foo.ObjWithNative.foo(int)'") return "Fail 2: " + e.message
}
try {
d = topLevel()
return "Link error expected on object"
}
catch (e: java.lang.UnsatisfiedLinkError) {
if (e.message != "foo.WithDefaultArgKt.topLevel(I)D" &&
e.message != "'double foo.WithDefaultArgKt.topLevel(int)'") return "Fail 3: " + e.message
}
return "OK"
}