FIR: Update diagnostics test data

Green code correctly became red
This commit is contained in:
Denis.Zharkov
2021-04-27 16:23:59 +03:00
committed by teamcityserver
parent 829f80179c
commit b94335dd1c
54 changed files with 101 additions and 129 deletions
@@ -7,10 +7,10 @@ class A {
class B(other: B = <!NO_THIS!>this<!>)
class C() {
constructor(x: Int) : this({
constructor(x: Int) : this(<!ARGUMENT_TYPE_MISMATCH!>{
val a = 10
<!ARGUMENT_TYPE_MISMATCH, INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>
}) {}
}<!>) {}
}
class D {
@@ -8,7 +8,7 @@ fun foo() =
cond1() -> 12
cond2() -> 2
<!CONDITION_TYPE_MISMATCH!>4<!> -> 34
<!CONDITION_TYPE_MISMATCH!>Pair(1, 2)<!> -> 3
<!CONDITION_TYPE_MISMATCH, TYPE_MISMATCH!>Pair(1, 2)<!> -> 3
in 1..10 -> 34
<!CONDITION_TYPE_MISMATCH!>4<!> -> 38
is Int -> 33
@@ -8,8 +8,8 @@ val <T> <!KCLASS_WITH_NULLABLE_TYPE_PARAMETER_IN_SIGNATURE!>test4<!> get() = T::
fun <T> test5() = listOf(T::class)
fun <T> test6(): kotlin.reflect.KClass<T> = T::class
fun <T> test7(): kotlin.reflect.KClass<*> = T::class
fun <T> test6(): kotlin.reflect.KClass<T> = <!TYPE_MISMATCH!>T<!>::class
fun <T> test7(): kotlin.reflect.KClass<*> = <!TYPE_MISMATCH!>T<!>::class
fun test8() = <!NULLABLE_TYPE_IN_CLASS_LITERAL_LHS!>String?::class<!>
fun <T> test9() where T : Any?, T : Comparable<T> = T::class
@@ -12,8 +12,8 @@ class A(outer: Outer) {
var b: String by foo(getMyProperty())
var r: String by foo(outer.getContainer().getMyProperty())
var e: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>+ foo(getMyProperty())<!>
var f: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>foo(getMyProperty()) - 1<!>
var e: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH, TYPE_MISMATCH!>+ foo(getMyProperty())<!>
var f: String by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH, TYPE_MISMATCH!>foo(getMyProperty()) - 1<!>
}
fun <A, B> foo(a: Any?) = MyProperty<A, B>()
@@ -25,4 +25,4 @@ class C<R>() {
}
var c1: Int by C()
var c2: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>C<Number>()<!>
var c2: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH, TYPE_MISMATCH!>C<Number>()<!>
@@ -10,6 +10,6 @@ operator fun String.provideDelegate(thisRef: Any?, prop: Any) = WrongDelegate(th
operator fun String.getValue(thisRef: Any?, prop: Any) = this
val test1: String by "OK"
val test1: String by <!TYPE_MISMATCH!>"OK"<!>
val test2: Int by "OK"
val test3 by "OK"
@@ -3,7 +3,7 @@
import kotlin.reflect.KProperty
val c: Int by <!DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>Delegate()<!>
val c: Int by <!DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH, TYPE_MISMATCH!>Delegate()<!>
class Delegate {
operator fun getValue(t: Any?, p: KProperty<*>): String {
@@ -1,10 +1,10 @@
// !WITH_NEW_INFERENCE
fun test(a: Int) {
run<Int>f@{
if (a > 0) return@f ""
if (a > 0) return@f <!ARGUMENT_TYPE_MISMATCH!>""<!>
return@f 1
}
run<Int>{ "" }
run<Int>{ <!ARGUMENT_TYPE_MISMATCH!>""<!> }
run<Int>{ 1 }
}
@@ -1,3 +1,3 @@
open class C<T : C<T>>
class TestOK : C<TestOK>()
class TestFail : C<C<TestFail>>()
class TestFail : <!UPPER_BOUND_VIOLATED!>C<C<TestFail>><!>()
@@ -14,14 +14,14 @@ class A<E> {
fun test(a: A<out CharSequence>, z: Out<CharSequence>) {
a.foo {
val x: String = <!INITIALIZER_TYPE_MISMATCH!>1<!> // Should be no TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS
""
<!ARGUMENT_TYPE_MISMATCH!>""<!>
}
a.bar { Out<CharSequence>() }
a.bar { <!ARGUMENT_TYPE_MISMATCH, TYPE_MISMATCH!>Out<CharSequence>()<!> }
a.bar { Out() }
a.bar { z.id() }
a.bar { <!ARGUMENT_TYPE_MISMATCH, TYPE_MISMATCH!>z.id()<!> }
a.foo {
z.foobar(if (1 > 2) return@foo "" else "")
""
z.foobar(if (1 > 2) return@foo <!ARGUMENT_TYPE_MISMATCH!>""<!> else "")
<!ARGUMENT_TYPE_MISMATCH!>""<!>
}
}
@@ -48,9 +48,9 @@ fun bar(block: () -> String) {}
fun test_5(b: Boolean) {
bar {
if (b) {
<!ARGUMENT_TYPE_MISMATCH!>if (b) {
println("meh")
}
}<!>
}
}
@@ -16,5 +16,5 @@ fun <S> test1(a: ParameterizedChild<S>?, b: Child): Base<S> = myRun {
}
fun <S> test2(a: S?, b: S): S = myRun {
select(a, b)
<!ARGUMENT_TYPE_MISMATCH!>select(a, b)<!>
}
@@ -20,5 +20,5 @@ fun testFunctions() {
fun testNestedCalls() {
id<String>(inferFromLambda { materialize() })
id<String>(inferFromLambda(fun() = materialize()))
id<String>(<!ARGUMENT_TYPE_MISMATCH!>inferFromLambda2(fun() = <!ARGUMENT_TYPE_MISMATCH!>materialize()<!>)<!>)
id<String>(inferFromLambda2(<!ARGUMENT_TYPE_MISMATCH!>fun() = materialize()<!>))
}
@@ -31,7 +31,7 @@ fun f1(future: OurFuture<String>, e: Either.Left<String>) {
true -> OurFuture.createOurFuture(e)
else -> throw Exception()
}
x
<!ARGUMENT_TYPE_MISMATCH!>x<!>
}
}
@@ -42,4 +42,4 @@ fun f2(future: OurFuture<String>, e: Either.Left<String>) {
else -> throw Exception()
}
}
}
}
@@ -78,11 +78,11 @@ fun main() {
// Interdependent lambdas by input-output types aren't supported
takeInterdependentLambdas({}, {})
takeInterdependentLambdas({ it }, { 10 })
takeInterdependentLambdas({ 10 }, { it })
takeInterdependentLambdas({ 10 }, { x -> x })
takeInterdependentLambdas({ x -> 10 }, { it })
takeInterdependentLambdas({ it }, { x -> 10 })
takeInterdependentLambdas({ it }, { <!ARGUMENT_TYPE_MISMATCH!>10<!> })
takeInterdependentLambdas({ <!ARGUMENT_TYPE_MISMATCH!>10<!> }, { it })
takeInterdependentLambdas({ <!ARGUMENT_TYPE_MISMATCH!>10<!> }, { x -> x })
takeInterdependentLambdas({ x -> <!ARGUMENT_TYPE_MISMATCH!>10<!> }, { it })
takeInterdependentLambdas({ it }, { x -> <!ARGUMENT_TYPE_MISMATCH!>10<!> })
// Dependent lambdas by input-output types
takeDependentLambdas({ <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>it<!> }, { it })
@@ -138,8 +138,8 @@ fun main() {
* K <: (C) -> Unit -> TypeVariable(_RP1) >: C
* K == (B) -> Unit -> TypeVariable(_RP1) == B
*/
val x17: (C) -> Unit = <!INITIALIZER_TYPE_MISMATCH!>selectB(id { <!DEBUG_INFO_EXPRESSION_TYPE("B")!>it<!> }, id { it }, id<(B) -> Unit> { x -> x })<!>
val x18: (C) -> Unit = select(id { <!DEBUG_INFO_EXPRESSION_TYPE("C")!>it<!> }, { <!DEBUG_INFO_EXPRESSION_TYPE("C")!>it<!> }, id<(B) -> Unit> { x -> x })
val x17: (C) -> Unit = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>selectB(id <!TYPE_MISMATCH!>{ <!DEBUG_INFO_EXPRESSION_TYPE("B")!>it<!> }<!>, id <!TYPE_MISMATCH!>{ it }<!>, id<(B) -> Unit> { x -> x })<!>
val x18: (C) -> Unit = <!TYPE_MISMATCH!>select(id <!TYPE_MISMATCH!>{ <!DEBUG_INFO_EXPRESSION_TYPE("C")!>it<!> }<!>, <!TYPE_MISMATCH!>{ <!DEBUG_INFO_EXPRESSION_TYPE("C")!>it<!> }<!>, id<(B) -> Unit> { x -> x })<!>
// Resolution of extension/non-extension functions combination
val x19: String.() -> Unit = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id { <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>this<!> }<!>, <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id(fun(x: String) {})<!>)
@@ -149,14 +149,14 @@ fun main() {
select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function2<kotlin.String, kotlin.String, kotlin.Unit>")!>id(fun String.(x: String) {})<!>, <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function2<kotlin.String, kotlin.String, kotlin.Unit>")!>id(fun(x: String, y: String) {})<!>)
select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x: String -> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>this<!> })
select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x -> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>this<!> })
select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x: String, y: String -> x })
select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), <!TYPE_MISMATCH!>{ x: String, y: String -> x }<!>)
// Convert to extension lambda is impossible because the lambda parameter types aren't specified explicitly
select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x, <!CANNOT_INFER_PARAMETER_TYPE!>y<!> -> x })
select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), <!TYPE_MISMATCH!>{ x, <!CANNOT_INFER_PARAMETER_TYPE!>y<!> -> x }<!>)
select(id(id(fun(x: String, y: String) { }), <!TOO_MANY_ARGUMENTS!>fun String.(x: String) {}<!>), { x, y -> x })
val x26: Int.(String) -> Int = fun (x: String) = 10 // it must be error, see KT-38439
// Receiver must be specified in anonymous function declaration
val x27: Int.(String) -> Int = id(fun (x: String) = 10)
select(id<Int.(String) -> Unit> {}, { x: Int, y: String -> x })
val x27: Int.(String) -> Int = id(<!TYPE_MISMATCH!>fun (x: String) = 10<!>)
select(id<Int.(String) -> Unit> {}, <!TYPE_MISMATCH!>{ x: Int, y: String -> x }<!>)
// Inferring lambda parameter types by partially specified parameter types of other lambdas
select(id { x, y -> x.inv() + y.toByte() }, { x: Int, y -> y.toByte() }, { x, y: Number -> x.inv() })
@@ -218,7 +218,7 @@ fun main() {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function<kotlin.Any>")!>select({ x: Int -> TODO() }, id { x: Int, y: Number -> Any() })<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<*, kotlin.String?>")!>select(id { x: Int -> null }, id { x: String -> "" })<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function<kotlin.Int>")!>select(id { x: Int -> 10 }, id { x: Int, y: Number -> TODO() })<!>
val x68: String.(String) -> String = select(id { x: String, y: String -> "10" }, id { x: String, y: String -> "TODO()" })
val x68: String.(String) -> String = select(id <!TYPE_MISMATCH!>{ x: String, y: String -> "10" }<!>, id <!TYPE_MISMATCH!>{ x: String, y: String -> "TODO()" }<!>)
// Anonymous functions
val x69: (C) -> Unit = selectB({ it }, { }, id(fun (x) { <!DEBUG_INFO_EXPRESSION_TYPE("A")!>x<!> }))
@@ -229,7 +229,7 @@ fun main() {
val x71: String.() -> Unit = select(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id(fun String.() { })<!>, <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.String, kotlin.Unit>")!>id(fun(x: String) {})<!>)
val x72: String.() -> Unit = select(fun String.() { }, fun(x: String) {}) // must be error
select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), fun (x, y) { <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>x<!>;<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>y<!> })
select(id<Int.(String) -> Unit>(fun (x, y) {}), { x: Int, y: String -> x }) // receiver of anonymous function must be specified explicitly
select(id<Int.(String) -> Unit>(fun Int.(y) {}), { x: Int, y: String -> x })
select(id<Int.(String) -> Unit>(fun (x, y) {}), <!TYPE_MISMATCH!>{ x: Int, y: String -> x }<!>) // receiver of anonymous function must be specified explicitly
select(id<Int.(String) -> Unit>(fun Int.(y) {}), <!TYPE_MISMATCH!>{ x: Int, y: String -> x }<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.Number, java.io.Serializable>")!>select(A3(), fun (x) = "", { a -> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number")!>a<!> })<!>
}
@@ -14,7 +14,7 @@ fun <T> readFromMyList(l: MyList<out T>, t: T) {}
fun test1(int: Int, any: Any) {
val a0 : MyList<Any> = getMyList(int)
val a1 : MyList<Int> = getMyList(any)
val a1 : MyList<Int> = <!TYPE_MISMATCH, TYPE_MISMATCH!>getMyList(any)<!>
val a2 : MyList<out Any> = getMyList(int)
@@ -13,7 +13,7 @@ fun insideJob1() = doTheJob1()
suspend fun insideJob2() = doTheJob2()
suspend fun insideJob3() = doTheJob3()
fun doTheJob0() = simpleAsync0 { insideJob0() }
fun doTheJob1() = simpleAsync1 { insideJob1() }
suspend fun doTheJob2() = simpleAsync2 { insideJob2() }
suspend fun doTheJob3() = simpleAsync3 { insideJob3() }
fun doTheJob0() = simpleAsync0 { <!ARGUMENT_TYPE_MISMATCH!>insideJob0()<!> }
fun doTheJob1() = simpleAsync1 { <!ARGUMENT_TYPE_MISMATCH!>insideJob1()<!> }
suspend fun doTheJob2() = simpleAsync2 { <!ARGUMENT_TYPE_MISMATCH!>insideJob2()<!> }
suspend fun doTheJob3() = simpleAsync3 { <!ARGUMENT_TYPE_MISMATCH!>insideJob3()<!> }
@@ -10,5 +10,5 @@ fun <A, B> Foo<A>.map(f: (A) -> B): Foo<B> = object : Foo<B> {}
fun foo() {
val l: Foo<String> = object : Foo<String> {}
val m: Foo<String> = l.map { ppp -> 1 }
val m: Foo<String> = l.map { ppp -> <!ARGUMENT_TYPE_MISMATCH!>1<!> }
}
@@ -12,14 +12,14 @@ abstract class Buggy {
}
val anotherThree : Int
get() = coll.find{ it > 3 } // does not work here
get() = <!TYPE_MISMATCH!>coll.find{ it > 3 }<!> // does not work here
val yetAnotherThree : Int
get() = coll.find({ v:Int -> v > 3 }) // neither here
get() = <!TYPE_MISMATCH!>coll.find({ v:Int -> v > 3 })<!> // neither here
val extendedGetter : Int
get() {
return coll.find{ it > 3 } // not even here!
return <!TYPE_MISMATCH!>coll.find{ it > 3 }<!> // not even here!
}
}
@@ -16,6 +16,6 @@ fun <T, G> A<T>.foo(x: (T)-> G): G {
fun main() {
val a = A(1)
val t: String = a.foo({p -> p})
val t: String = a.foo({p -> <!ARGUMENT_TYPE_MISMATCH!>p<!>})
checkSubtype<String>(t)
}
@@ -4,7 +4,7 @@ package typeInferenceExpectedTypeMismatch
import java.util.*
fun test() {
val s : Set<Int> = <!INITIALIZER_TYPE_MISMATCH!>newList()<!>
val s : Set<Int> = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>newList()<!>
use(s)
}
@@ -26,7 +26,7 @@ fun <T, R> foo(o: Out<T>, i: In<R>): Two<T, R> = throw Exception("$o $i")
fun test1(outA: Out<A>, inB: In<B>) {
foo(outA, inB)
val b: Two<A, C> = foo(outA, inB)
val b: Two<A, C> = <!TYPE_MISMATCH!>foo(outA, inB)<!>
use(b)
}
@@ -18,5 +18,5 @@ fun test(a: A<Runnable>, b: B, c: C<Runnable>) {
b.f { }
c.f { }
C<Runnable>().f { }
C.g<Runnable> { }
}
C.g<Runnable> <!TYPE_MISMATCH!>{ }<!>
}
@@ -34,7 +34,7 @@ fun main() {
}
A.baz {
x -> x.hashCode()
x -> <!ARGUMENT_TYPE_MISMATCH, TYPE_MISMATCH!>x.hashCode()<!>
}
val block: (String) -> Any? = {
@@ -1,3 +1,3 @@
// !WITH_NEW_INFERENCE
annotation class A(val a: IntArray = arrayOf(1))
annotation class A(val a: IntArray = <!TYPE_MISMATCH!>arrayOf(1)<!>)
annotation class B(val a: IntArray = intArrayOf(1))
@@ -32,12 +32,12 @@ public class Foo<T> {
// FILE: main.kt
fun <T> bar(n: Number?, d: T, e: T) {
val a: Number = <!INITIALIZER_TYPE_MISMATCH!>Foo.simpleId(n)<!>
val a: Number = Foo.simpleId(n)
val b: Number? = Foo.simpleId(n)
val c = Foo.simpleId(n)
val x4 = Foo(if (true) 10 else null)
val x5: Number = <!INITIALIZER_TYPE_MISMATCH!>x4.produceT()<!>
val x5: Number = x4.produceT()
val x6: Number? = x4.produceT()
val x7 = x4.produceT()
val x8 = x4.produceNotNullT()
@@ -17,9 +17,9 @@ fun <T> otherGeneric(l: List<T>) {}
fun test() {
val a: Byte = id(1)
val b: Byte = id(300)
val b: Byte = <!TYPE_MISMATCH!>id(300)<!>
val c: Int = <!INITIALIZER_TYPE_MISMATCH!>id(9223372036854775807)<!>
val c: Int = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>id(9223372036854775807)<!>
val d = id(22)
checkSubtype<Int>(d)
@@ -29,7 +29,7 @@ fun test() {
val f: Byte = either(1, 2)
val g: Byte = either(1, 300)
val g: Byte = <!TYPE_MISMATCH!>either(1, 300)<!>
other(<!ARGUMENT_TYPE_MISMATCH!>11<!>)
@@ -5,6 +5,6 @@ interface Foo
fun test() {
var nullable: Foo? = null
val foo: Collection<Foo> = <!INITIALIZER_TYPE_MISMATCH!>java.util.Collections.singleton(nullable)<!>
val foo: Collection<Foo> = java.util.Collections.singleton(nullable)
val foo1: Collection<Foo> = java.util.Collections.singleton(nullable!!)
}
@@ -5,7 +5,7 @@ package kt235
fun main() {
val array = MyArray()
val f: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
array[2] = 23 //error: Type mismatch: inferred type is Int (!!!) but String was expected
<!TYPE_MISMATCH!>array[2] = 23<!> //error: Type mismatch: inferred type is Int (!!!) but String was expected
}<!>
val g: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
var x = 1
@@ -17,11 +17,11 @@ fun main() {
}<!>
val array1 = MyArray1()
val i: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
array1[2] = 23
<!TYPE_MISMATCH!>array1[2] = 23<!>
}<!>
val fi: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
array[2] = 23
<!TYPE_MISMATCH!>array[2] = 23<!>
}<!>
val gi: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
var x = 1
@@ -46,4 +46,4 @@ class MyArray1() {
class MyNumber() {
operator fun inc(): MyNumber = MyNumber()
}
}
@@ -1,20 +0,0 @@
fun <T> assertEquals(a: T, b: T) {
if (a != b) throw AssertionError("$a != $b")
}
fun main() {
val bytePos = 128.toByte() // Byte.MAX_VALUE + 1
assertEquals(-128, bytePos.toInt()) // correct, wrapped to Byte.MIN_VALUE
val byteNeg: Byte = -bytePos // should not compile, byteNeg should be Int
assertEquals(128, byteNeg.toInt()) // passes, should not be possible
val shortPos = 32768.toShort() // Short.MAX_VALUE + 1
assertEquals(-32768, shortPos.toInt()) // correct, wrapped to Short.MIN_VALUE
val shortNeg: Short = -shortPos // should not compile, shortNeg should be Int
assertEquals(32768, shortNeg.toInt()) // passes, should not be possible
(-128).toByte()
-128.toByte()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun <T> assertEquals(a: T, b: T) {
if (a != b) throw AssertionError("$a != $b")
}
@@ -5,6 +5,6 @@ inline fun <T> tryLambdas(lamb : () -> T) : T{
}
fun main() {
<!INAPPLICABLE_CANDIDATE!>tryLambdas<!><String> {
return@tryLambdas
<!ARGUMENT_TYPE_MISMATCH!>return@tryLambdas<!>
}
}
}
@@ -1,10 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(f: () -> String) {}
fun <K> select(x: K, y: K): K = x
fun test() {
foo { select("non-null", null) } // inferred String? but String is expected
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -21,7 +21,7 @@ val y4: B<Int> = B<Int>("")
val y5: B<String> = <!NONE_APPLICABLE!>B<!><String>(1)
val y6: B<String> = B<String>("")
val y7: B<String> = B(1)
val y7: B<String> = <!TYPE_MISMATCH, TYPE_MISMATCH!>B(1)<!>
val y8: B<String> = B("")
val y9 = B(1)
@@ -10,7 +10,7 @@ class A {
return 1
}
return
return foo()
return <!TYPE_MISMATCH!>foo()<!>
}
fun foo(): Int = 1
@@ -12,6 +12,6 @@ fun <F> wrapAAndBToOut(x: F): Out<F> where F : A, F : B = Out()
fun main(a: A) {
val x: Out<A> = materializeOutOfAAndB() // OI: inferred type A is not a subtype of B; `F` is instantiated as `A`, so upper bounds was violated
val y: Inv<A> = materializeInvOfAAndB() // OI and NI: required B, found A
val y: Inv<A> = <!TYPE_MISMATCH!>materializeInvOfAAndB()<!> // OI and NI: required B, found A
val z: Out<A> = wrapAAndBToOut(<!ARGUMENT_TYPE_MISMATCH!>a<!>) // OI and NI: required B, found A
}
}
@@ -16,5 +16,5 @@ class Derived : Base<Int>() {
val x2: Base<Int>.InnerCell = InnerCell(42)
val test1: <!UNRESOLVED_REFERENCE!>CT<!> = Cell(42)
val test2: Base<Int>.CT = Cell(42)
val test2: Base<Int>.CT = <!TYPE_MISMATCH, TYPE_MISMATCH!>Cell(42)<!>
}
@@ -11,9 +11,9 @@
fun foo(x: Int) {
r {
when (x) {
<!ARGUMENT_TYPE_MISMATCH!>when (x) {
2 -> 0
}
}<!>
}
}
@@ -16,10 +16,10 @@ fun MyProducerScope<*>.myAwaitClose(block: () -> Unit = {}) {}
fun <T> myEmptyFlow(): MyFlow<T> = null!!
fun test(): MyFlow<Int> {
return select(
return <!TYPE_MISMATCH!>select(
<!DEBUG_INFO_EXPRESSION_TYPE("MyFlow<kotlin.Any?>")!>myCallbackFlow <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<MyProducerScope<kotlin.Any?>, kotlin.Unit>")!>{
myAwaitClose {}
}<!><!>,
myEmptyFlow()
)
)<!>
}
@@ -26,7 +26,7 @@ fun <T> id(x: T) = x
fun foo2() = {
var x = A()
x += { <!ARGUMENT_TYPE_MISMATCH!>""<!> }
x += <!ARGUMENT_TYPE_MISMATCH!>{ "" }<!>
var y = A()
y += 1
}
@@ -37,6 +37,6 @@ class B {
}
fun foo3(x: B) = {
x += { "" }
x += id { "" }
x += { <!ARGUMENT_TYPE_MISMATCH!>""<!> }
x += id { <!ARGUMENT_TYPE_MISMATCH!>""<!> }
}
@@ -29,7 +29,7 @@ fun foo() {
i = genericBuilder { 1 }
genericBuilder { 1 }
genericBuilder<Int> { 1 }
genericBuilder<Int> { "" }
genericBuilder<Int> { <!ARGUMENT_TYPE_MISMATCH!>""<!> }
val y = { 1 }
genericBuilder(y)
@@ -44,7 +44,7 @@ fun foo() {
val s: String = manyArgumentsBuilder({}, { "" }) { 1 }
manyArgumentsBuilder<String>({}, { "" }, { 1 })
manyArgumentsBuilder<String>({}, { 1 }, { 2 })
manyArgumentsBuilder<String>({}, { <!ARGUMENT_TYPE_MISMATCH!>1<!> }, { 2 })
severalParamsInLambda { x, y ->
x checkType { _<String>() }
@@ -8,10 +8,10 @@ fun <T> genericBuilder(c: suspend () -> T): T = null!!
fun foo() {
var result = ""
genericBuilder<String> {
try {
<!ARGUMENT_TYPE_MISMATCH!>try {
await("")
} catch(e: Exception) {
result = "fail"
}
}<!>
}
}
@@ -30,7 +30,7 @@ fun test_2() {
}
fun test_3() {
val x = create { 1.0 }
val x = create { <!ARGUMENT_TYPE_MISMATCH!>1.0<!> }
}
@OverloadResolutionByLambdaReturnType
@@ -30,7 +30,7 @@ fun test_2() {
}
fun test_3() {
val x = create { 1.0 }
val x = create { <!ARGUMENT_TYPE_MISMATCH!>1.0<!> }
}
@OverloadResolutionByLambdaReturnType
@@ -8,5 +8,5 @@ fun test1(l: List<Number>) {
val i: Int = l.firstTyped()
val s: String = l.firstTyped()
val s: String = <!INITIALIZER_TYPE_MISMATCH, NEW_INFERENCE_ERROR!>l.firstTyped()<!>
}
@@ -10,7 +10,7 @@ fun main() {
val pi = 4.0.toDouble() * delta * (1..n).reduce(
{t, i ->
val x = (i - 0.5) * delta
t + 1.0 / (1.0 + x * x)
<!ARGUMENT_TYPE_MISMATCH, TYPE_MISMATCH!>t + 1.0 / (1.0 + x * x)<!>
})
// !!! pi has error type here
@@ -27,9 +27,9 @@ fun test1(): Map<Int, Int> = run {
}
fun test2(): Map<Int, Int> = run {
try {
<!ARGUMENT_TYPE_MISMATCH!>try {
emptyMap()
} catch (e: ExcA) {
mapOf("" to "")
}
}<!>
}
@@ -53,8 +53,8 @@ public class JavaClassCase3{
// TESTCASE NUMBER: 3
fun case3() {
val x = JavaClassCase3.id(null) // Nothing!
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
val a = if (<!CONDITION_TYPE_MISMATCH!>x<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing..kotlin.Nothing?!")!>x<!>
val a = if (x) {
"NOK"
} else "NOK"
}
@@ -3,12 +3,12 @@
// TESTCASE NUMBER: 1
fun case_1(value_1: Int, value_2: String, value_3: TypesProvider): String {
when {
<!CONDITION_TYPE_MISMATCH!>.012f / value_1<!> -> return ""
<!CONDITION_TYPE_MISMATCH, TYPE_MISMATCH!>.012f / value_1<!> -> return ""
<!CONDITION_TYPE_MISMATCH!>"$value_2..."<!> -> return ""
<!CONDITION_TYPE_MISMATCH!>'-'<!> -> return ""
<!CONDITION_TYPE_MISMATCH!>{}<!> -> return ""
<!CONDITION_TYPE_MISMATCH!>value_3.getAny()<!> -> return ""
<!CONDITION_TYPE_MISMATCH!>-10..-1<!> -> return ""
<!CONDITION_TYPE_MISMATCH, TYPE_MISMATCH!>value_3.getAny()<!> -> return ""
<!CONDITION_TYPE_MISMATCH, TYPE_MISMATCH!>-10..-1<!> -> return ""
}
return ""
@@ -5,7 +5,7 @@ fun case_1(value_1: TypesProvider) {
when {
getBoolean(), value_1.getBoolean() -> return
value_1.getBoolean() && getBoolean(), getLong() == 1000L -> return
<!CONDITION_TYPE_MISMATCH!>Out<Int>()<!>, getLong(), {}, Any(), throw Exception() -> return
<!CONDITION_TYPE_MISMATCH, TYPE_MISMATCH!>Out<Int>()<!>, getLong(), {}, Any(), throw Exception() -> return
}
return
+1 -1
View File
@@ -3,7 +3,7 @@
class Pair<A, B>
abstract class C<T : B<Int>, X : (B<Char>) -> Pair<B<Any>, B<A>>>() : B<Any>() { // 2 errors
abstract class C<T : B<Int>, X : (B<Char>) -> Pair<B<Any>, B<A>>>() : <error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'A'">B<Any></error>() { // 2 errors
val a = B<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'A'">Char</error>>() // error
abstract val x : (B<Char>) -> B<Any>
+1 -1
View File
@@ -6,7 +6,7 @@
class C : A<C>()
val a = B<C>()
val a1 = B<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'A<kotlin/Int>'">Int</error>>()
val a1 = B<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'A<TypeVariable(X)>'">Int</error>>()
class X<A, B : A>()
+2 -2
View File
@@ -30,8 +30,8 @@ class Test1<T>()
}
fun test() {
Test1<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'it(Jet87/A & Jet87/B)'">B</error>>()
Test1<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'it(Jet87/A & Jet87/B)'">A</error>>()
Test1<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'Jet87/A'">B</error>>()
Test1<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'Jet87/B'">A</error>>()
Test1<C>()
}
+1 -1
View File
@@ -8,4 +8,4 @@ open class Bar() : <error descr="[OTHER_ERROR] Unknown (other) error">Foo</error
}
val x : Int = <error descr="[INITIALIZER_TYPE_MISMATCH] Initializer type mismatch: expected kotlin/Int, actual Foo">Foo()</error>
val x : Int = <error descr="[INITIALIZER_TYPE_MISMATCH] Initializer type mismatch: expected kotlin/Int, actual Foo"><error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Foo but kotlin/Int was expected">Foo()</error></error>