Files
kotlin/compiler/testData/codegen/box/compatibility/dataClassEqualsHashCodeToString.kt
Alexander Udalov 73652f309f Do not create synthesized equals/hashCode/toString in data classes in compatibility mode
To simplify migration from 1.0 to 1.1, do not allow data classes to
automatically implement abstract equals/hashCode/toString declared in
super-interfaces (KT-11306) if "-language-version 1.0" is specified
2016-10-04 10:24:41 +03:00

14 lines
348 B
Kotlin
Vendored

// LANGUAGE_VERSION: 1.0
data class Foo(val s: String)
fun box(): String {
val f1 = Foo("OK")
val f2 = Foo("OK")
if (f1 != f2) return "Fail equals"
if (f1.hashCode() != f2.hashCode()) return "Fail hashCode"
if (f1.toString() != f2.toString() || f1.toString() != "Foo(s=OK)") return "Fail toString: $f1 $f2"
return f1.s
}