Fix rewrite at slice exception for callable references inside flatMap

#KT-40254 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-07-13 15:45:50 +03:00
parent 1e4c554bcd
commit 09b44b3189
7 changed files with 48 additions and 5 deletions
@@ -0,0 +1,10 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
// WITH_RUNTIME
fun <T> List<Option<T>>.flatten(): List<T> = <!AMBIGUITY!>flatMap<!> { <!UNRESOLVED_REFERENCE!>it<!>.<!INAPPLICABLE_CANDIDATE!>fold<!>(::emptyList, <!UNRESOLVED_REFERENCE!>::listOf<!>) }
class Option<out T> {
fun <R> fold(ifEmpty: () -> R, ifSome: (T) -> R): R = TODO()
}
@@ -0,0 +1,10 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
// WITH_RUNTIME
fun <T> List<Option<T>>.flatten(): List<T> = flatMap { it.fold(::emptyList, ::listOf) }
class Option<out T> {
fun <R> fold(ifEmpty: () -> R, ifSome: (T) -> R): R = TODO()
}
@@ -0,0 +1,11 @@
package
public fun </*0*/ T> kotlin.collections.List<Option<T>>.flatten(): kotlin.collections.List<T>
public final class Option</*0*/ out T> {
public constructor Option</*0*/ out T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun </*0*/ R> fold(/*0*/ ifEmpty: () -> R, /*1*/ ifSome: (T) -> R): R
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}