Move test for NI to diagnostic tests and add "todo"

This commit is contained in:
Mikhail Zarechenskiy
2017-07-27 22:09:49 +03:00
parent fb72726f08
commit 3fb865e07c
10 changed files with 37 additions and 58 deletions
@@ -0,0 +1,5 @@
fun <X, Y, Z> foo(f: (Y) -> Z, g: (X) -> Y, x: X): Z = f(g(x))
// TODO: Actually, this is a bug and will work when new inference is enabled
// see ([NI] Select variable with proper non-trivial constraint first) for more details
fun test() = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>({ it + 1 }, { it.length }, "")
@@ -0,0 +1,4 @@
package
public fun </*0*/ X, /*1*/ Y, /*2*/ Z> foo(/*0*/ f: (Y) -> Z, /*1*/ g: (X) -> Y, /*2*/ x: X): Z
public fun test(): [ERROR : Error function type]
@@ -0,0 +1,9 @@
typealias SuspendFn = suspend () -> Unit
val test1f: suspend () -> Unit = fun () {}
val test2f: suspend Any.() -> Unit = fun Any.() {}
// This is a bug in the old inference and should be fixed in new inference
// see "Fix anonymous function literals handling in type checker" for more deatils
val test3f: suspend Any.(Int) -> Int = <!TYPE_MISMATCH!>fun (k: Int) = k + 1<!>
val test4f: SuspendFn = <!TYPE_MISMATCH!>fun Any.() {}<!>
@@ -0,0 +1,7 @@
package
public val test1f: suspend () -> kotlin.Unit
public val test2f: suspend kotlin.Any.() -> kotlin.Unit
public val test3f: suspend kotlin.Any.(kotlin.Int) -> kotlin.Int
public val test4f: SuspendFn /* = suspend () -> kotlin.Unit */
public typealias SuspendFn = suspend () -> kotlin.Unit
@@ -4,8 +4,3 @@ val test1: suspend () -> Unit = {}
val test2: suspend Any.() -> Unit = {}
val test3: suspend Any.(Int) -> Int = { k: Int -> k + 1 }
val test4: SuspendFn = {}
val test1f: suspend () -> Unit = fun () {}
val test2f: suspend Any.() -> Unit = fun Any.() {}
val test3f: suspend Any.(Int) -> Int = fun (k: Int) = k + 1
val test4f: SuspendFn = fun Any.() {}
@@ -1,11 +1,7 @@
package
public val test1: suspend () -> kotlin.Unit
public val test1f: suspend () -> kotlin.Unit
public val test2: suspend kotlin.Any.() -> kotlin.Unit
public val test2f: suspend kotlin.Any.() -> kotlin.Unit
public val test3: suspend kotlin.Any.(kotlin.Int) -> kotlin.Int
public val test3f: suspend kotlin.Any.(kotlin.Int) -> kotlin.Int
public val test4: SuspendFn /* = suspend () -> kotlin.Unit */
public val test4f: SuspendFn /* = suspend () -> kotlin.Unit */
public typealias SuspendFn = suspend () -> kotlin.Unit
@@ -1,3 +0,0 @@
fun <X, Y, Z> foo(f: (Y) -> Z, g: (X) -> Y, x: X): Z = f(g(x))
fun test() = foo({ it + 1 }, { it.length }, "")
@@ -1,40 +0,0 @@
FILE /fixationOrder2.kt
FUN public fun <X, Y, Z> foo(f: (Y) -> Z, g: (X) -> Y, x: X): Z
TYPE_PARAMETER <X>
TYPE_PARAMETER <Y>
TYPE_PARAMETER <Z>
VALUE_PARAMETER value-parameter f: (Y) -> Z
VALUE_PARAMETER value-parameter g: (X) -> Y
VALUE_PARAMETER value-parameter x: X
BLOCK_BODY
RETURN type=kotlin.Nothing from='foo((Y) -> Z, (X) -> Y, X): Z'
CALL 'invoke(Y): Z' type=Z origin=INVOKE
$this: GET_VAR 'value-parameter f: (Y) -> Z' type=(Y) -> Z origin=VARIABLE_AS_FUNCTION
p1: CALL 'invoke(X): Y' type=Y origin=INVOKE
$this: GET_VAR 'value-parameter g: (X) -> Y' type=(X) -> Y origin=VARIABLE_AS_FUNCTION
p1: GET_VAR 'value-parameter x: X' type=X origin=null
FUN public fun test(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='test(): Int'
CALL 'foo((Int) -> Int, (String) -> Int, String): Int' type=kotlin.Int origin=null
<X>: String
<Y>: Int
<Z>: Int
f: BLOCK type=(kotlin.Int) -> kotlin.Int origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA local final fun <anonymous>(it: kotlin.Int): kotlin.Int
VALUE_PARAMETER value-parameter it: kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='<anonymous>(Int): Int'
CALL 'plus(Int): Int' type=kotlin.Int origin=PLUS
$this: GET_VAR 'value-parameter it: Int' type=kotlin.Int origin=null
other: CONST Int type=kotlin.Int value='1'
FUNCTION_REFERENCE '<anonymous>(Int): Int' type=(kotlin.Int) -> kotlin.Int origin=LAMBDA
g: BLOCK type=(kotlin.String) -> kotlin.Int origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA local final fun <anonymous>(it: kotlin.String): kotlin.Int
VALUE_PARAMETER value-parameter it: kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='<anonymous>(String): Int'
CALL '<get-length>(): Int' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'value-parameter it: String' type=kotlin.String origin=null
FUNCTION_REFERENCE '<anonymous>(String): Int' type=(kotlin.String) -> kotlin.Int origin=LAMBDA
x: CONST String type=kotlin.String value=''
@@ -10060,6 +10060,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("fixationOrderForProperConstraints.kt")
public void testFixationOrderForProperConstraints() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/fixationOrderForProperConstraints.kt");
doTest(fileName);
}
@TestMetadata("flexibleTypesAsUpperBound.kt")
public void testFlexibleTypesAsUpperBound() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/flexibleTypesAsUpperBound.kt");
@@ -10150,6 +10156,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("lambdaInValInitializerWithAnonymousFunctions.kt")
public void testLambdaInValInitializerWithAnonymousFunctions() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.kt");
doTest(fileName);
}
@TestMetadata("listConstructor.kt")
public void testListConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/listConstructor.kt");
@@ -1104,12 +1104,6 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/regressions/newInference/fixationOrder1.kt");
doTest(fileName);
}
@TestMetadata("fixationOrder2.kt")
public void testFixationOrder2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/regressions/newInference/fixationOrder2.kt");
doTest(fileName);
}
}
}