[stdlib] Make @LowPriorityInOverloadResolution applicable to ctors

This commit is contained in:
Sergej Jaskiewicz
2021-12-01 16:21:41 +03:00
committed by Space
parent 2aa1c187d9
commit 599f705842
5 changed files with 36 additions and 1 deletions
@@ -12,8 +12,20 @@ fun bar(a: String?) = 3
fun bar(a: Any) = 4
class MyString(val value: String)
class Baz
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.LowPriorityInOverloadResolution
constructor(val s: String) {
constructor(s: MyString): this(s.value)
}
fun Baz(s: String) = Baz(MyString(s + "!"))
fun box(): String {
if (foo(1) != 2) return "fail1"
if (bar(null) != 3) return "fail2"
if (Baz("hello").s != "hello!") return "fail3"
return "OK"
}