[stdlib] Make @LowPriorityInOverloadResolution applicable to ctors
This commit is contained in:
@@ -461,6 +461,7 @@ internal object CheckLowPriorityInOverloadResolution : CheckerStage() {
|
|||||||
val annotations = when (val fir = candidate.symbol.fir) {
|
val annotations = when (val fir = candidate.symbol.fir) {
|
||||||
is FirSimpleFunction -> fir.annotations
|
is FirSimpleFunction -> fir.annotations
|
||||||
is FirProperty -> fir.annotations
|
is FirProperty -> fir.annotations
|
||||||
|
is FirConstructor -> fir.annotations
|
||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
@@ -12,8 +12,20 @@ fun bar(a: String?) = 3
|
|||||||
|
|
||||||
fun bar(a: Any) = 4
|
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 {
|
fun box(): String {
|
||||||
if (foo(1) != 2) return "fail1"
|
if (foo(1) != 2) return "fail1"
|
||||||
if (bar(null) != 3) return "fail2"
|
if (bar(null) != 3) return "fail2"
|
||||||
|
if (Baz("hello").s != "hello!") return "fail3"
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
+11
@@ -14,3 +14,14 @@ class Scope {
|
|||||||
fun Scope.bar(e: Foo) {
|
fun Scope.bar(e: Foo) {
|
||||||
e.test {}
|
e.test {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Baz
|
||||||
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
@kotlin.internal.LowPriorityInOverloadResolution
|
||||||
|
constructor(val x: Foo)
|
||||||
|
|
||||||
|
fun Baz(x: Foo): Baz {
|
||||||
|
throw NotImplementedError()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testBaz(e: Foo) = Baz(e)
|
||||||
|
|||||||
+11
@@ -1,5 +1,7 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
|
public fun Baz(/*0*/ x: Foo): Baz
|
||||||
|
public fun testBaz(/*0*/ e: Foo): Baz
|
||||||
public fun Scope.bar(/*0*/ e: Foo): kotlin.Unit
|
public fun Scope.bar(/*0*/ e: Foo): kotlin.Unit
|
||||||
public fun Foo.test(): kotlin.Unit
|
public fun Foo.test(): kotlin.Unit
|
||||||
|
|
||||||
@@ -10,6 +12,14 @@ public final class Bar {
|
|||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class Baz {
|
||||||
|
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) @kotlin.internal.LowPriorityInOverloadResolution public constructor Baz(/*0*/ x: Foo)
|
||||||
|
public final val x: Foo
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
public final class Foo {
|
public final class Foo {
|
||||||
public constructor Foo()
|
public constructor Foo()
|
||||||
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) @kotlin.internal.LowPriorityInOverloadResolution public final val test: Bar
|
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) @kotlin.internal.LowPriorityInOverloadResolution public final val test: Bar
|
||||||
@@ -25,3 +35,4 @@ public final class Scope {
|
|||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
public final operator fun Bar.invoke(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
public final operator fun Bar.invoke(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ internal annotation class Exact
|
|||||||
/**
|
/**
|
||||||
* Specifies that a corresponding member has the lowest priority in overload resolution.
|
* Specifies that a corresponding member has the lowest priority in overload resolution.
|
||||||
*/
|
*/
|
||||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
|
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR)
|
||||||
@Retention(AnnotationRetention.BINARY)
|
@Retention(AnnotationRetention.BINARY)
|
||||||
internal annotation class LowPriorityInOverloadResolution
|
internal annotation class LowPriorityInOverloadResolution
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user