[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,6 @@
data class A(val component1: Int)
fun foo(a: A) {
a.component1()
a.component1
}
@@ -0,0 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
data class A(val x: Int, val y: String) {
fun copy(x: Int, y: String) = x
fun copy(x: Int, y: String) = A(x, y)
}
@@ -0,0 +1,4 @@
data class A(val x: Int, val y: String) {
fun component1() = 1
fun component2() = 2
}
@@ -0,0 +1,3 @@
class Outer {
private data class Nested(val c: Int)
}
@@ -0,0 +1,9 @@
// !LANGUAGE: +ProhibitDataClassesOverridingCopy
interface WithCopy<T> {
fun copy(str: T): WithCopy<T>
}
data class Test(val str: String) : WithCopy<String> {
override fun copy(str: String) = Test(str)
}
@@ -0,0 +1,9 @@
// !LANGUAGE: +ProhibitDataClassesOverridingCopy
interface WithCopy<T> {
fun copy(str: T): WithCopy<T>
}
data class Test(val str: String) : WithCopy<String> {
override fun copy(str: String = this.str) = Test(str)
}
@@ -0,0 +1,9 @@
// See EA-73584
data class<!SYNTAX!><!> {
}
// See KT-9296
data interface<!SYNTAX!><!> {
}
@@ -0,0 +1,9 @@
// !LANGUAGE: +ProhibitDataClassesOverridingCopy
interface WithCopy<T> {
fun copy(str: T): WithCopy<T>
}
data class Test(val str: String, val int: Int) : WithCopy<String> {
override fun copy(str: String) = copy(str, int)
}
@@ -0,0 +1,7 @@
// !LANGUAGE: -ProhibitDataClassesOverridingCopy
interface WithCopy<T> {
fun copy(str: T): WithCopy<T>
}
data class Test(val str: String): WithCopy<String>
@@ -0,0 +1,7 @@
// !LANGUAGE: +ProhibitDataClassesOverridingCopy
interface WithCopy<T> {
fun copy(str: T): WithCopy<T>
}
data class Test(val str: String): WithCopy<String>
@@ -0,0 +1,3 @@
data class My(val x: Int, vararg val y: String)
data class Your(vararg z: String)
@@ -0,0 +1,13 @@
interface SuperInterface
open class SuperClass
abstract data class Base(val x: Int)
class Derived: Base(42)
data class Nasty(val z: Int, val y: Int): Base(z)
data class Complex(val y: Int): SuperInterface, SuperClass()
data class SubData(val sss: String) : Complex(42)
@@ -0,0 +1 @@
data object Object(val x: Int, val y: Int)
@@ -0,0 +1,6 @@
data class A()
fun foo(a: A) {
a.<!UNRESOLVED_REFERENCE!>component1<!>()
a.<!UNRESOLVED_REFERENCE!>component2<!>()
}
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
data class A(val i: Int, val j: G)
data class B(val i: G, val j: G)
fun fa(a: A) {
val (i, j) = a
val i2 = a.component1()
val j2 = a.component2()
}
fun fb(b: B) {
val (i, j) = b
val i2 = b.component1()
val j2 = b.component2()
}
@@ -0,0 +1,22 @@
// !WITH_NEW_INFERENCE
class Data<T>(val x: T, val y: T)
operator fun <T> Data<T>.component1() = x
operator fun <T> Data<T>.component2() = y
fun foo(): Int {
val d: Data<Int>? = null
// An error must be here
val (<!INAPPLICABLE_CANDIDATE!>x<!>, <!INAPPLICABLE_CANDIDATE!>y<!>) = d
return x + y
}
data class NormalData<T>(val x: T, val y: T)
fun bar(): Int {
val d: NormalData<Int>? = null
// An error must be here
val (<!INAPPLICABLE_CANDIDATE!>x<!>, <!INAPPLICABLE_CANDIDATE!>y<!>) = d
return x + y
}
@@ -0,0 +1,16 @@
abstract class Base {
final override fun equals(other: Any?) = false
final override fun hashCode() = 42
open override fun toString() = "OK"
}
data class Data1(val field: String) : Base()
interface AbstractAnyMembers {
abstract override fun equals(other: Any?): Boolean
abstract override fun hashCode(): Int
abstract override fun toString(): String
}
data class Data2(val field: String): Base(), AbstractAnyMembers
@@ -0,0 +1,25 @@
// KT-11306 ABSTRACT_MEMBER_NOT_IMPLEMENTED for data class should inheriting interfaces requiring equals(), hashCode(), or toString()
interface Foo {
override fun equals(other: Any?): Boolean
override fun hashCode(): Int
override fun toString(): String
}
data class FooImpl(val num: Int) : Foo
data class FooImplSome(val num: Int) : Foo {
override fun hashCode() = 42
}
data class FooImplAll(val num: Int) : Foo {
override fun equals(other: Any?) = false
override fun hashCode() = 42
override fun toString() = "OK"
}
data class WrongSignatures(val num: Int) : Foo {
override fun equals(other: WrongSignatures) = false
override fun hashCode(): Boolean = true
}
@@ -0,0 +1,5 @@
interface T {
fun component1(): Int
}
data class A(val x: Int) : T
@@ -0,0 +1,5 @@
interface T {
final fun component1(): Int = 42
}
data class A(val x: Int) : T
@@ -0,0 +1,3 @@
class Outer {
inner data class Inner(val x: Int)
}
@@ -0,0 +1 @@
inner data class Outer(val x: Int)
@@ -0,0 +1,9 @@
// !CHECK_TYPE
data class A(val x: Int, val y: String)
fun foo(a: A) {
val (b, c) = a
checkSubtype<Int>(b)
checkSubtype<String>(c)
}
@@ -0,0 +1,10 @@
// !CHECK_TYPE
data class A(val x: Int, val y: String)
fun foo(arr: Array<A>) {
for ((b, c) in arr) {
checkSubtype<Int>(b)
checkSubtype<String>(c)
}
}
@@ -0,0 +1,6 @@
data class A
fun foo(a: A) {
a.<!UNRESOLVED_REFERENCE!>component1<!>()
a.<!UNRESOLVED_REFERENCE!>component2<!>()
}
@@ -0,0 +1,6 @@
class A(val x: Int, val y: String)
fun foo(a: A) {
a.<!UNRESOLVED_REFERENCE!>component1<!>()
a.<!UNRESOLVED_REFERENCE!>component2<!>()
}
@@ -0,0 +1,8 @@
// !CHECK_TYPE
data class A(val x: Int)
fun foo(a: A) {
checkSubtype<Int>(a.component1())
a.<!UNRESOLVED_REFERENCE!>component2<!>()
}
@@ -0,0 +1,9 @@
data class A1(val x: Int, val y: String, val x: Int) {
val z = ""
}
data class A2(val x: Int, val y: String) {
val x = ""
}
data class A3(val<!SYNTAX!><!> :Int, val<!SYNTAX!><!> : Int)
@@ -0,0 +1,4 @@
sealed data class My(val x: Int) {
object Your: My(1)
class His(y: Int): My(y)
}
@@ -0,0 +1,10 @@
data enum class First(val x: Int) {
A(1),
B(2)
}
data object Second
data interface Third
data annotation class Fourth(val x: Int)
@@ -0,0 +1,8 @@
// !CHECK_TYPE
data class A(val x: Int, val y: String)
fun foo(a: A) {
checkSubtype<Int>(a.component1())
checkSubtype<String>(a.component2())
}
@@ -0,0 +1,8 @@
// !CHECK_TYPE
data class A(var x: Int, var y: String)
fun foo(a: A) {
checkSubtype<Int>(a.component1())
checkSubtype<String>(a.component2())
}