[FIR] Implement ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE diagnostic
#KT-59401 Fixed
This commit is contained in:
committed by
Space Team
parent
d91000e39c
commit
789f886d3c
Vendored
+2
-2
@@ -3,12 +3,12 @@ fun foo(x: String = "O"): String = x
|
||||
fun bar(x: String = "K"): String = x
|
||||
|
||||
fun dump(dumpStrategy: String) {
|
||||
val k0: kotlin.reflect.KFunction0<String> = returnAdapter(::<!INAPPLICABLE_CANDIDATE!>foo<!>) // Error: ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE
|
||||
val k0: kotlin.reflect.KFunction0<String> = returnAdapter(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>::foo<!>) // Error: ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE
|
||||
val k1: kotlin.reflect.KFunction0<String> = <!INITIALIZER_TYPE_MISMATCH!>::foo<!>
|
||||
// Should be error here, too
|
||||
val k2: kotlin.reflect.KFunction0<String> = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>if (dumpStrategy == "KotlinLike") ::foo else ::bar<!>
|
||||
|
||||
val f0: Function0<String> = returnAdapter(::<!INAPPLICABLE_CANDIDATE!>foo<!>)
|
||||
val f0: Function0<String> = returnAdapter(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>::foo<!>)
|
||||
val f1: Function0<String> = ::foo
|
||||
val f2: Function0<String> = if (dumpStrategy == "KotlinLike") ::foo else ::bar
|
||||
}
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// !LANGUAGE: -AdaptedCallableReferenceAgainstReflectiveType +DisableCompatibilityModeForNewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
fun foo(x: Int): Unit {} // (1)
|
||||
fun bar(f: KFunction1<Int, Unit>) {}
|
||||
|
||||
fun test() {
|
||||
bar(::foo) // OK, foo resolved to (1)
|
||||
}
|
||||
|
||||
object Scope {
|
||||
fun foo(x: Int, y: Int = 0): Int = 0 // (2)
|
||||
|
||||
fun test() {
|
||||
bar(::foo) // Error and foo should be resolved to (2)
|
||||
}
|
||||
}
|
||||
|
||||
object Local {
|
||||
fun baz(x: Int, y: Int = 0): Int = 0
|
||||
|
||||
fun test() {
|
||||
bar(::<!INAPPLICABLE_CANDIDATE!>baz<!>)
|
||||
}
|
||||
}
|
||||
+10
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -AdaptedCallableReferenceAgainstReflectiveType +DisableCompatibilityModeForNewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@@ -15,6 +16,7 @@ object Scope {
|
||||
|
||||
fun test() {
|
||||
bar(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>::foo<!>) // Error and foo should be resolved to (2)
|
||||
bar(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>Scope::foo<!>) // Error and foo should be resolved to (2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,3 +27,11 @@ object Local {
|
||||
bar(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>::baz<!>)
|
||||
}
|
||||
}
|
||||
|
||||
object WrongType {
|
||||
fun foo(x: String, y: Int = 0) {} // (3)
|
||||
|
||||
fun test() {
|
||||
bar(::foo) // Should resolve to (1) because (3) has wrong type on top of being adapted
|
||||
}
|
||||
}
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ f: kotlin.reflect.KFunction1<kotlin.Int, kotlin.Unit>): kotlin.Unit
|
||||
public fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public object Local {
|
||||
private constructor Local()
|
||||
public final fun baz(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): kotlin.Int
|
||||
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 final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Scope {
|
||||
private constructor Scope()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+10
-1
@@ -15,6 +15,7 @@ object Scope {
|
||||
|
||||
fun test() {
|
||||
bar(::foo)
|
||||
bar(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>Scope::foo<!>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +23,14 @@ object Local {
|
||||
fun baz(x: Int, y: Int = 0): Int = 0
|
||||
|
||||
fun test() {
|
||||
bar(::<!INAPPLICABLE_CANDIDATE!>baz<!>)
|
||||
bar(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>::baz<!>)
|
||||
}
|
||||
}
|
||||
|
||||
object WrongType {
|
||||
fun foo(x: String, y: Int = 0) {} // (3)
|
||||
|
||||
fun test() {
|
||||
bar(::foo) // Should resolve to (1) because (3) has wrong type on top of being adapted
|
||||
}
|
||||
}
|
||||
+9
@@ -15,6 +15,7 @@ object Scope {
|
||||
|
||||
fun test() {
|
||||
bar(<!COMPATIBILITY_WARNING!>::foo<!>)
|
||||
bar(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>Scope::foo<!>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,3 +26,11 @@ object Local {
|
||||
bar(<!ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE!>::baz<!>)
|
||||
}
|
||||
}
|
||||
|
||||
object WrongType {
|
||||
fun foo(x: String, y: Int = 0) {} // (3)
|
||||
|
||||
fun test() {
|
||||
bar(::foo) // Should resolve to (1) because (3) has wrong type on top of being adapted
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ f: kotlin.reflect.KFunction1<kotlin.Int, kotlin.Unit>): kotlin.Unit
|
||||
public fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public object Local {
|
||||
private constructor Local()
|
||||
public final fun baz(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): kotlin.Int
|
||||
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 final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Scope {
|
||||
private constructor Scope()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user