data + open / inner / abstract / sealed are now forbidden
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3725ef8cdf
commit
fff434d377
-15
@@ -1,15 +0,0 @@
|
||||
class Bar(val name: String)
|
||||
|
||||
class Baz {
|
||||
inner class Foo() {
|
||||
inner data class NestedFoo(val bar: Bar)
|
||||
|
||||
fun foo(): String {
|
||||
return NestedFoo(Bar("FAIL")).copy(bar = Bar("OK")).bar.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Baz().Foo().foo()
|
||||
}
|
||||
+3
-1
@@ -6,7 +6,9 @@ abstract class Foo {
|
||||
|
||||
fun box(): String {
|
||||
return object: Foo() {
|
||||
inner data class NestedFoo(val bar: Bar)
|
||||
inner class NestedFoo(val bar: Bar) {
|
||||
fun copy(bar: Bar) = NestedFoo(bar)
|
||||
}
|
||||
|
||||
override fun foo(): String {
|
||||
return NestedFoo(Bar("Fail")).copy(bar = Bar("OK")).bar.name
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
class Dummy {
|
||||
override fun equals(other: Any?) = true
|
||||
}
|
||||
|
||||
open data class A(val v: Any)
|
||||
|
||||
class B(v: Any) : A(v)
|
||||
|
||||
fun box() : String {
|
||||
val a = A(Dummy())
|
||||
val b = B(Dummy())
|
||||
return if(b == a) "OK" else "fail"
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
open data class A(open val x: String)
|
||||
|
||||
class B : A("Fail") {
|
||||
override val x: String = "OK"
|
||||
}
|
||||
|
||||
fun foo(a: A) = a.component1()
|
||||
|
||||
fun box(): String {
|
||||
return foo(B())
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
open data class A(open val x: String)
|
||||
|
||||
class B : A("Fail") {
|
||||
override val x: String = "OK"
|
||||
}
|
||||
|
||||
fun foo(a: A) = a
|
||||
|
||||
fun box(): String {
|
||||
return if ("${foo(B())}" == "A(x=OK)") "OK" else "fail"
|
||||
}
|
||||
Reference in New Issue
Block a user