[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,12 @@
// !CHECK_TYPE
package g
import java.util.HashSet
fun <T, C: Collection<T>> convert(src: Collection<T>, dest: C): C = throw Exception("$src $dest")
fun test(l: List<Int>) {
//todo should be inferred
val r = convert(l, HashSet())
r checkType { <!UNRESOLVED_REFERENCE!>_<!><HashSet<Int>>() }
}
@@ -0,0 +1,68 @@
// !WITH_NEW_INFERENCE
package a
interface A
fun <T> emptyList(): List<T> = throw Exception()
fun test1() {
emptyList()
}
//--------------
fun <T: A> emptyListOfA(): List<T> = throw Exception()
fun test2() {
emptyListOfA()
}
//--------------
fun <T: A, R: T> emptyStrangeMap(): Map<T, R> = throw Exception()
fun test3() {
emptyStrangeMap()
}
//--------------
fun <T, R: T> emptyStrangeMap1(t: T): Map<T, R> = throw Exception("$t")
fun test4() {
emptyStrangeMap1(1)
}
//--------------
fun <T: A, R> emptyStrangeMap2(t: T): Map<T, R> where R: T = throw Exception("$t")
fun test5(a: A) {
emptyStrangeMap2(a)
}
//--------------
fun <T: A, R: T> emptyStrangeMap3(r: R): Map<T, R> = throw Exception("$r")
fun test6(a: A) {
emptyStrangeMap3(a)
}
//--------------
fun <T, R: T> emptyStrangeMap4(l: MutableList<T>): Map<T, R> = throw Exception("$l")
fun test7(list: MutableList<Int>) {
emptyStrangeMap4(list)
}
//--------------
fun test7() : Map<A, A> = emptyStrangeMap()
//--------------
fun <U, V: U> foo(): U = throw Exception()
fun test8(): Int = foo()
@@ -0,0 +1,33 @@
// !WITH_NEW_INFERENCE
// !CHECK_TYPE
package s
interface In<in T>
interface A
interface B
interface C: A, B
fun <T> foo(in1: In<T>, in2: In<T>): T = throw Exception("$in1 $in2")
fun test(inA: In<A>, inB: In<B>, inC: In<C>) {
foo(inA, inB)
val r = foo(inA, inC)
checkSubtype<C>(r)
val c: C = foo(inA, inB)
use(c)
}
fun <T: C> bar(in1: In<T>): T = throw Exception("$in1")
fun test(inA: In<A>) {
val r = bar(inA)
checkSubtype<C>(r)
}
fun use(vararg a: Any?) = a
@@ -0,0 +1,20 @@
//KT-2856 Fix the getOrElse signature to be able to return any supertype of V
package d
import java.util.HashMap
public inline fun <K,V1, V: V1> Map<K,V>.getOrElse1(key: K, defaultValue: ()-> V1) : V1 {
if (this.containsKey(key)) {
return this.get(key) as V
} else {
return defaultValue()
}
}
fun main() {
val map = HashMap<Int, Int>()
println(map.getOrElse1(2, { null })) // Error
}
//from standard library
fun println(message : Any?) {}
@@ -0,0 +1,13 @@
fun <R : Any> unescape(value: Any): R? = throw Exception("$value")
fun <T: Any> foo(v: Any): T? = unescape(v)
//--------------
interface A
fun <R : A> unescapeA(value: Any): R? = throw Exception("$value")
fun <T: A> fooA(v: Any): T? = unescapeA(v)
@@ -0,0 +1,16 @@
// !CHECK_TYPE
@kotlin.internal.InlineOnly
public inline fun <C, R> C.ifEmpty(f: () -> R): R where C : Collection<*>, C : R = if (isEmpty()) f() else this
public fun <T> listOf(t: T): List<T> = TODO()
fun usage(c: List<String>) {
val cn = c.ifEmpty { null }
cn checkType { <!UNRESOLVED_REFERENCE!>_<!><List<String>?>() }
val cs = c.ifEmpty { listOf("x") }
cs checkType { <!UNRESOLVED_REFERENCE!>_<!><List<String>>() }
}
@@ -0,0 +1,12 @@
// !WITH_NEW_INFERENCE
package Hello
open class Base<T>
class StringBase : Base<String>()
class Client<T, X: Base<T>>(x: X)
fun test() {
val c = Client(StringBase()) // Type inference fails here for T.
val i : Int = c
}
@@ -0,0 +1,23 @@
// !WITH_NEW_INFERENCE
package a
fun <V: U, U> foo(v: V, u: U) = u
fun <U, V: U> bar(v: V, u: U) = u
fun test(a: Any, s: String) {
val b = foo(a, s)
checkItIsExactlyAny(a, arrayListOf(b))
val c = bar(a, s)
checkItIsExactlyAny(a, arrayListOf(c))
}
fun <T> checkItIsExactlyAny(t: T, l: MutableList<T>) {}
fun <V : U, U> baz(v: V, u: MutableSet<U>) = u
fun test(a: Any, s: MutableSet<String>) {
<!INAPPLICABLE_CANDIDATE!>baz<!>(a, s)
}
//from standard library
fun <T> arrayListOf(vararg t: T): MutableList<T> {}