[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,34 @@
fun <T1> test1(x: List<T1>) = x
fun <T2> test1(x: List<T2>) = x
fun <T1> List<T1>.test1a() {}
fun <T2> List<T2>.test1a() {}
fun <T> test2(x: List<T>) = x
fun test2(x: List<String>) = x
fun <T> List<T>.test2a() {}
fun List<String>.test2a() {}
fun <T : Any> test3(x: List<T>) = x
fun test3(x: List<Any>) = x
fun <T : Any> List<T>.test3a() {}
fun List<Any>.test3a() {}
fun <T> test4(x: Map<T, T>) = x
fun <K, V> test4(x: Map<K, V>) = x
fun <T> Map<T, T>.test4a() {}
fun <K, V> Map<K, V>.test4a() {}
class Inv<T>
fun <T> test5(x: Inv<T>) = x
fun <T> test5(x: Inv<out T>) = x
fun <T> test6(x: Array<T>) = x
fun test6(x: Array<String>) = x
fun <T> test7(x: Inv<T>) = x
fun <T> Inv<T>.test7() {}
@@ -0,0 +1,6 @@
class A {
fun a(a: Int): Int = 0
fun a(a: Int) {
}
}
@@ -0,0 +1,7 @@
package qwertyuiop
fun c(s: String) {
}
fun c(s: String) {
}
@@ -0,0 +1,5 @@
package extensionFunctions
fun Int.qwe(a: Float) = 1
fun Int.qwe(a: Float) = 2
@@ -0,0 +1,7 @@
class A() {
fun b() {
}
fun b() {
}
}
@@ -0,0 +1,4 @@
class Aaa() {
fun f() = 1
fun <P> f() = 1
}
@@ -0,0 +1,4 @@
class Aaa() {
val a = 1
val a = 1
}
@@ -0,0 +1,4 @@
class Aaa() {
val a = 1
val a = ""
}
@@ -0,0 +1,29 @@
// constructor vs. fun overload
package constructorVsFun
class a() { }
fun a() = 1
class Tram {
fun f() { }
class f() { }
}
class Yvayva {
companion object {
fun fghj() { }
class fghj() { }
}
}
class Rtyu {
fun ololo() { }
companion object {
class ololo() { }
}
}
@@ -0,0 +1,8 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(g: () -> Int) {}
fun foo(f: (Int) -> Int) {}
fun test() {
<!AMBIGUITY!>foo<!> { -> 42 }
}
@@ -0,0 +1,3 @@
fun Int.rty() = 3
fun String.rty() = 4
@@ -0,0 +1,13 @@
// FILE: pkg1.kt
// check no error in overload in different packages
package pkg1
fun e() = 1
// FILE: pkg2.kt
package pkg2
fun e() = 1
// FILE: pkg3pkg1.kt
package pkg3.pkg1
fun e() = 1
@@ -0,0 +1,213 @@
fun test() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
fun local() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
}
}
class Test {
init {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
}
fun test() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
}
val property: Any get() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
return 0
}
}
val property: Any get() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
return 0
}
object Object {
fun test() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
}
val property: Any get() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
return 0
}
}
val obj = object {
fun test() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
}
val property: Any get() {
fun test1() {}
fun test1() {}
fun Any.test2() {}
fun test2(x: Any) = x
fun Any.test3() {}
fun Any.test3() {}
fun test4(): Int = 0
fun test4(): String = ""
class Test5(val x: Int) {
constructor(): this(0)
}
fun Test5() {}
fun Test5(x: Int) = x
return 0
}
}
@@ -0,0 +1,7 @@
// check no error when regular function and extension function have same name
package extensionAndRegular
fun who() = 1
fun Int.who() = 1
@@ -0,0 +1,4 @@
class Aaaa() {
val bb = 1
fun bb() = 1
}
@@ -0,0 +1,7 @@
fun Runnable(f: () -> Unit): Runnable = object : Runnable {
public override fun run() {
f()
}
}
val x = Runnable { }
@@ -0,0 +1,15 @@
import java.io.Serializable
interface Test1 {
fun <T> foo(t: T) where T : Cloneable, T : Serializable
fun <T> foo(t: T) where T : Serializable, T : Cloneable
}
interface I1
interface I2 : I1
interface Test2 {
fun <T> foo(t: T) where T : I1, T : I2
fun <T> foo(t: T) where T : I2, T : I1
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: Base.java
public interface Base {
<T> String foo(T a);
<T> int foo(T a, Object... args);
}
// FILE: Derived.java
public interface Derived extends Base {
}
// FILE: test.kt
fun testDerived(base: Base, derived: Derived) {
val test1: String = base.foo("")
val test2: String = derived.foo("")
}
@@ -0,0 +1,59 @@
// !WITH_NEW_INFERENCE
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
fun simple() = 1
fun simple(a: Int = 3) = ""
fun twoDefault(a: Int = 2) = 1
fun twoDefault(a: Any = 2, b: String = "") = ""
fun <T> withGeneric(a: T) = 1
fun <T> withGeneric(a: T, b: Int = 4) = ""
fun <T> discriminateGeneric(a: T) = 1
fun discriminateGeneric(a: Int, b: String = "") = ""
fun <T: CharSequence> withDefaultGeneric(t: T, d: T? = null) = 1
fun <T: Any> withDefaultGeneric(t: T, d: T? = null, a: Int = 1) = ""
fun withDefaults(a: Any = 2) = 1
fun withDefaults(a: Int = 2, b: String = "") = ""
fun <T: Any> withGenericDefaults(t: T, d: T? = null) = 1
fun <T: CharSequence> withGenericDefaults(t: T, d: T? = null, a: Int = 1) = ""
fun wrong(a: Int = 1) {}
fun wrong(a: String = "", b: Int = 1) {}
fun test() {
val a = simple()
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
val b = simple(1)
b checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
val c = twoDefault()
c checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
val d = twoDefault(1)
d checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
val e = twoDefault(1, "")
e checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
val f = withGeneric(3)
f checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
val g = discriminateGeneric(1)
g checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
val h = withDefaultGeneric("")
h checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
withDefaults(1)
withGenericDefaults("")
<!AMBIGUITY!>wrong<!>(null!!)
}
@@ -0,0 +1,28 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
object X1
object X2
interface Base {
fun <T1> foo(a: T1): X1
fun <T2> foo(a: T2, vararg args: Any): X2
}
interface Derived : Base
fun testDerived(base: Base, derived: Derived) {
val test1: X1 = base.foo("")
val test2: X1 = derived.foo("")
}
interface GenericBase<T> {
fun <T1> foo(x: T, a: T1): X1
}
interface SpecializedDerived : GenericBase<String> {
fun <T2> foo(x: String, a: T2, vararg args: Any): X2
}
fun testSpecializedDerived(derived: SpecializedDerived) {
val test1: X1 = derived.foo("", "")
}
@@ -0,0 +1,14 @@
// KT-1998 Strange "Overload resolution ambiguity"
object A {
val c : String = "test"
fun f(b: B): String {
return b.c // Test no "Overload resolution ambiguity" is reported here
}
}
class B
val B.c : String
get() = "test"
@@ -0,0 +1,20 @@
// !WITH_NEW_INFERENCE
interface A
interface B
fun <R: A> R.f() {
}
fun <R: B> R.f() {
}
class AImpl: A
class BImpl: B
class C: A, B
fun main() {
AImpl().f()
BImpl().f()
C().<!AMBIGUITY!>f<!>()
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun withLambda(block : Int.(String) -> Unit) {
}
fun withLambda(o : Int, block : Int.(String) -> Unit) {
}
fun test() {
withLambda {
it.length
}
withLambda { r -> // no error should be here
r.length
}
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun withLambda(block : Int.(String) -> Unit) {
}
fun withLambda(block : Int.(String, String) -> Unit) {
}
fun test() {
withLambda { r ->
r.length
}
withLambda { x, y ->
x.length + y.length
}
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER
// KT-7440 Cannot complete type inference if two extension functions for interface hierarchy
package inferenceagain
interface Base<T>
interface Derived<T> : Base<T>
fun <R : Comparable<R>, T : Any> Base<T>.maxBy(f: (T) -> R): T? = null
fun <R : Comparable<R>, T : Any> Derived<T>.maxBy(f: (T) -> R): T? = null
fun <T> derivedOf(vararg members: T): Derived<T> = null!!
fun <T> x(l: Derived<T>) {
derivedOf(1, 2, 3).maxBy<Int, Int> { it } // works
derivedOf(1, 2, 3).maxBy { it } // should work
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
private fun foo(i: Int) {}
private fun foo(s: String) {}
}
fun test(a: A) {
a.<!INAPPLICABLE_CANDIDATE!>foo<!>(3)
a.<!INAPPLICABLE_CANDIDATE!>foo<!>()
}