[NI] Fix checking for inline lambdas without candidate
#KT-34506
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
// !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
|
||||
|
||||
inline fun <T, R> Array<out T>.myFlatMap(transform: (T) -> Iterable<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@JvmName("seqFlatMap")
|
||||
inline fun <T, R> Array<out T>.myFlatMap(transform: (T) -> Sequence<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
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<!> {
|
||||
if (b) return
|
||||
<!UNRESOLVED_REFERENCE!>it<!>.toList()
|
||||
}
|
||||
}
|
||||
|
||||
fun <T, R> Array<out T>.noInlineFlatMap(transform: (T) -> Iterable<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@JvmName("noInlineSeqFlatMap")
|
||||
fun <T, R> Array<out T>.noInlineFlatMap(transform: (T) -> Sequence<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun test_2(a: Array<String>, b: Boolean) {
|
||||
a.<!AMBIGUITY!>noInlineFlatMap<!> { <!UNRESOLVED_REFERENCE!>it<!>.toList().ifEmpty { return } }
|
||||
a.<!AMBIGUITY!>noInlineFlatMap<!> {
|
||||
if (b) return
|
||||
<!UNRESOLVED_REFERENCE!>it<!>.toList()
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// !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
|
||||
|
||||
inline fun <T, R> Array<out T>.myFlatMap(transform: (T) -> Iterable<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@JvmName("seqFlatMap")
|
||||
inline fun <T, R> Array<out T>.myFlatMap(transform: (T) -> Sequence<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun String.toList(): List<String> = null!!
|
||||
|
||||
fun test_1(a: Array<String>, b: Boolean) {
|
||||
a.myFlatMap { it.toList().ifEmpty { return } }
|
||||
a.myFlatMap {
|
||||
if (b) return
|
||||
it.toList()
|
||||
}
|
||||
}
|
||||
|
||||
fun <T, R> Array<out T>.noInlineFlatMap(transform: (T) -> Iterable<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@JvmName("noInlineSeqFlatMap")
|
||||
fun <T, R> Array<out T>.noInlineFlatMap(transform: (T) -> Sequence<R>): List<R> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun test_2(a: Array<String>, b: Boolean) {
|
||||
a.noInlineFlatMap { it.toList().ifEmpty { <!RETURN_NOT_ALLOWED!>return<!> } }
|
||||
a.noInlineFlatMap {
|
||||
if (b) <!RETURN_NOT_ALLOWED!>return<!>
|
||||
it.toList()
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun test_1(/*0*/ a: kotlin.Array<kotlin.String>, /*1*/ b: kotlin.Boolean): kotlin.Unit
|
||||
public fun test_2(/*0*/ a: kotlin.Array<kotlin.String>, /*1*/ b: kotlin.Boolean): kotlin.Unit
|
||||
public inline fun </*0*/ T, /*1*/ R> kotlin.Array<out T>.myFlatMap(/*0*/ transform: (T) -> kotlin.collections.Iterable<R>): kotlin.collections.List<R>
|
||||
@kotlin.OverloadResolutionByLambdaReturnType @kotlin.jvm.JvmName(name = "seqFlatMap") public inline fun </*0*/ T, /*1*/ R> kotlin.Array<out T>.myFlatMap(/*0*/ transform: (T) -> kotlin.sequences.Sequence<R>): kotlin.collections.List<R>
|
||||
public fun </*0*/ T, /*1*/ R> kotlin.Array<out T>.noInlineFlatMap(/*0*/ transform: (T) -> kotlin.collections.Iterable<R>): kotlin.collections.List<R>
|
||||
@kotlin.OverloadResolutionByLambdaReturnType @kotlin.jvm.JvmName(name = "noInlineSeqFlatMap") public fun </*0*/ T, /*1*/ R> kotlin.Array<out T>.noInlineFlatMap(/*0*/ transform: (T) -> kotlin.sequences.Sequence<R>): kotlin.collections.List<R>
|
||||
public fun kotlin.String.toList(): kotlin.collections.List<kotlin.String>
|
||||
|
||||
package kotlin {
|
||||
|
||||
public final annotation class OverloadResolutionByLambdaReturnType : kotlin.Annotation {
|
||||
public constructor OverloadResolutionByLambdaReturnType()
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user