[NI] Implement algorithm for completion mode selection
Current selection of completion mode for call is not always correct in case of full mode, and sometimes too conservative in case of partial mode. Updated algorithm checks constraints wrt position of type variables in return type and in other related constraints. Full completion happens if proper constraint requirements are satisfied for variables.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
|
||||
// FILE: GenericRunnable.java
|
||||
|
||||
public interface GenericRunnable<T> {
|
||||
T invoke();
|
||||
}
|
||||
|
||||
// FILE: OurFuture.java
|
||||
|
||||
public class OurFuture<T> {
|
||||
static <T> OurFuture<T> createOurFuture(T result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public <U> OurFuture<U> compose(GenericRunnable<OurFuture<U>> mapper) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
open class Either<out L> {
|
||||
class Left<out L>(val a: L) : Either<L>()
|
||||
}
|
||||
|
||||
fun f1(future: OurFuture<String>, e: Either.Left<String>) {
|
||||
future.compose<Either<String>> {
|
||||
val x = when {
|
||||
true -> OurFuture.createOurFuture(e)
|
||||
else -> throw Exception()
|
||||
}
|
||||
x
|
||||
}
|
||||
}
|
||||
|
||||
fun f2(future: OurFuture<String>, e: Either.Left<String>) {
|
||||
future.compose<Either<String>> {
|
||||
when {
|
||||
true -> OurFuture.createOurFuture(e)
|
||||
else -> throw Exception()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user