[NI] Use types and systems from return arguments instead of return type of lambda
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
// !LANGUAGE: +NewInference +FactoryPatternResolution
|
||||
// !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
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// !LANGUAGE: +NewInference +FactoryPatternResolution
|
||||
// !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.myFlatMap { container ->
|
||||
val nextCandidates = container.nextCandidates ?: return@myFlatMap emptyList()
|
||||
nextCandidates
|
||||
}
|
||||
return candidates
|
||||
}
|
||||
|
||||
fun test_2(name: Name, toplevelDescriptors: List<DeclarationDescriptor>): List<DeclarationDescriptor> {
|
||||
val candidates = toplevelDescriptors.myFlatMap { container ->
|
||||
val nextCandidates = container.nextCandidatesSeq ?: return@myFlatMap sequenceOf()
|
||||
nextCandidates
|
||||
}
|
||||
return candidates
|
||||
}
|
||||
|
||||
fun test_3(name: Name, toplevelDescriptors: List<DeclarationDescriptor>): List<DeclarationDescriptor> {
|
||||
val candidates = toplevelDescriptors.myFlatMap { container ->
|
||||
val nextCandidates = container.nextCandidatesSeq!!
|
||||
nextCandidates
|
||||
}
|
||||
return candidates
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
public fun test_1(/*0*/ name: Name, /*1*/ toplevelDescriptors: kotlin.collections.List<DeclarationDescriptor>): kotlin.collections.List<DeclarationDescriptor>
|
||||
public fun test_2(/*0*/ name: Name, /*1*/ toplevelDescriptors: kotlin.collections.List<DeclarationDescriptor>): kotlin.collections.List<DeclarationDescriptor>
|
||||
public fun test_3(/*0*/ name: Name, /*1*/ toplevelDescriptors: kotlin.collections.List<DeclarationDescriptor>): kotlin.collections.List<DeclarationDescriptor>
|
||||
public inline fun </*0*/ T, /*1*/ R> kotlin.collections.Iterable<T>.myFlatMap(/*0*/ transform: (T) -> kotlin.collections.Iterable<R>): kotlin.collections.List<R>
|
||||
@kotlin.OverloadResolutionByLambdaReturnType @kotlin.jvm.JvmName(name = "myFlatMapSequence") public inline fun </*0*/ T, /*1*/ R> kotlin.collections.Iterable<T>.myFlatMap(/*0*/ transform: (T) -> kotlin.sequences.Sequence<R>): kotlin.collections.List<R>
|
||||
|
||||
public interface DeclarationDescriptor {
|
||||
public abstract val name: Name
|
||||
public abstract val nextCandidates: kotlin.collections.List<DeclarationDescriptor>?
|
||||
public abstract val nextCandidatesSeq: kotlin.sequences.Sequence<DeclarationDescriptor>?
|
||||
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 interface Name {
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -30,7 +30,7 @@ fun test_2() {
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
val x = <!CANDIDATE_CHOSEN_USING_OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION!>create <!TYPE_MISMATCH!>{ <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.0<!> }<!><!>
|
||||
val x = <!CANDIDATE_CHOSEN_USING_OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION!>create { <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.0<!> }<!>
|
||||
}
|
||||
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
|
||||
Reference in New Issue
Block a user