[NI] Relax rules for call completion: require at least one constraint

It's enough to have at least one good constraint.

 Note that the whole algorithm can be a bit more general:
 we could check also Out<T>, In<T> and verify that T has good only
 lower constraint or upper constraint, but there are questions for
 types like Inv<Out<T>>, where T should have lower and upper constraints

 #KT-31514 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-05-28 19:53:22 +03:00
parent 848640253a
commit f702417655
13 changed files with 94 additions and 8 deletions
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface Parent
interface Inv<T>
object Child : Parent
fun <K : Parent> wrapper(): Inv<K> = TODO()
fun <T : Parent> consume(wrapper: Inv<T>) {}
fun <S> select(x: S, y: S): S = x
fun error(f: Inv<out Parent>, w: Inv<Child>) {
consume(select(f, wrapper<Child>()))
}
@@ -0,0 +1,25 @@
package
public fun </*0*/ T : Parent> consume(/*0*/ wrapper: Inv<T>): kotlin.Unit
public fun error(/*0*/ f: Inv<out Parent>, /*1*/ w: Inv<Child>): kotlin.Unit
public fun </*0*/ S> select(/*0*/ x: S, /*1*/ y: S): S
public fun </*0*/ K : Parent> wrapper(): Inv<K>
public object Child : Parent {
private constructor Child()
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 Inv</*0*/ T> {
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 Parent {
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
}
@@ -0,0 +1,5 @@
interface Box<out R>
fun <R> List<Box<R>>.choose(): Box<R>? = TODO()
fun list(): List<Box<*>> = TODO()
fun f() = list().choose()
@@ -0,0 +1,11 @@
package
public fun f(): Box<kotlin.Any?>?
public fun list(): kotlin.collections.List<Box<*>>
public fun </*0*/ R> kotlin.collections.List<Box<R>>.choose(): Box<R>?
public interface Box</*0*/ out R> {
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
}