more tests on type inference
#KT-2200 fixed #KT-2283 fixed
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package a
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun g<T> (<!UNUSED_PARAMETER!>f<!>: () -> List<T>) : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun test() {
|
||||
//here possibly can be a cycle on constraints
|
||||
val <!UNUSED_VARIABLE!>x<!> = g { Collections.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>() }
|
||||
|
||||
val <!UNUSED_VARIABLE!>y<!> = g<Int> { Collections.emptyList()!! }
|
||||
val <!UNUSED_VARIABLE!>z<!> : List<Int> = g { Collections.emptyList()!! }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//KT-2200 array(array()) breaks compiler
|
||||
package n
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val <!UNUSED_VARIABLE!>a<!> = array(<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>array<!>())
|
||||
val <!UNUSED_VARIABLE!>a0<!> : Array<Array<Int>> = array(array())
|
||||
val a1 = array(array<Int>())
|
||||
a1 : Array<Array<Int>>
|
||||
val a2 = array<Array<Int>>(array())
|
||||
a2 : Array<Array<Int>>
|
||||
}
|
||||
|
||||
//from library
|
||||
fun <T> array(vararg t : T) : Array<T> = t
|
||||
@@ -0,0 +1,13 @@
|
||||
//KT-2283 Bad diagnostics of failed type inference
|
||||
package a
|
||||
|
||||
|
||||
trait Foo<A>
|
||||
|
||||
fun <A, B> Foo<A>.map(<!UNUSED_PARAMETER!>f<!>: (A) -> B): Foo<B> = object : Foo<B> {}
|
||||
|
||||
|
||||
fun foo() {
|
||||
val l: Foo<String> = object : Foo<String> {}
|
||||
val <!UNUSED_VARIABLE!>m<!>: Foo<String> = l.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>map<!> { ppp -> 1 }
|
||||
}
|
||||
@@ -1365,6 +1365,16 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2200.kt")
|
||||
public void testKt2200() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2283.kt")
|
||||
public void testKt2283() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt2283.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2294.kt")
|
||||
public void testKt2294() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt");
|
||||
|
||||
Reference in New Issue
Block a user