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
This commit is contained in:
Alexander Udalov
2016-10-03 11:46:48 +03:00
parent 597912824b
commit 73652f309f
10 changed files with 122 additions and 36 deletions
@@ -0,0 +1,13 @@
// 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
}