NI: Add constraints which contain constraining type without projection

^KT-32243 Fixed
^KT-35172 Fixed
This commit is contained in:
Victor Petukhov
2019-11-30 20:24:46 +03:00
committed by victor.petukhov
parent 65cc0fa463
commit 775eb67219
8 changed files with 61 additions and 14 deletions
@@ -20,7 +20,7 @@ public class Foo {
// FILE: test.kt
fun test(e: <!UNRESOLVED_REFERENCE!>ErrorType<!>) {
Foo.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!> {
Foo.foo {
Sam.Result.create(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>e<!>)
}
}
@@ -0,0 +1,30 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -CAST_NEVER_SUCCEEDS
// SKIP_TXT
// FILE: Test.java
import java.util.Collection;
public class Test {
static <T> Inv<Collection<? extends T>> bar() {
return null;
}
}
// FILE: main.kt
class Inv<E>
fun <R> foo(x: R, y: Inv<R>) {}
fun main() {
val values: List<Int> = null as List<Int>
/*
* Before the fix, there was type mismatch during checking `Test.bar()` to pass to `foo`:
* Required: Inv<List<Int>>
* Found: Inv<(MutableCollection<out Int!>..Collection<Int!>?)>
* Constraint `(MutableCollection<out T!>..Collection<T!>?)` from 'Found' (for TypeVariable(R)) has been removed
* during fixation TypeVariable(T) due to the constraint for R contained TypeVariable(T).
* The problem was that TypeVariable(T) wan't substituted due to `containsConstrainingTypeWithoutProjection` optimization.
*/
foo(values, Test.bar())
}