FIR: Add workaround for OverloadResolutionByLambdaReturnType
Mostly, that should help for existing flatMap usages ^KT-43129 Submitted
This commit is contained in:
+3
-1
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.NoMutableState
|
|||||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeCallConflictResolverFactory
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeCallConflictResolverFactory
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeCompositeConflictResolver
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeCompositeConflictResolver
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeOverloadConflictResolver
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeOverloadConflictResolver
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeOverloadResolutionByLambdaConflictResolve
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents
|
import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents
|
||||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JvmTypeSpecificityComparator
|
import org.jetbrains.kotlin.resolve.jvm.JvmTypeSpecificityComparator
|
||||||
@@ -22,7 +23,8 @@ object JvmCallConflictResolverFactory : ConeCallConflictResolverFactory() {
|
|||||||
val specificityComparator = JvmTypeSpecificityComparator(components.ctx)
|
val specificityComparator = JvmTypeSpecificityComparator(components.ctx)
|
||||||
return ConeCompositeConflictResolver(
|
return ConeCompositeConflictResolver(
|
||||||
ConeOverloadConflictResolver(specificityComparator, components),
|
ConeOverloadConflictResolver(specificityComparator, components),
|
||||||
ConeEquivalentCallConflictResolver(specificityComparator, components)
|
ConeEquivalentCallConflictResolver(specificityComparator, components),
|
||||||
|
ConeOverloadResolutionByLambdaConflictResolve(components.session),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir.resolve.calls
|
package org.jetbrains.kotlin.fir.resolve.calls
|
||||||
|
|
||||||
class ConeCompositeConflictResolver(
|
class ConeCompositeConflictResolver(
|
||||||
private vararg val conflictResolvers: AbstractConeCallConflictResolver
|
private vararg val conflictResolvers: ConeCallConflictResolver
|
||||||
) : ConeCallConflictResolver() {
|
) : ConeCallConflictResolver() {
|
||||||
override fun chooseMaximallySpecificCandidates(
|
override fun chooseMaximallySpecificCandidates(
|
||||||
candidates: Set<Candidate>,
|
candidates: Set<Candidate>,
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.fir.resolve.calls
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.fqName
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION
|
||||||
|
|
||||||
|
class ConeOverloadResolutionByLambdaConflictResolve(private val session: FirSession) : ConeCallConflictResolver() {
|
||||||
|
override fun chooseMaximallySpecificCandidates(
|
||||||
|
candidates: Set<Candidate>,
|
||||||
|
discriminateGenerics: Boolean,
|
||||||
|
discriminateAbstracts: Boolean
|
||||||
|
): Set<Candidate> {
|
||||||
|
if (candidates.size == 1) return candidates
|
||||||
|
|
||||||
|
candidates.singleOrNull { candidate ->
|
||||||
|
(candidate.symbol.fir as? FirCallableDeclaration<*>)?.annotations?.any {
|
||||||
|
it.fqName(session) == OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION
|
||||||
|
} == true
|
||||||
|
}?.let {
|
||||||
|
return setOf(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
return candidates
|
||||||
|
}
|
||||||
|
}
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
// !LANGUAGE: +NewInference
|
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
||||||
// WITH_RUNTIME
|
|
||||||
|
|
||||||
|
|
||||||
fun <T> List<Option<T>>.flatten(): List<T> = <!AMBIGUITY!>flatMap<!> { <!UNRESOLVED_REFERENCE!>it<!>.<!NONE_APPLICABLE!>fold<!>(::emptyList, <!UNRESOLVED_REFERENCE!>::listOf<!>) }
|
|
||||||
|
|
||||||
class Option<out T> {
|
|
||||||
fun <R> fold(ifEmpty: () -> R, ifSome: (T) -> R): R = TODO()
|
|
||||||
}
|
|
||||||
compiler/testData/diagnostics/tests/callableReference/resolve/resolveTwoReferencesAgainstGenerics.kt
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// !LANGUAGE: +NewInference
|
// !LANGUAGE: +NewInference
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -3,18 +3,18 @@
|
|||||||
class A
|
class A
|
||||||
|
|
||||||
fun test_1(list: List<Set<A>>) {
|
fun test_1(list: List<Set<A>>) {
|
||||||
list.<!AMBIGUITY!>flatMapTo<!>(mutableSetOf()) { <!UNRESOLVED_REFERENCE!>it<!> }
|
list.flatMapTo(mutableSetOf()) { it }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_2(list: List<Set<A>>) {
|
fun test_2(list: List<Set<A>>) {
|
||||||
sequence<A> {
|
sequence<A> {
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Ambiguity: flatMapTo, [kotlin/collections/flatMapTo, kotlin/collections/flatMapTo]")!>list.<!AMBIGUITY!>flatMapTo<!>(mutableSetOf()) { <!UNRESOLVED_REFERENCE!>it<!> }<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.MutableSet<A>")!>list.flatMapTo(mutableSetOf()) { it }<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_3(list: List<Set<A>>) {
|
fun test_3(list: List<Set<A>>) {
|
||||||
sequence {
|
sequence {
|
||||||
list.<!AMBIGUITY!>flatMapTo<!>(mutableSetOf()) { <!UNRESOLVED_REFERENCE!>it<!> }
|
list.flatMapTo(mutableSetOf()) { it }
|
||||||
yield(A())
|
yield(A())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,6 @@ fun test_3(list: List<Set<A>>) {
|
|||||||
fun test_4(list: List<Set<A>>) {
|
fun test_4(list: List<Set<A>>) {
|
||||||
sequence {
|
sequence {
|
||||||
yield(A())
|
yield(A())
|
||||||
list.<!AMBIGUITY!>flatMapTo<!>(mutableSetOf()) { <!UNRESOLVED_REFERENCE!>it<!> }
|
list.flatMapTo(mutableSetOf()) { it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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
|
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||||
// ISSUE: KT-11265
|
// 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
|
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS
|
||||||
// ISSUE: KT-11265
|
// 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
|
// !LANGUAGE: +NewInference +OverloadResolutionByLambdaReturnType
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION -EXPERIMENTAL_API_USAGE -EXPERIMENTAL_UNSIGNED_LITERALS
|
||||||
// ISSUE: KT-11265
|
// ISSUE: KT-11265
|
||||||
|
|||||||
+7
-7
@@ -20,17 +20,17 @@ fun takeString(s: String) {}
|
|||||||
fun takeInt(s: Int) {}
|
fun takeInt(s: Int) {}
|
||||||
|
|
||||||
fun test_1() {
|
fun test_1() {
|
||||||
val x = <!AMBIGUITY!>create<!> { "" }
|
val x = create { "" }
|
||||||
takeString(x)
|
takeString(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_2() {
|
fun test_2() {
|
||||||
val x = <!AMBIGUITY!>create<!> { 1 }
|
val x = create { 1 }
|
||||||
takeInt(x)
|
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_3() {
|
fun test_3() {
|
||||||
val x = <!AMBIGUITY!>create<!> { 1.0 }
|
val x = create { 1.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@OverloadResolutionByLambdaReturnType
|
@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 <T> create(x: T, f: (T) -> String): String = ""
|
||||||
|
|
||||||
fun test_4() {
|
fun test_4() {
|
||||||
val x = <!AMBIGUITY!>create<!>("") { "" }
|
val x = create("") { "" }
|
||||||
takeString(x)
|
takeString(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_5() {
|
fun test_5() {
|
||||||
val x = <!AMBIGUITY!>create<!>("") { 1 }
|
val x = create("") { 1 }
|
||||||
takeInt(x)
|
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
|
||||||
}
|
}
|
||||||
+8
-8
@@ -20,17 +20,17 @@ fun takeString(s: String) {}
|
|||||||
fun takeInt(s: Int) {}
|
fun takeInt(s: Int) {}
|
||||||
|
|
||||||
fun test_1() {
|
fun test_1() {
|
||||||
val x = <!AMBIGUITY!>create<!> { "" }
|
val x = create { "" }
|
||||||
takeString(x)
|
takeString(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_2() {
|
fun test_2() {
|
||||||
val x = <!AMBIGUITY!>create<!> { 1 }
|
val x = create { 1 }
|
||||||
takeInt(x)
|
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_3() {
|
fun test_3() {
|
||||||
val x = <!AMBIGUITY!>create<!> { 1.0 }
|
val x = create { 1.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@OverloadResolutionByLambdaReturnType
|
@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 <T> create(x: T, f: (T) -> String): String = ""
|
||||||
|
|
||||||
fun test_4() {
|
fun test_4() {
|
||||||
val x = <!AMBIGUITY!>create<!>("") { "" }
|
val x = create("") { "" }
|
||||||
takeString(x)
|
takeString(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test_5() {
|
fun test_5() {
|
||||||
val x = <!AMBIGUITY!>create<!>("") { 1 }
|
val x = create("") { 1 }
|
||||||
takeInt(x)
|
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface A
|
interface A
|
||||||
@@ -56,6 +56,6 @@ fun foo(f: () -> A): Int = 1
|
|||||||
fun foo(f: () -> B): String = ""
|
fun foo(f: () -> B): String = ""
|
||||||
|
|
||||||
fun test_6(c: C) {
|
fun test_6(c: C) {
|
||||||
val x = <!AMBIGUITY!>foo<!> { c }
|
val x = foo { c }
|
||||||
takeString(x)
|
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
|
// !LANGUAGE: -NewInference
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||||
// ISSUE: KT-11265
|
// 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 String.toList(): List<String> = null!!
|
||||||
|
|
||||||
fun test_1(a: Array<String>, b: Boolean) {
|
fun test_1(a: Array<String>, b: Boolean) {
|
||||||
a.<!AMBIGUITY!>myFlatMap<!> { <!UNRESOLVED_REFERENCE!>it<!>.toList().ifEmpty { return } }
|
a.myFlatMap { it.toList().ifEmpty { return } }
|
||||||
a.<!AMBIGUITY!>myFlatMap<!> {
|
a.myFlatMap {
|
||||||
if (b) return
|
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) {
|
fun test_2(a: Array<String>, b: Boolean) {
|
||||||
a.<!AMBIGUITY!>noInlineFlatMap<!> { <!UNRESOLVED_REFERENCE!>it<!>.toList().ifEmpty { return } }
|
a.noInlineFlatMap { it.toList().ifEmpty { return } }
|
||||||
a.<!AMBIGUITY!>noInlineFlatMap<!> {
|
a.noInlineFlatMap {
|
||||||
if (b) return
|
if (b) return
|
||||||
<!UNRESOLVED_REFERENCE!>it<!>.toList()
|
it.toList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -23,21 +23,21 @@ val test3: MutableList<Int> =
|
|||||||
}
|
}
|
||||||
|
|
||||||
val test4: Collection<Int> =
|
val test4: Collection<Int> =
|
||||||
listOf(1, 2, 3).<!AMBIGUITY!>flatMapTo<!>(LinkedHashSet()) {
|
listOf(1, 2, 3).flatMapTo(LinkedHashSet()) {
|
||||||
<!NONE_APPLICABLE!>listOf<!>(<!UNRESOLVED_REFERENCE!>it<!>)
|
listOf(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
val test5: Collection<Int> =
|
val test5: Collection<Int> =
|
||||||
listOf(1, 2, 3).<!AMBIGUITY!>flatMapTo<!>(LinkedHashSet()) { // TODO
|
listOf(1, 2, 3).flatMapTo(LinkedHashSet()) { // TODO
|
||||||
if (true) <!NONE_APPLICABLE!>listOf<!>(<!UNRESOLVED_REFERENCE!>it<!>) else <!NONE_APPLICABLE!>listOf<!>(<!UNRESOLVED_REFERENCE!>it<!>)
|
if (true) listOf(it) else listOf(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
val test6: Collection<Int> =
|
val test6: Collection<Int> =
|
||||||
listOf(1, 2, 3).<!AMBIGUITY!>flatMapTo<!>(LinkedHashSet<Int>()) {
|
listOf(1, 2, 3).flatMapTo(LinkedHashSet<Int>()) {
|
||||||
if (true) <!NONE_APPLICABLE!>listOf<!>(<!UNRESOLVED_REFERENCE!>it<!>) else <!NONE_APPLICABLE!>listOf<!>(<!UNRESOLVED_REFERENCE!>it<!>)
|
if (true) listOf(it) else listOf(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
val test7: Collection<Int> =
|
val test7: Collection<Int> =
|
||||||
listOf(1, 2, 3).<!AMBIGUITY!>flatMapTo<!>(LinkedHashSet()) {
|
listOf(1, 2, 3).flatMapTo(LinkedHashSet()) {
|
||||||
<!INAPPLICABLE_CANDIDATE!>select<!>(<!NONE_APPLICABLE!>listOf<!>(<!UNRESOLVED_REFERENCE!>it<!>), <!NONE_APPLICABLE!>listOf<!>(<!UNRESOLVED_REFERENCE!>it<!>))
|
select(listOf(it), listOf(it))
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-8
@@ -4,12 +4,16 @@ FILE fqName:<root> fileName:/typeParametersInImplicitCast.kt
|
|||||||
VALUE_PARAMETER name:lss index:0 type:kotlin.collections.List<kotlin.collections.List<T of <root>.problematic>>
|
VALUE_PARAMETER name:lss index:0 type:kotlin.collections.List<kotlin.collections.List<T of <root>.problematic>>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='public final fun problematic <T> (lss: kotlin.collections.List<kotlin.collections.List<T of <root>.problematic>>): kotlin.collections.List<T of <root>.problematic> declared in <root>'
|
RETURN type=kotlin.Nothing from='public final fun problematic <T> (lss: kotlin.collections.List<kotlin.collections.List<T of <root>.problematic>>): kotlin.collections.List<T of <root>.problematic> declared in <root>'
|
||||||
ERROR_CALL 'Unresolved reference: <Ambiguity: flatMap, [kotlin/collections/flatMap, kotlin/collections/flatMap]>#' type=IrErrorType
|
CALL 'public final fun flatMap <T, R> (transform: kotlin.Function1<T of kotlin.collections.flatMap, kotlin.collections.Iterable<R of kotlin.collections.flatMap>>): kotlin.collections.List<R of kotlin.collections.flatMap> [inline] declared in kotlin.collections' type=kotlin.collections.List<T of <root>.problematic> origin=null
|
||||||
FUN_EXPR type=kotlin.Function0<kotlin.collections.List<kotlin.Any?>> origin=LAMBDA
|
<T>: kotlin.collections.List<T of <root>.problematic>
|
||||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.collections.List<kotlin.Any?>
|
<R>: T of <root>.problematic
|
||||||
|
$receiver: GET_VAR 'lss: kotlin.collections.List<kotlin.collections.List<T of <root>.problematic>> declared in <root>.problematic' type=kotlin.collections.List<kotlin.collections.List<T of <root>.problematic>> origin=null
|
||||||
|
transform: FUN_EXPR type=kotlin.Function1<kotlin.collections.List<T of <root>.problematic>, kotlin.collections.Iterable<T of <root>.problematic>> origin=LAMBDA
|
||||||
|
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.collections.List<T of <root>.problematic>) returnType:kotlin.collections.Iterable<T of <root>.problematic>
|
||||||
|
VALUE_PARAMETER name:it index:0 type:kotlin.collections.List<T of <root>.problematic>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.collections.List<kotlin.Any?> declared in <root>.problematic'
|
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.collections.List<T of <root>.problematic>): kotlin.collections.Iterable<T of <root>.problematic> declared in <root>.problematic'
|
||||||
TYPE_OP type=kotlin.collections.List<kotlin.Any?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<kotlin.Any?>
|
TYPE_OP type=kotlin.collections.List<T of <root>.problematic?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<T of <root>.problematic?>
|
||||||
CALL 'public/*package*/ open fun id <T> (v: kotlin.collections.List<T of <root>.ListId.id?>?): kotlin.collections.List<T of <root>.ListId.id?> declared in <root>.ListId' type=kotlin.collections.List<kotlin.Any?> origin=null
|
CALL 'public/*package*/ open fun id <T> (v: kotlin.collections.List<T of <root>.ListId.id?>?): kotlin.collections.List<T of <root>.ListId.id?> declared in <root>.ListId' type=kotlin.collections.List<T of <root>.problematic?> origin=null
|
||||||
<T>: kotlin.Any?
|
<T>: T of <root>.problematic?
|
||||||
v: ERROR_CALL 'Unresolved reference: <Unresolved name: it>#' type=IrErrorType
|
v: GET_VAR 'it: kotlin.collections.List<T of <root>.problematic> declared in <root>.problematic.<anonymous>' type=kotlin.collections.List<T of <root>.problematic> origin=null
|
||||||
|
|||||||
Reference in New Issue
Block a user