[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,17 @@
// FILE: First.java
public class First<T extends Sample> {
public static <D extends Sample> void bind(First<D> first) {}
}
// FILE: SubFirst.java
public class SubFirst<D extends Sample> extends First<D> {}
// FILE: test.kt
interface Sample
fun test(s: SubFirst<*>) {
First.bind(s)
}
@@ -0,0 +1,6 @@
// !LANGUAGE: +NewInference
inline fun <T, reified S> foo(x: T?, y: T): T {
if (x is S) return x
return y
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: JClass.java
public class JClass {
public <K> void foo(Key<K> key, K value) {}
}
// FILE: test.kt
class Key<T>
fun <S> select(x: S, y: S): S = x
fun <T> setValue(key: Key<T>, value: T, j: JClass) {
j.foo(key, select(value, null))
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface A<T : CharSequence>
fun <S : CharSequence?> foo1(a: A<S>) {}
class B1<E : String?> : A<E>
class B2<E : CharSequence?> : A<E>
class B3<E> : A<E>
class B4<E : CharSequence> : A<E>
fun <X : CharSequence, Y1 : X, Y2: Y1?> foo(a: A<X>, b: A<Y1>, c: A<Y2>) {}
@@ -0,0 +1,19 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A<T : CharSequence>(x: T)
fun <E : CharSequence> foo1(x: E) {}
fun <E : CharSequence> E.foo2() {}
fun <F : String?> bar(x: F) {
<!INAPPLICABLE_CANDIDATE!>A<!>(x)
<!INAPPLICABLE_CANDIDATE!>A<!><F>(x)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(x)
<!INAPPLICABLE_CANDIDATE!>foo1<!><F>(x)
x.<!INAPPLICABLE_CANDIDATE!>foo2<!>()
x.<!INAPPLICABLE_CANDIDATE!>foo2<!><F>()
}
@@ -0,0 +1,14 @@
// !WITH_NEW_INFERENCE
fun <E : String?, T : ((CharSequence) -> Unit)?> foo(x: E, y: T) {
if (x != null) {
y(x)
}
if (y != null) {
y(x)
}
if (x != null && y != null) {
y(x)
}
}
@@ -0,0 +1,38 @@
// !LANGUAGE: +NewInference
fun simpleTypeAndNumberType(b: Comparable<*>?) {
if (b is Byte?) {
b!!.dec()
}
}
fun <T> typeParmeterAndNumberType(b: T?) {
if (b is Byte?) {
b!!.dec()
}
}
fun anyAndNumberType(b: Any?) {
if (b is Byte?) {
b!!.dec()
}
}
fun comparableAndNumberType(b: Comparable<Byte>?) {
if (b is Byte?) {
b!!.dec()
}
}
object SeparateTypes {
interface A
interface B {
fun foo() {}
}
fun separate(a: A?) {
if (a is B?) {
a!!.foo()
}
}
}
@@ -0,0 +1,14 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
abstract class Expr<T>
class Sum<K>(val e: Expr<K>) : Expr<K?>()
private fun <V> times(e: Expr<V>, element: V): Expr<V> = TODO()
private fun <S> foo(e: Expr<S>) {}
fun test(intExpression: Expr<Int>) {
foo(Sum(times(intExpression, 42)))
}
@@ -0,0 +1,18 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface A
interface B {
fun test() {}
}
fun <K> select(a: K, b: K): K = a
fun test(a: A?, b: B?) {
b as A?
a as B?
val c = select(a, b)
if (c != null) {
c.test()
}
}
@@ -0,0 +1,35 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
fun <E> bar(x: E) {}
fun <T> foo(): T {
val x1: T = null
val x2: T? = null
bar<T>(null)
bar<T?>(null)
return null
}
fun <T> baz(): T? = null
fun <T> foobar(): T = null
class A<F> {
fun xyz(x: F) {}
fun foo(): F {
val x1: F = null
val x2: F? = null
xyz(null)
bar<F?>(null)
return null
}
fun baz(): F? = null
fun foobar(): F = null
}
@@ -0,0 +1,13 @@
fun <T : Any?> foo(x: T) {
if (x is String?) {
x.length
if (x != null) {
x.length
}
}
if (x is String) {
x.length
}
}
@@ -0,0 +1,46 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
fun <T : CharSequence?> T.bar1() {}
fun CharSequence?.bar2() {}
fun <T : CharSequence> T.bar3() {}
fun CharSequence.bar4() {}
fun <T : CharSequence?> foo(x: T) {
if (x != null) {
if (x != null) {}
x.length
x?.length
x.bar1()
x.bar2()
x.bar3()
x.bar4()
x?.bar1()
}
x.length
if (x is String) {
x.<!AMBIGUITY!>length<!>
x?.<!AMBIGUITY!>length<!>
x.bar1()
x.bar2()
x.bar3()
}
if (x is CharSequence) {
x.length
x?.length
x.bar1()
x.bar2()
x.bar3()
}
}
@@ -0,0 +1,36 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
fun <T : CharSequence?> T.bar1() {}
fun CharSequence?.bar2() {}
fun <T : CharSequence> T.bar3() {}
fun CharSequence.bar4() {}
fun <T : String?> T.foo() {
if (this != null) {
if (this != null) {}
length
this?.length
bar1()
bar2()
bar3()
bar4()
this?.bar1()
}
length
if (this is String) {
length
this?.length
bar1()
bar2()
bar3()
}
}
@@ -0,0 +1,52 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE,-UNUSED_PARAMETER,-ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE,-UNUSED_VALUE
fun <T : CharSequence> bar1(x: T) {}
fun bar2(x: CharSequence) {}
fun bar3(x: String) {}
fun <T : CharSequence?> foo(x: T) {
var y1: CharSequence = ""
var y2: String = ""
if (x != null) {
if (x != null) {}
y1 = x
y2 = x
bar1(x)
bar1<CharSequence>(x)
bar2(x)
<!INAPPLICABLE_CANDIDATE!>bar3<!>(x)
}
if (x is String) {
y1 = x
y2 = x
bar1(x)
bar2(x)
bar3(x)
}
if (x is CharSequence) {
y1 = x
y2 = x
bar1(x)
bar2(x)
<!INAPPLICABLE_CANDIDATE!>bar3<!>(x)
}
if (1 == 1) {
val y = x!!
bar1(x)
bar1<CharSequence>(x)
bar2(x)
<!INAPPLICABLE_CANDIDATE!>bar3<!>(x)
<!INAPPLICABLE_CANDIDATE!>bar1<!>(y)
bar2(y)
<!INAPPLICABLE_CANDIDATE!>bar3<!>(y)
}
}
@@ -0,0 +1,49 @@
// !WITH_NEW_INFERENCE
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
class A<F> {
fun <E : F> foo1(x: E) = x
fun <E : F?> foo2(x: E) = x
fun <Z : F, W : Z?> bar(x: F, y: F?, z: Z, w: W) {
foo1<F>(x)
val x1 = foo1(x)
x1.checkType { _<F>() }
foo2<F>(x)
val x2 = foo2(x)
x2.checkType { _<F>() }
<!INAPPLICABLE_CANDIDATE!>foo1<!><F?>(y)
foo1(y)
foo2<F?>(y)
val x3 = foo2(y)
x3.checkType { _<F?>() }
foo1<F>(y)
foo2<F>(y)
foo1<Z>(z)
val x4 = foo1(z)
x4.checkType { _<Z>() }
foo2<Z>(z)
val x5 = foo2(z)
x4.checkType { _<Z>() }
<!INAPPLICABLE_CANDIDATE!>foo1<!><W>(w)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(w)
foo2<W>(w)
val x6 = foo2(w)
x6.checkType { _<W>() }
<!INAPPLICABLE_CANDIDATE!>foo1<!><W>(w)
}
}
@@ -0,0 +1,67 @@
// !WITH_NEW_INFERENCE
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
class A<F> {
class Inv<Q>
fun <E : Inv<F>> fooInv1(x: E) = x
fun <E : Inv<F?>> fooInv2(x: E) = x
class In<in Q>
fun <E : In<F>> fooIn1(x: E) = x
fun <E : In<F?>> fooIn2(x: E) = x
class Out<out Q>
fun <E : Out<F>> fooOut1(x: E) = x
fun <E : Out<F?>> fooOut2(x: E) = x
fun <Z : F, W : Z?> bar() {
// F
fooInv1<Inv<F>>(Inv<F>())
<!INAPPLICABLE_CANDIDATE!>fooInv2<!><Inv<F>>(Inv<F>())
fooInv1(Inv<F>())
<!INAPPLICABLE_CANDIDATE!>fooInv2<!>(Inv<F>())
fooIn1<In<F?>>(In<F?>())
fooIn2<In<F?>>(In<F?>())
fooIn1(In<F?>())
fooIn2(In<F?>())
fooOut1<Out<F>>(Out<F>())
fooOut2<Out<F>>(Out<F>())
fooOut1(Out<F>())
fooOut2(Out<F>())
// Z
<!INAPPLICABLE_CANDIDATE!>fooInv1<!><Inv<Z>>(Inv<Z>())
<!INAPPLICABLE_CANDIDATE!>fooInv2<!><Inv<Z>>(Inv<Z>())
<!INAPPLICABLE_CANDIDATE!>fooInv1<!>(Inv<Z>())
<!INAPPLICABLE_CANDIDATE!>fooInv2<!>(Inv<Z>())
<!INAPPLICABLE_CANDIDATE!>fooIn1<!><In<Z?>>(In<Z?>())
<!INAPPLICABLE_CANDIDATE!>fooIn2<!><In<Z?>>(In<Z?>())
<!INAPPLICABLE_CANDIDATE!>fooIn1<!>(In<Z?>())
<!INAPPLICABLE_CANDIDATE!>fooIn2<!>(In<Z?>())
fooOut1<Out<Z>>(Out<Z>())
fooOut2<Out<Z>>(Out<Z>())
fooOut1(Out<Z>())
fooOut2(Out<Z>())
// W
<!INAPPLICABLE_CANDIDATE!>fooInv1<!><Inv<W>>(Inv<W>())
<!INAPPLICABLE_CANDIDATE!>fooInv2<!><Inv<W>>(Inv<W>())
<!INAPPLICABLE_CANDIDATE!>fooInv1<!>(Inv<W>())
<!INAPPLICABLE_CANDIDATE!>fooInv2<!>(Inv<W>())
<!INAPPLICABLE_CANDIDATE!>fooIn1<!><In<W?>>(In<W?>())
<!INAPPLICABLE_CANDIDATE!>fooIn2<!><In<W?>>(In<W?>())
<!INAPPLICABLE_CANDIDATE!>fooIn1<!>(In<W?>())
<!INAPPLICABLE_CANDIDATE!>fooIn2<!>(In<W?>())
<!INAPPLICABLE_CANDIDATE!>fooOut1<!><Out<W>>(Out<W>())
fooOut2<Out<W>>(Out<W>())
<!INAPPLICABLE_CANDIDATE!>fooOut1<!>(Out<W>())
fooOut2(Out<W>())
}
}
@@ -0,0 +1,40 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_VALUE,-UNUSED_VARIABLE,-ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE,-VARIABLE_WITH_REDUNDANT_INITIALIZER
class A<T : CharSequence?, E1 : T, E2: T?> {
fun T.bar() {}
fun foo(x: E1, y: E2) {
x.bar()
if (1 == 1) {
y.<!INAPPLICABLE_CANDIDATE!>bar<!>()
}
x?.bar()
y?.bar()
var t: T = x
var tN: T? = y
// condition needed to make smart cast on tN impossible
if (1 == 1) {
tN = x
}
if (1 == 1) {
t = tN
}
t = y
if (y != null) {
t = y
}
if (tN != null) {
t = tN
}
}
}
@@ -0,0 +1,27 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
fun <T : CharSequence?> T.bar1() {}
fun CharSequence?.bar2() {}
fun <T : CharSequence> T.bar3() {}
fun <T : String?> foo(x: T) {
x.length
x?.length
if (1 == 1) {
x!!.length
}
x.bar1()
x.bar2()
x?.bar1()
x?.bar2()
x.<!INAPPLICABLE_CANDIDATE!>bar3<!>()
x?.let { it.length }
}
@@ -0,0 +1,18 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
fun <T : CharSequence?> bar1(x: T) {}
fun bar2(x: CharSequence?) {}
fun <T : CharSequence> bar3(x: T) {}
fun bar4(x: String) {}
fun <T : String?> foo(x: T) {
bar1(x)
bar2(x)
<!INAPPLICABLE_CANDIDATE!>bar3<!>(x)
bar4(x)
}