[NI] Analyse lambda in factory pattern resolution in independent context

This commit is contained in:
Dmitriy Novozhilov
2020-04-24 13:14:12 +03:00
parent a0c7bece93
commit e7869bd9d4
10 changed files with 144 additions and 6 deletions
@@ -0,0 +1,41 @@
// !LANGUAGE: +NewInference +FactoryPatternResolution
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
// ISSUE: KT-11265
// FILE: FactoryPattern.kt
package annotations
annotation class FactoryPattern
// FILE: main.kt
import annotations.FactoryPattern
@kotlin.jvm.JvmName("myFlatMapIterable")
@FactoryPattern
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().myFlatMap {
elvis(it.descriptors, sequenceOf())
}
}