Synthesized 'copy' in data classes cannot override anything since 1.3
Synthesized 'copy' introduces default values for parameters, which is prohibited for regular overrides. Report warning in language version 1.2-, error in 1.3+.
This commit is contained in:
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// !LANGUAGE: +ProhibitDataClassesOverridingCopy
|
||||
|
||||
interface WithCopy<T> {
|
||||
fun copy(str: T): WithCopy<T>
|
||||
}
|
||||
|
||||
<!DATA_CLASS_OVERRIDE_DEFAULT_VALUES_ERROR!>data<!> class <!CONFLICTING_JVM_DECLARATIONS, CONFLICTING_JVM_DECLARATIONS!>Test(val str: String)<!> : WithCopy<String> {
|
||||
<!CONFLICTING_OVERLOADS!>override fun copy(str: String)<!> = Test(str)
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public final data class Test : WithCopy<kotlin.String> {
|
||||
public constructor Test(/*0*/ str: kotlin.String)
|
||||
public final val str: kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.String
|
||||
public open override /*1*/ fun copy(/*0*/ str: kotlin.String): Test
|
||||
public final override /*1*/ /*synthesized*/ fun copy(/*0*/ str: kotlin.String = ...): Test
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface WithCopy</*0*/ T> {
|
||||
public abstract fun copy(/*0*/ str: T): WithCopy<T>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// !LANGUAGE: +ProhibitDataClassesOverridingCopy
|
||||
|
||||
interface WithCopy<T> {
|
||||
fun copy(str: T): WithCopy<T>
|
||||
}
|
||||
|
||||
<!DATA_CLASS_OVERRIDE_DEFAULT_VALUES_ERROR!>data<!> class <!CONFLICTING_JVM_DECLARATIONS, CONFLICTING_JVM_DECLARATIONS, CONFLICTING_JVM_DECLARATIONS!>Test(val str: String)<!> : WithCopy<String> {
|
||||
<!CONFLICTING_OVERLOADS!>override fun copy(str: String = <!DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE!>this.str<!>)<!> = Test(str)
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public final data class Test : WithCopy<kotlin.String> {
|
||||
public constructor Test(/*0*/ str: kotlin.String)
|
||||
public final val str: kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.String
|
||||
public open override /*1*/ fun copy(/*0*/ str: kotlin.String = ...): Test
|
||||
public final override /*1*/ /*synthesized*/ fun copy(/*0*/ str: kotlin.String = ...): Test
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface WithCopy</*0*/ T> {
|
||||
public abstract fun copy(/*0*/ str: T): WithCopy<T>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package
|
||||
|
||||
public final data class Test : WithCopy<kotlin.String> {
|
||||
public constructor Test(/*0*/ str: kotlin.String, /*1*/ int: kotlin.Int)
|
||||
public final val int: kotlin.Int
|
||||
public final val str: kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.String
|
||||
public final operator /*synthesized*/ fun component2(): kotlin.Int
|
||||
public open override /*1*/ fun copy(/*0*/ str: kotlin.String): Test
|
||||
public final /*synthesized*/ fun copy(/*0*/ str: kotlin.String = ..., /*1*/ int: kotlin.Int = ...): Test
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface WithCopy</*0*/ T> {
|
||||
public abstract fun copy(/*0*/ str: T): WithCopy<T>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// !LANGUAGE: -ProhibitDataClassesOverridingCopy
|
||||
|
||||
interface WithCopy<T> {
|
||||
fun copy(str: T): WithCopy<T>
|
||||
}
|
||||
|
||||
<!DATA_CLASS_OVERRIDE_DEFAULT_VALUES_WARNING!>data<!> class Test(val str: String): WithCopy<String>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
public final data class Test : WithCopy<kotlin.String> {
|
||||
public constructor Test(/*0*/ str: kotlin.String)
|
||||
public final val str: kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.String
|
||||
public final override /*1*/ /*synthesized*/ fun copy(/*0*/ str: kotlin.String = ...): Test
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface WithCopy</*0*/ T> {
|
||||
public abstract fun copy(/*0*/ str: T): WithCopy<T>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// !LANGUAGE: +ProhibitDataClassesOverridingCopy
|
||||
|
||||
interface WithCopy<T> {
|
||||
fun copy(str: T): WithCopy<T>
|
||||
}
|
||||
|
||||
<!DATA_CLASS_OVERRIDE_DEFAULT_VALUES_ERROR!>data<!> class Test(val str: String): WithCopy<String>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
public final data class Test : WithCopy<kotlin.String> {
|
||||
public constructor Test(/*0*/ str: kotlin.String)
|
||||
public final val str: kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.String
|
||||
public final override /*1*/ /*synthesized*/ fun copy(/*0*/ str: kotlin.String = ...): Test
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface WithCopy</*0*/ T> {
|
||||
public abstract fun copy(/*0*/ str: T): WithCopy<T>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user