Files
kotlin-fork/compiler/testData/codegen/boxInline/assert/jvmClassInitializer.kt
T
pyos bc4be53569 JVM: generate $assertionsDisabled before inlining the node
This fixes the problem where compiling a class initializer that contains
a call to an `assert`ing function in a separate module causes the
assertion to always be enabled (i.e. the attached test used to fail in
CompileKotlinAgainstInlineKotlin mode).
2019-10-11 14:54:52 +03:00

42 lines
829 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR
// FILE: inline.kt
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
// WITH_RUNTIME
// FULL_JDK
package test
class A {
inline fun doAssert() {
assert(false)
}
}
// FILE: inlineSite.kt
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
import test.*
class B {
companion object {
@JvmField
val triggered: Boolean = try {
A().doAssert()
false
} catch (e: AssertionError) {
true
}
}
}
class Dummy
fun box(): String {
val loader = Dummy::class.java.classLoader
loader.setDefaultAssertionStatus(false)
return if (loader.loadClass("B").getField("triggered").get(null) == true)
"FAIL: assertion triggered"
else
"OK"
}