mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
Avoid name clashes in cases such as
inline class Login(val login: String)
inline class Password(val password: String)
fun validate(login: Login) { ... }
fun validate(password: Password) { ... }
35 lines
553 B
Kotlin
Vendored
35 lines
553 B
Kotlin
Vendored
// !LANGUAGE: +InlineClasses
|
|
// IGNORE_BACKEND: JVM_IR, JS, JS_IR
|
|
// FULL_JDK
|
|
// WITH_RUNTIME
|
|
|
|
inline class Id(val id: String)
|
|
|
|
fun throws() {
|
|
throw RuntimeException()
|
|
}
|
|
|
|
fun test(id: Id) {
|
|
throws()
|
|
}
|
|
|
|
fun foo() {
|
|
test(Id("id"))
|
|
}
|
|
|
|
fun box(): String {
|
|
val stackTrace = try {
|
|
foo()
|
|
throw AssertionError()
|
|
} catch (e: RuntimeException) {
|
|
e.stackTrace
|
|
}
|
|
|
|
for (entry in stackTrace) {
|
|
if (entry.methodName.startsWith("test$")) {
|
|
return "OK"
|
|
}
|
|
}
|
|
|
|
throw AssertionError()
|
|
} |