[FIR] Add checking receivers of callable references
This commit is contained in:
Vendored
+7
@@ -0,0 +1,7 @@
|
|||||||
|
fun test_1(a: String, s: String) {
|
||||||
|
val pair = s.let(a::to)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test_2(a: String, s: String) {
|
||||||
|
val pair = s.let { a.to(it) }
|
||||||
|
}
|
||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
FILE: genericInReceiver.kt
|
||||||
|
public final fun test_1(a: R|kotlin/String|, s: R|kotlin/String|): R|kotlin/Unit| {
|
||||||
|
lval pair: R|kotlin/Pair<kotlin/String, kotlin/String>| = R|<local>/s|.R|kotlin/let|<R|kotlin/String|, R|kotlin/Pair<kotlin/String, kotlin/String>|>(R|<local>/a|::R|kotlin/to<kotlin/String, kotlin/String>|)
|
||||||
|
}
|
||||||
|
public final fun test_2(a: R|kotlin/String|, s: R|kotlin/String|): R|kotlin/Unit| {
|
||||||
|
lval pair: R|kotlin/Pair<kotlin/String, kotlin/String>| = R|<local>/s|.R|kotlin/let|<R|kotlin/String|, R|kotlin/Pair<kotlin/String, kotlin/String>|>(<L> = let@fun <anonymous>(it: R|kotlin/String|): R|kotlin/Pair<kotlin/String, kotlin/String>| <kind=EXACTLY_ONCE> {
|
||||||
|
^ R|<local>/a|.R|kotlin/to|<R|kotlin/String|, R|kotlin/String|>(R|<local>/it|)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+5
@@ -310,6 +310,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/extensionReceiverInference.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/extensionReceiverInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericInReceiver.kt")
|
||||||
|
public void testGenericInReceiver() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/genericInReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ifWithCR.kt")
|
@TestMetadata("ifWithCR.kt")
|
||||||
public void testIfWithCR() throws Exception {
|
public void testIfWithCR() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/ifWithCR.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/ifWithCR.kt");
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ enum class CallKind(vararg resolutionSequence: ResolutionStage) {
|
|||||||
DiscriminateSynthetics,
|
DiscriminateSynthetics,
|
||||||
NoTypeArguments,
|
NoTypeArguments,
|
||||||
CreateFreshTypeVariableSubstitutorStage,
|
CreateFreshTypeVariableSubstitutorStage,
|
||||||
|
CheckReceivers.Dispatch,
|
||||||
|
CheckReceivers.Extension,
|
||||||
CheckCallableReferenceExpectedType
|
CheckCallableReferenceExpectedType
|
||||||
),
|
),
|
||||||
SyntheticIdForCallableReferencesResolution(
|
SyntheticIdForCallableReferencesResolution(
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
inline class Z(val x: Int)
|
inline class Z(val x: Int)
|
||||||
|
|||||||
Vendored
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
inline class Z(val x: Int)
|
inline class Z(val x: Int)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// MODULE: lib
|
// MODULE: lib
|
||||||
// FILE: common.kt
|
// FILE: common.kt
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
// KT-12630 KotlinReflectionInternalError on referencing some functions from stdlib
|
// KT-12630 KotlinReflectionInternalError on referencing some functions from stdlib
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
-3
@@ -6,10 +6,10 @@ public interface J {
|
|||||||
|
|
||||||
// FILE: test.kt
|
// FILE: test.kt
|
||||||
|
|
||||||
fun f1(x: Int?): Any = x::hashCode
|
fun f1(x: Int?): Any = <!UNRESOLVED_REFERENCE!>x::hashCode<!>
|
||||||
fun <T> f2(t: T): Any = t::hashCode
|
fun <T> f2(t: T): Any = t::hashCode
|
||||||
fun <S : String?> f3(s: S): Any = s::hashCode
|
fun <S : String?> f3(s: S): Any = s::hashCode
|
||||||
fun <U : Any> f4(u: U?): Any = u::hashCode
|
fun <U : Any> f4(u: U?): Any = <!UNRESOLVED_REFERENCE!>u::hashCode<!>
|
||||||
fun f5(c: List<*>): Any = c[0]::hashCode
|
fun f5(c: List<*>): Any = <!UNRESOLVED_REFERENCE!>c[0]::hashCode<!>
|
||||||
|
|
||||||
fun f6(j: J): Any = j.platformString()::hashCode
|
fun f6(j: J): Any = j.platformString()::hashCode
|
||||||
|
|||||||
Vendored
+3
-3
@@ -18,9 +18,9 @@ class Test {
|
|||||||
val <T> List<T>.b: Int? get() = size
|
val <T> List<T>.b: Int? get() = size
|
||||||
|
|
||||||
fun <T> List<T>.testCallable1(): () -> Unit = a<T>::foo
|
fun <T> List<T>.testCallable1(): () -> Unit = a<T>::foo
|
||||||
fun <T> List<T>.testCallable2(): () -> Unit = b?::foo
|
fun <T> List<T>.testCallable2(): () -> Unit = <!UNRESOLVED_REFERENCE!>b?::foo<!>
|
||||||
fun <T> List<T>.testCallable3(): () -> Unit = b<T, Any>::foo
|
fun <T> List<T>.testCallable3(): () -> Unit = <!UNRESOLVED_REFERENCE!>b<T, Any>::foo<!>
|
||||||
fun <T> List<T>.testCallable4(): () -> Unit = b<T>?::foo
|
fun <T> List<T>.testCallable4(): () -> Unit = <!UNRESOLVED_REFERENCE!>b<T>?::foo<!>
|
||||||
|
|
||||||
fun <T> List<T>.testClassLiteral1() = a<T>::class
|
fun <T> List<T>.testClassLiteral1() = a<T>::class
|
||||||
fun <T> List<T>.testClassLiteral2() = b?::class
|
fun <T> List<T>.testClassLiteral2() = b?::class
|
||||||
|
|||||||
Vendored
+1
-1
@@ -4,4 +4,4 @@ package test
|
|||||||
fun nullableFun(): Int? = null
|
fun nullableFun(): Int? = null
|
||||||
fun Int.foo() {}
|
fun Int.foo() {}
|
||||||
|
|
||||||
val test1 = nullableFun()?::foo
|
val test1 = <!UNRESOLVED_REFERENCE!>nullableFun()?::foo<!>
|
||||||
Vendored
+2
-2
@@ -4,10 +4,10 @@ class A {
|
|||||||
fun A.extA(x: String) = x
|
fun A.extA(x: String) = x
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
Int::extInt
|
<!UNRESOLVED_REFERENCE!>Int::extInt<!>
|
||||||
A::extA
|
A::extA
|
||||||
|
|
||||||
eat(Int::extInt)
|
<!INAPPLICABLE_CANDIDATE!>eat<!>(<!UNRESOLVED_REFERENCE!>Int::extInt<!>)
|
||||||
eat(A::extA)
|
eat(A::extA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -15,11 +15,11 @@ class A {
|
|||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
String::ext
|
String::ext
|
||||||
Obj::ext
|
<!UNRESOLVED_REFERENCE!>Obj::ext<!>
|
||||||
|
|
||||||
String::ext2
|
String::ext2
|
||||||
A.Companion::ext2
|
<!UNRESOLVED_REFERENCE!>A.Companion::ext2<!>
|
||||||
A::ext2
|
<!UNRESOLVED_REFERENCE!>A::ext2<!>
|
||||||
|
|
||||||
<!UNRESOLVED_REFERENCE!>A::foo<!>
|
<!UNRESOLVED_REFERENCE!>A::foo<!>
|
||||||
<!UNRESOLVED_REFERENCE!>A::bar<!>
|
<!UNRESOLVED_REFERENCE!>A::bar<!>
|
||||||
|
|||||||
Reference in New Issue
Block a user