FIR: Add workaround for OverloadResolutionByLambdaReturnType
Mostly, that should help for existing flatMap usages ^KT-43129 Submitted
This commit is contained in:
Vendored
-41
@@ -1,41 +0,0 @@
|
||||
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
// FILE: OverloadResolutionByLambdaReturnType.kt
|
||||
|
||||
package kotlin
|
||||
|
||||
annotation class OverloadResolutionByLambdaReturnType
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import kotlin.OverloadResolutionByLambdaReturnType
|
||||
|
||||
@kotlin.jvm.JvmName("myFlatMapIterable")
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
fun <T, R> Sequence<T>.myFlatMap(transform: (T) -> Iterable<R>): Sequence<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun <T, R> Sequence<T>.myFlatMap(transform: (T) -> Sequence<R>): Sequence<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
interface A {
|
||||
val supertypes: Collection<B>
|
||||
}
|
||||
|
||||
interface B {
|
||||
val descriptors: Sequence<C>?
|
||||
}
|
||||
|
||||
interface C
|
||||
|
||||
fun <K : Any> elvis(x: K?, y: K): K = y
|
||||
|
||||
fun test(a: A) {
|
||||
a.supertypes.asSequence().<!AMBIGUITY!>myFlatMap<!> {
|
||||
<!INAPPLICABLE_CANDIDATE!>elvis<!>(<!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>descriptors<!>, sequenceOf())
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS
|
||||
// ISSUE: KT-11265
|
||||
|
||||
// FILE: OverloadResolutionByLambdaReturnType.kt
|
||||
|
||||
package kotlin
|
||||
|
||||
annotation class OverloadResolutionByLambdaReturnType
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import kotlin.OverloadResolutionByLambdaReturnType
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
fun <R> UByteArray.fooMap(t: (UByte) -> Iterable<R>): List<R> {
|
||||
TODO("ub.fm")
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
fun <T, R> Iterable<T>.fooMap(t: (T) -> Iterable<R>): List<R> {
|
||||
TODO("i.fm(i)")
|
||||
}
|
||||
|
||||
@JvmName("fooMapSeq")
|
||||
fun <T, R> Iterable<T>.fooMap(t: (T) -> Sequence<R>): List<R> {
|
||||
TODO("i.fm(s)")
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val list = ubyteArrayOf(0u).<!AMBIGUITY!>fooMap<!> { <!NONE_APPLICABLE!>listOf<!>(<!UNRESOLVED_REFERENCE!>it<!>) }
|
||||
takeUByteList(list)
|
||||
}
|
||||
|
||||
fun takeUByteList(list: List<UByte>) {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS
|
||||
// ISSUE: KT-11265
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS
|
||||
// ISSUE: KT-11265
|
||||
|
||||
// FILE: OverloadResolutionByLambdaReturnType.kt
|
||||
|
||||
package kotlin
|
||||
|
||||
annotation class OverloadResolutionByLambdaReturnType
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import kotlin.OverloadResolutionByLambdaReturnType
|
||||
|
||||
public inline fun <T, R> Iterable<T>.myFlatMap(transform: (T) -> Iterable<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("myFlatMapSequence")
|
||||
public inline fun <T, R> Iterable<T>.myFlatMap(transform: (T) -> Sequence<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
interface Name
|
||||
interface DeclarationDescriptor {
|
||||
val nextCandidates: List<DeclarationDescriptor>?
|
||||
val nextCandidatesSeq: Sequence<DeclarationDescriptor>?
|
||||
val name: Name
|
||||
}
|
||||
|
||||
fun test_1(name: Name, toplevelDescriptors: List<DeclarationDescriptor>): List<DeclarationDescriptor> {
|
||||
val candidates = toplevelDescriptors.<!AMBIGUITY!>myFlatMap<!> { container ->
|
||||
val nextCandidates = container.<!UNRESOLVED_REFERENCE!>nextCandidates<!> ?: return@myFlatMap emptyList()
|
||||
nextCandidates
|
||||
}
|
||||
return candidates
|
||||
}
|
||||
|
||||
fun test_2(name: Name, toplevelDescriptors: List<DeclarationDescriptor>): List<DeclarationDescriptor> {
|
||||
val candidates = toplevelDescriptors.<!AMBIGUITY!>myFlatMap<!> { container ->
|
||||
val nextCandidates = container.<!UNRESOLVED_REFERENCE!>nextCandidatesSeq<!> ?: return@myFlatMap sequenceOf()
|
||||
nextCandidates
|
||||
}
|
||||
return candidates
|
||||
}
|
||||
|
||||
fun test_3(name: Name, toplevelDescriptors: List<DeclarationDescriptor>): List<DeclarationDescriptor> {
|
||||
val candidates = toplevelDescriptors.<!AMBIGUITY!>myFlatMap<!> { container ->
|
||||
val nextCandidates = container.<!UNRESOLVED_REFERENCE!>nextCandidatesSeq<!>!!
|
||||
nextCandidates
|
||||
}
|
||||
return candidates
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS
|
||||
// ISSUE: KT-11265
|
||||
|
||||
+8
-8
@@ -20,17 +20,17 @@ fun takeString(s: String) {}
|
||||
fun takeInt(s: Int) {}
|
||||
|
||||
fun test_1() {
|
||||
val x = <!AMBIGUITY!>create<!> { "" }
|
||||
val x = create { "" }
|
||||
takeString(x)
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
val x = <!AMBIGUITY!>create<!> { 1 }
|
||||
takeInt(x)
|
||||
val x = create { 1 }
|
||||
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
val x = <!AMBIGUITY!>create<!> { 1.0 }
|
||||
val x = create { 1.0 }
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@@ -38,11 +38,11 @@ fun <K> create(x: K, f: (K) -> Int): Int = 1
|
||||
fun <T> create(x: T, f: (T) -> String): String = ""
|
||||
|
||||
fun test_4() {
|
||||
val x = <!AMBIGUITY!>create<!>("") { "" }
|
||||
val x = create("") { "" }
|
||||
takeString(x)
|
||||
}
|
||||
|
||||
fun test_5() {
|
||||
val x = <!AMBIGUITY!>create<!>("") { 1 }
|
||||
takeInt(x)
|
||||
}
|
||||
val x = create("") { 1 }
|
||||
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
|
||||
}
|
||||
|
||||
+8
-8
@@ -20,17 +20,17 @@ fun takeString(s: String) {}
|
||||
fun takeInt(s: Int) {}
|
||||
|
||||
fun test_1() {
|
||||
val x = <!AMBIGUITY!>create<!> { "" }
|
||||
val x = create { "" }
|
||||
takeString(x)
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
val x = <!AMBIGUITY!>create<!> { 1 }
|
||||
takeInt(x)
|
||||
val x = create { 1 }
|
||||
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
val x = <!AMBIGUITY!>create<!> { 1.0 }
|
||||
val x = create { 1.0 }
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@@ -38,13 +38,13 @@ fun <K> create(x: K, f: (K) -> Int): Int = 1
|
||||
fun <T> create(x: T, f: (T) -> String): String = ""
|
||||
|
||||
fun test_4() {
|
||||
val x = <!AMBIGUITY!>create<!>("") { "" }
|
||||
val x = create("") { "" }
|
||||
takeString(x)
|
||||
}
|
||||
|
||||
fun test_5() {
|
||||
val x = <!AMBIGUITY!>create<!>("") { 1 }
|
||||
takeInt(x)
|
||||
val x = create("") { 1 }
|
||||
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
|
||||
}
|
||||
|
||||
interface A
|
||||
@@ -56,6 +56,6 @@ fun foo(f: () -> A): Int = 1
|
||||
fun foo(f: () -> B): String = ""
|
||||
|
||||
fun test_6(c: C) {
|
||||
val x = <!AMBIGUITY!>foo<!> { c }
|
||||
val x = foo { c }
|
||||
takeString(x)
|
||||
}
|
||||
|
||||
Vendored
-24
@@ -1,24 +0,0 @@
|
||||
// !LANGUAGE: -NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
// FILE: OverloadResolutionByLambdaReturnType.kt
|
||||
|
||||
package kotlin
|
||||
|
||||
annotation class OverloadResolutionByLambdaReturnType
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import kotlin.OverloadResolutionByLambdaReturnType
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
fun create(f: (Int) -> Int): Int = 1
|
||||
fun create(f: (Int) -> String): String = ""
|
||||
|
||||
fun takeString(s: String) {}
|
||||
|
||||
fun test_1() {
|
||||
val x = <!AMBIGUITY!>create<!> { "" }
|
||||
takeString("")
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// ISSUE: KT-11265
|
||||
|
||||
+6
-6
@@ -25,10 +25,10 @@ inline fun <T, R> Array<out T>.myFlatMap(transform: (T) -> Sequence<R>): List<R>
|
||||
fun String.toList(): List<String> = null!!
|
||||
|
||||
fun test_1(a: Array<String>, b: Boolean) {
|
||||
a.<!AMBIGUITY!>myFlatMap<!> { <!UNRESOLVED_REFERENCE!>it<!>.toList().ifEmpty { return } }
|
||||
a.<!AMBIGUITY!>myFlatMap<!> {
|
||||
a.myFlatMap { it.toList().ifEmpty { return } }
|
||||
a.myFlatMap {
|
||||
if (b) return
|
||||
<!UNRESOLVED_REFERENCE!>it<!>.toList()
|
||||
it.toList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ fun <T, R> Array<out T>.noInlineFlatMap(transform: (T) -> Sequence<R>): List<R>
|
||||
}
|
||||
|
||||
fun test_2(a: Array<String>, b: Boolean) {
|
||||
a.<!AMBIGUITY!>noInlineFlatMap<!> { <!UNRESOLVED_REFERENCE!>it<!>.toList().ifEmpty { return } }
|
||||
a.<!AMBIGUITY!>noInlineFlatMap<!> {
|
||||
a.noInlineFlatMap { it.toList().ifEmpty { return } }
|
||||
a.noInlineFlatMap {
|
||||
if (b) return
|
||||
<!UNRESOLVED_REFERENCE!>it<!>.toList()
|
||||
it.toList()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user