[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().<!AMBIGUITY!>myFlatMap<!> {
<!INAPPLICABLE_CANDIDATE!>elvis<!>(<!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>descriptors<!>, sequenceOf())
}
}
@@ -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())
}
}
@@ -0,0 +1,36 @@
package
public fun </*0*/ K : kotlin.Any> elvis(/*0*/ x: K?, /*1*/ y: K): K
public fun test(/*0*/ a: A): kotlin.Unit
@kotlin.jvm.JvmName(name = "myFlatMapIterable") @annotations.FactoryPattern public fun </*0*/ T, /*1*/ R> kotlin.sequences.Sequence<T>.myFlatMap(/*0*/ transform: (T) -> kotlin.collections.Iterable<R>): kotlin.sequences.Sequence<R>
public fun </*0*/ T, /*1*/ R> kotlin.sequences.Sequence<T>.myFlatMap(/*0*/ transform: (T) -> kotlin.sequences.Sequence<R>): kotlin.sequences.Sequence<R>
public interface A {
public abstract val supertypes: kotlin.collections.Collection<B>
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 B {
public abstract val descriptors: kotlin.sequences.Sequence<C>?
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 C {
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 annotations {
public final annotation class FactoryPattern : kotlin.Annotation {
public constructor FactoryPattern()
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
}
}