From da3233c47d939c97bb8b4aad3d8ed905bba92309 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 28 Apr 2021 10:58:42 +0300 Subject: [PATCH] FIR: Update test data (NEW_INFERENCE_ERROR) Though these diagnostics look correct (the calls or constraint systems indeed contain errors), more precise diagnostic kinds should be chosen later. --- .../tests/callableReference/kt34314.fir.kt | 2 +- .../specialCallsWithCallableReferences.fir.kt | 16 ++++++++-------- .../tests/inference/capturedTypesInSelfType.kt | 2 +- .../coercionWithExpectedTypeAndBound.fir.kt | 4 ++-- .../coerctionToUnitForATypeWithUpperBound.fir.kt | 14 ++++++++++++++ .../coerctionToUnitForATypeWithUpperBound.kt | 3 +-- .../cstWithTypeContainingNonFixedVariable.fir.kt | 4 ++-- ...tInferableParameterOfAnonymousFunction.fir.kt | 4 ++-- .../definitelyNotNullTypeInReturnPosition.fir.kt | 4 ++-- .../tests/inference/constraints/kt8879.fir.kt | 2 +- .../nestedCalls/binaryExpressions.fir.kt | 2 +- .../notEnoughInformationAndNothing.fir.kt | 12 ++++++------ .../specialCallsWithCallableReferences.fir.kt | 6 +++--- .../violatingUpperBoundForSelfType.fir.kt | 4 ++-- .../specialConstructions/exclExclAsCall.fir.kt | 2 +- .../tests/typeParameters/kt46186.fir.kt | 16 ++++++++-------- .../inferenceForSignedAndUnsignedTypes.fir.kt | 2 +- .../coroutines/inference/kt33542.fir.kt | 2 +- .../inference/suspendCallsWithErrors.fir.kt | 2 +- 19 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/inference/coercionToUnit/coerctionToUnitForATypeWithUpperBound.fir.kt diff --git a/compiler/testData/diagnostics/tests/callableReference/kt34314.fir.kt b/compiler/testData/diagnostics/tests/callableReference/kt34314.fir.kt index 6703cd814a8..a469b2f6887 100644 --- a/compiler/testData/diagnostics/tests/callableReference/kt34314.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/kt34314.fir.kt @@ -2,5 +2,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE fun main() { - val x = run { ::run } // no error + val x = run { ::run } // no error } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt index 2b0c0d2879e..5c82eb525fd 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt @@ -38,7 +38,7 @@ fun select(vararg x: R) = x[0] fun poll0(): Flow { return flow { - val inv = select(::bar, ::foo) + val inv = select(::bar, ::foo) inv() } } @@ -52,7 +52,7 @@ fun poll01(): Flow { fun poll02(): Flow { return flow { - val inv = select(::bar3, ::foo3) + val inv = select(::bar3, ::foo3) inv() } } @@ -66,7 +66,7 @@ fun poll03(): Flow { fun poll04(): Flow { return flow { - val inv = select(::bar5, ::foo5) + val inv = select(::bar5, ::foo5) inv } } @@ -437,7 +437,7 @@ fun poll76(): Flow { fun poll8(): Flow { return flow { - val inv = ::bar in setOf(::foo) + val inv = ::bar in setOf(::foo) inv() } } @@ -451,7 +451,7 @@ fun poll81(): Flow { fun poll82(): Flow { return flow { - val inv = ::bar3 in setOf(::foo3) + val inv = ::bar3 in setOf(::foo3) inv() } } @@ -465,7 +465,7 @@ fun poll83(): Flow { fun poll84(): Flow { return flow { - val inv = ::bar5 in setOf(::foo5) + val inv = ::bar5 in setOf(::foo5) inv } } @@ -479,7 +479,7 @@ fun poll85(): Flow { fun poll86(): Flow { return flow { - val inv = ::Foo7 in setOf(::Foo7) + val inv = ::Foo7 in setOf(::Foo7) inv } } @@ -493,7 +493,7 @@ fun poll87(): Flow { fun poll88(): Flow { return flow { - val inv = foo7() in setOf(::Foo7) + val inv = foo7() in setOf(::Foo7) inv } } diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypesInSelfType.kt b/compiler/testData/diagnostics/tests/inference/capturedTypesInSelfType.kt index 9f98d9373b1..fe88e3bdabc 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypesInSelfType.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypesInSelfType.kt @@ -5,5 +5,5 @@ class Foo>(val values: Array) fun foo(x: Array>) { - val y = Foo(x) + val y = Foo(x) } diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedTypeAndBound.fir.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedTypeAndBound.fir.kt index e8c9562b975..3044cee818f 100644 --- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedTypeAndBound.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedTypeAndBound.fir.kt @@ -3,11 +3,11 @@ fun materializeNumber(): T = TODO() fun a(): Unit = run { - materializeNumber() + materializeNumber() } fun b(): Unit = run { run { - materializeNumber() + materializeNumber() } } diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coerctionToUnitForATypeWithUpperBound.fir.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coerctionToUnitForATypeWithUpperBound.fir.kt new file mode 100644 index 00000000000..58b194984c7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coerctionToUnitForATypeWithUpperBound.fir.kt @@ -0,0 +1,14 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface Base +class Foo : Base + +fun myRun(action: () -> T): T = action() + +fun foo(f: (Foo) -> Unit) {} + +fun main() { + foo { f: Foo -> + myRun { f } + } +} diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coerctionToUnitForATypeWithUpperBound.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coerctionToUnitForATypeWithUpperBound.kt index 1d5333bbba1..66af0d75e27 100644 --- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coerctionToUnitForATypeWithUpperBound.kt +++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coerctionToUnitForATypeWithUpperBound.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER interface Base @@ -12,4 +11,4 @@ fun main() { foo { f: Foo -> myRun { f } } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/cstWithTypeContainingNonFixedVariable.fir.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/cstWithTypeContainingNonFixedVariable.fir.kt index 497fe81964b..fe7e2881fc8 100644 --- a/compiler/testData/diagnostics/tests/inference/commonSystem/cstWithTypeContainingNonFixedVariable.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/cstWithTypeContainingNonFixedVariable.fir.kt @@ -59,11 +59,11 @@ fun testVariableWithBound() { c1 - val c2 = select(SubInv(), createWithNumberBound()) + val c2 = select(SubInv(), createWithNumberBound()) c2 - val c3 = select(SubInv(), createWithIntBound()) + val c3 = select(SubInv(), createWithIntBound()) c3 } diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/notInferableParameterOfAnonymousFunction.fir.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/notInferableParameterOfAnonymousFunction.fir.kt index 00bf1955a65..14000f003c9 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/notInferableParameterOfAnonymousFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/notInferableParameterOfAnonymousFunction.fir.kt @@ -5,9 +5,9 @@ fun id(x: K) = x fun main() { val x1 = select(id { x, y -> }, { x: Int, y -> }) - val x2 = select(id { x, y -> }, { x: Int, y -> }) + val x2 = select(id { x, y -> }, { x: Int, y -> }) - val x3 = select(id(fun (x, y) {}), fun (x: Int, y) {}) + val x3 = select(id(fun (x, y) {}), fun (x: Int, y) {}) val x4 = select((fun (x, y) {}), fun (x: Int, y) {}) val x5 = select(id(fun (x, y) {}), fun (x: Int, y) {}) diff --git a/compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.fir.kt b/compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.fir.kt index f1dc8c0c3bd..be183316214 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.fir.kt @@ -262,8 +262,8 @@ class Main(x: L?, y: L) { val x471 = foo47(y) fun takeLambda(block: () -> R): R = materialize() - val x480 = takeLambda { foo48 { x } } - val x481 = takeLambda { foo48 { y } } + val x480 = takeLambda { foo48 { x } } + val x481 = takeLambda { foo48 { y } } val x482 = takeLambda { foo48 { null } } } diff --git a/compiler/testData/diagnostics/tests/inference/constraints/kt8879.fir.kt b/compiler/testData/diagnostics/tests/inference/constraints/kt8879.fir.kt index 32a391b14a8..70ef84c6151 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/kt8879.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/kt8879.fir.kt @@ -9,5 +9,5 @@ fun > foo(klass: Inv): String? = null fun bar(): Inv = null!! fun test() { - foo(bar()) + foo(bar()) } diff --git a/compiler/testData/diagnostics/tests/inference/nestedCalls/binaryExpressions.fir.kt b/compiler/testData/diagnostics/tests/inference/nestedCalls/binaryExpressions.fir.kt index 3f42aaa8e0b..266b32d2ef6 100644 --- a/compiler/testData/diagnostics/tests/inference/nestedCalls/binaryExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/nestedCalls/binaryExpressions.fir.kt @@ -24,7 +24,7 @@ fun test(z: Z) { operator fun Z.plus(a: A): A = a fun test1(z: Z) { - id(z + newA()) + id(z + newA()) val a: A = z + newA() val b: A = z.plus(newA()) val c: A = id(z + newA()) diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationAndNothing.fir.kt b/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationAndNothing.fir.kt index 988a99029ca..2c65f9d32db 100644 --- a/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationAndNothing.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/nothingType/notEnoughInformationAndNothing.fir.kt @@ -17,19 +17,19 @@ fun test1(b: Boolean?) { } fun test2() { - select( + select( materialize() - ) + ) select(materialize(), materialize()) select(materialize(), null, Inv()) - select( + select( materialize(), null - ) - select( + ) + select( materialize(), materialize() - ) + ) select( materialize(), materialize(), diff --git a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt index 5fb1242f4b3..ead2b250578 100644 --- a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt @@ -284,7 +284,7 @@ fun poll82() { } fun poll83() { - val inv = ::bar4 in setOf(::foo4) + val inv = ::bar4 in setOf(::foo4) inv } @@ -299,7 +299,7 @@ fun poll85() { } fun poll86() { - val inv = ::Foo7 in setOf(::Foo7) + val inv = ::Foo7 in setOf(::Foo7) inv } @@ -309,6 +309,6 @@ fun poll87() { } fun poll88() { - val inv = foo7() in setOf(::Foo7) + val inv = foo7() in setOf(::Foo7) inv } diff --git a/compiler/testData/diagnostics/tests/inference/violatingUpperBoundForSelfType.fir.kt b/compiler/testData/diagnostics/tests/inference/violatingUpperBoundForSelfType.fir.kt index 2e4f8805a8e..a4276b44e44 100644 --- a/compiler/testData/diagnostics/tests/inference/violatingUpperBoundForSelfType.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/violatingUpperBoundForSelfType.fir.kt @@ -6,5 +6,5 @@ fun > createMap(enumClass: Class) {} fun reproduce() { val enumClass: Class> = "any" as Class> - createMap(enumClass) -} \ No newline at end of file + createMap(enumClass) +} diff --git a/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.fir.kt b/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.fir.kt index 08c10b71599..29cee2c9fb8 100644 --- a/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.fir.kt @@ -14,7 +14,7 @@ fun emptyNullableListOfA(): List? = null fun testExclExcl() { doList(emptyNullableListOfA()!!) //should be an error here - val l: List = id(emptyNullableListOfA()!!) + val l: List = id(emptyNullableListOfA()!!) doList(strangeNullableList { doInt(it) }!!) //lambda should be analyzed (at completion phase) } diff --git a/compiler/testData/diagnostics/tests/typeParameters/kt46186.fir.kt b/compiler/testData/diagnostics/tests/typeParameters/kt46186.fir.kt index a95edd7324b..06f37cb6505 100644 --- a/compiler/testData/diagnostics/tests/typeParameters/kt46186.fir.kt +++ b/compiler/testData/diagnostics/tests/typeParameters/kt46186.fir.kt @@ -9,13 +9,13 @@ abstract class View4 interface View5 fun findViewById1(): T = null as T -fun test1(): I = findViewById1() +fun test1(): I = findViewById1() fun findViewById2(): T = null as T fun test2(): I = findViewById2() inline fun findViewById3(): T = null as T -fun test3(): I = findViewById3() +fun test3(): I = findViewById3() inline fun findViewById4(): T = null as T fun test4(): I = findViewById4() @@ -39,17 +39,17 @@ inline fun findViewById10(): T where T: View3, T: View5 = null as T fun test10(): I = findViewById10() fun findViewById11(): T = null as T -fun test11(): View4 = findViewById11() +fun test11(): View4 = findViewById11() object Obj { fun findViewById1(): T = null as T - fun test1(): View1 = findViewById1() + fun test1(): View1 = findViewById1() fun findViewById2(): T = null as T fun test2(): View2 = findViewById2() inline fun findViewById3(): T = null as T - fun test3(): View1 = findViewById3() + fun test3(): View1 = findViewById3() inline fun findViewById4(): T = null as T fun test4(): View2 = findViewById4() @@ -67,13 +67,13 @@ object Obj { fun test8(): View4 = findViewById8() fun findViewById9(): T where T: View3, T: View5 = null as T - fun test9(): View1 = findViewById9() + fun test9(): View1 = findViewById9() inline fun findViewById10(): T where T: View3, T: View5 = null as T - fun test10(): View1 = findViewById10() + fun test10(): View1 = findViewById10() fun findViewById11(): T = null as T - fun test11(): View4 = findViewById11() + fun test11(): View4 = findViewById11() } interface A diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.fir.kt b/compiler/testData/diagnostics/tests/unsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.fir.kt index a54ea46fbde..360bb907206 100644 --- a/compiler/testData/diagnostics/tests/unsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/unsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.fir.kt @@ -10,7 +10,7 @@ fun select(x: K, y: K): K = TODO() fun takeUByte(u: UByte) {} fun foo() { - select(1, 1u) checkType { _>() } + select(1, 1u) checkType { _>() } takeUByte(id(1)) 1 + 1u diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt33542.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt33542.fir.kt index 40b6129a5c5..eea59bf1d46 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt33542.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt33542.fir.kt @@ -20,7 +20,7 @@ suspend fun yield() {} fun test() { builder { - send(run { + send(run { yield() // No error but `yield` is not inside "suspension" context actually }) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.fir.kt index db4a9dd6775..6a20ce5cd52 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.fir.kt @@ -19,6 +19,6 @@ val test1 = generate { yield(A) } -val test2: Int = generate { +val test2: Int = generate { yield(A()) }