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:
+13
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user