[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,11 @@
package b
class A {
operator fun <T> get(i: Int): List<T> = throw Exception("$i")
}
fun bar(l: List<Int>) = l
fun test(a: A) {
bar(a[12])
}
@@ -0,0 +1,72 @@
// !WITH_NEW_INFERENCE
package h
interface A<T> {}
fun <T> newA(): A<T> = throw Exception()
interface Z
fun <T> id(t: T): T = t
//binary expressions
//identifier
infix fun <T> Z.foo(a: A<T>): A<T> = a
fun test(z: Z) {
z foo newA()
val a: A<Int> = id(z foo newA())
val b: A<Int> = id(z.foo(newA()))
use(a, b)
}
//binary operation expression
operator fun <T> Z.plus(a: A<T>): A<T> = a
fun test1(z: Z) {
id(z + newA())
val a: A<Z> = z + newA()
val b: A<Z> = z.plus(newA())
val c: A<Z> = id(z + newA())
val d: A<Z> = id(z.plus(newA()))
use(a, b, c, d)
}
//comparison operation
operator fun <T> Z.compareTo(a: A<T>): Int { use(a); return 1 }
fun test2(z: Z) {
val a: Boolean = id(z < newA())
val b: Boolean = id(z < newA<Z>())
use(a, b)
}
//'equals' operation
fun Z.equals(any: Any): Int { use(any); return 1 }
fun test3(z: Z) {
z == newA()
z == newA<Z>()
id(z == newA())
id(z == newA<Z>())
id(z === newA())
id(z === newA<Z>())
}
//'in' operation
fun test4(collection: Collection<A<*>>) {
id(newA() in collection)
id(newA<Int>() in collection)
}
//boolean operations
fun <T> toBeOrNot(): Boolean = throw Exception()
fun test5() {
if (toBeOrNot() && toBeOrNot()) {}
if (toBeOrNot<Int>() && toBeOrNot<Int>()) {}
}
//use
fun use(vararg a: Any?) = a
@@ -0,0 +1,9 @@
package a
fun test(c: C) {
<!INAPPLICABLE_CANDIDATE!>foo<!>(c.b)
}
fun foo(s: String) = s
class C(val b: Int) {}
@@ -0,0 +1,8 @@
fun <T> foo(t: T) = t
fun test(map: MutableMap<Int, Int>, t: Int) {
map [t] = foo(t) // t was marked with black square
}
//from library
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) : V? = this.put(key, value)
@@ -0,0 +1,19 @@
package a
import java.util.ArrayList
public fun <T> Iterable<T>.withIndices(): List<Pair<Int, T>> {
val answer = ArrayList<Pair<Int, T>>()
var nextIndex = 1
for (e in this) {
answer.add(Pair(nextIndex, e))
nextIndex++
}
return answer
}
//from standard library
public class Pair<out A, out B>(
public val first: A,
public val second: B
)
@@ -0,0 +1,16 @@
package j
interface MyFunc<T> {}
class A(val b: B) {
}
class B {
operator fun <T> invoke(f: (T) -> T): MyFunc<T> = throw Exception()
}
fun <R> id(r: R) = r
fun foo(a: A) {
val r : MyFunc<Int> = id (a.b { x -> x + 14 })
}
@@ -0,0 +1,6 @@
class A<T> {
fun <S> foo(s: S): S = s
fun <U> bar(s: U): List<T> = null!!
fun test() = foo(bar(""))
}
@@ -0,0 +1,12 @@
// !CHECK_TYPE
package aaa
infix fun <T> T.foo(t: T) = t
fun <T> id(t: T) = t
fun a() {
val i = id(2 foo 3)
checkSubtype<Int>(i) // i shouldn't be resolved to error element
}
@@ -0,0 +1,35 @@
//KT-3395 mapOf function can't be used as literal
package b
import java.util.ArrayList
public fun <T> query(t: T, args: Map<String, Any>): List<T> {
return ArrayList<T>()
}
fun test(pair: Pair<String, Int>) {
val id = "Hello" // variable is marked as unused
println("Some" + query(0, mapOf(id to 1)))
println("Some" + query(0, mapOf(pair)))
}
//from standard library
fun <K, V> mapOf(vararg values: Pair<K, V>): Map<K, V> { throw Exception() }
infix fun <A,B> A.to(that: B): Pair<A, B> { throw Exception() }
fun println(message : Any?) { throw Exception() }
class Pair<out A, out B> () {}
//short example
fun <T> foo(t: T) = t
fun test(t: String) {
println("Some" + foo(t)) // t was marked with black square
}
@@ -0,0 +1,15 @@
//KT-3461 Nullable argument allowed where shouldn't be
package a
class F {
fun p(): String? = null
}
fun foo(s: String) {}
fun r(): Int? = null
fun test() {
foo(F().p())
<!INAPPLICABLE_CANDIDATE!>foo<!>(r())
}
@@ -0,0 +1,41 @@
package a
interface A {
val b: B
val nb: B?
}
interface B {
fun foo(): Int
}
fun test(u: A?, x: A?, y: A?, z: A?, w: A, v: A?) {
u?.b?.foo()!! // was UNNECESSARY_SAFE_CALL everywhere, because result type (of 'foo()') wasn't made nullable
u!!.b?.foo()!!
x?.b!!.foo()!!
// x?.b is not null
x!!.b!!.foo()!!
y?.nb?.foo()!!
y!!.nb?.foo()!!
z?.nb!!.foo()!!
// z?.nb is not null
z!!.nb!!.foo()!!
w.b?.foo()!!
w.b!!.foo()!!
w.nb?.foo()!!
w.nb!!.foo()!!
v!!.b.foo()!!
}
fun B?.bar(): Int = 1
fun B?.baz(): Int? = 1
fun doInt(i: Int) = i
fun test(a: A?) {
doInt(a?.b.bar()!!)
doInt(a?.b.baz()!!)
}
@@ -0,0 +1,18 @@
package a
fun foo(l: List<Int>): Int = l.get(0)
fun <T> emptyList(): List<T> = throw Exception()
fun <T: Any> makeNullable(t: T): T? = null
fun bar(i: Int) = i
fun bar(a: Any) = a
fun test(array: Array<Int>) {
bar(array[foo(emptyList())])
bar(foo(emptyList()) + foo(a.emptyList()))
bar(makeNullable(foo(emptyList())) ?: 0)
}