diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt index a83ff3f07c0..83608972f8f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt @@ -120,10 +120,10 @@ public object ModifierCheckerCore { // Abstract + open + final + sealed: incompatible result += incompatibilityRegister(ABSTRACT_KEYWORD, OPEN_KEYWORD, FINAL_KEYWORD, SEALED_KEYWORD) // data + open, data + inner, data + abstract, data + sealed - result += deprecationRegister(DATA_KEYWORD, OPEN_KEYWORD) - result += deprecationRegister(DATA_KEYWORD, INNER_KEYWORD) - result += deprecationRegister(DATA_KEYWORD, ABSTRACT_KEYWORD) - result += deprecationRegister(DATA_KEYWORD, SEALED_KEYWORD) + result += incompatibilityRegister(DATA_KEYWORD, OPEN_KEYWORD) + result += incompatibilityRegister(DATA_KEYWORD, INNER_KEYWORD) + result += incompatibilityRegister(DATA_KEYWORD, ABSTRACT_KEYWORD) + result += incompatibilityRegister(DATA_KEYWORD, SEALED_KEYWORD) // open is redundant to abstract & override result += redundantRegister(ABSTRACT_KEYWORD, OPEN_KEYWORD) result += redundantRegister(OVERRIDE_KEYWORD, OPEN_KEYWORD) diff --git a/compiler/testData/codegen/box/bridges/fakeOverrideWithSynthesizedImplementation.kt b/compiler/testData/codegen/box/bridges/fakeOverrideWithSynthesizedImplementation.kt index 13b87b448a2..09a3d921613 100644 --- a/compiler/testData/codegen/box/bridges/fakeOverrideWithSynthesizedImplementation.kt +++ b/compiler/testData/codegen/box/bridges/fakeOverrideWithSynthesizedImplementation.kt @@ -1,4 +1,6 @@ -open data class A(val value: String) +open class A(val value: String) { + fun component1() = value +} interface B { fun component1(): Any diff --git a/compiler/testData/codegen/box/classes/kt6136.kt b/compiler/testData/codegen/box/classes/kt6136.kt index 3f075a47c0f..14a14e1c4e0 100644 --- a/compiler/testData/codegen/box/classes/kt6136.kt +++ b/compiler/testData/codegen/box/classes/kt6136.kt @@ -2,7 +2,7 @@ interface Id { val id: T } -open data class Actor ( +data class Actor ( override val id: Int, val firstName: String, val lastName: String diff --git a/compiler/testData/codegen/box/classes/kt6136_2.kt b/compiler/testData/codegen/box/classes/kt6136_2.kt index 7b566a076ee..16ce553dd9e 100644 --- a/compiler/testData/codegen/box/classes/kt6136_2.kt +++ b/compiler/testData/codegen/box/classes/kt6136_2.kt @@ -2,7 +2,7 @@ interface Id { val id: T } -open data class Actor ( +data class Actor ( id: Int, val firstName: String, val lastName: String diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInNestedDataClass.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInNestedDataClass.kt deleted file mode 100644 index 6d40d4263e6..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInNestedDataClass.kt +++ /dev/null @@ -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() -} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInObjectNestedDataClass.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInObjectNestedDataClass.kt index 3a6794efec9..935389c50cb 100644 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInObjectNestedDataClass.kt +++ b/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInObjectNestedDataClass.kt @@ -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 diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/instanceof.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/instanceof.kt deleted file mode 100644 index 809f5a9ff15..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/instanceof.kt +++ /dev/null @@ -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" -} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/overriddenProperty.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/overriddenProperty.kt deleted file mode 100644 index 50f27979b39..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/overriddenProperty.kt +++ /dev/null @@ -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()) -} diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/overriddenProperty.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/overriddenProperty.kt deleted file mode 100644 index 3a4f021fea1..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/overriddenProperty.kt +++ /dev/null @@ -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" -} diff --git a/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt b/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt deleted file mode 100644 index 0cc9161a522..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt +++ /dev/null @@ -1,13 +0,0 @@ -// !CHECK_TYPE - -open data class A(private val x: Int) - -class B : A(1) { - fun component1(): String = "" -} - -fun foo() { - val b = B() - checkSubtype(b.component1()) - checkSubtype((checkSubtype(b)).component1()) -} diff --git a/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.txt b/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.txt deleted file mode 100644 index 04cbaed14c1..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.txt +++ /dev/null @@ -1,23 +0,0 @@ -package - -public fun foo(): kotlin.Unit - -@kotlin.data() public open class A { - public constructor A(/*0*/ x: kotlin.Int) - private final val x: kotlin.Int - private final operator /*synthesized*/ fun component1(): kotlin.Int - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): A - 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 -} - -public final class B : A { - public constructor B() - invisible_fake final override /*1*/ /*fake_override*/ val x: kotlin.Int - public final fun component1(): kotlin.String - public final override /*1*/ /*fake_override*/ fun copy(/*0*/ x: kotlin.Int = ...): A - 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 -} diff --git a/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt b/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt index 567d779fc4d..aa220e8810a 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt @@ -2,7 +2,7 @@ interface Allowed open class NotAllowed -abstract data class Base(val x: Int) +abstract data class Base(val x: Int) class Derived: Base(42) diff --git a/compiler/testData/diagnostics/tests/dataClasses/innerDataClass.kt b/compiler/testData/diagnostics/tests/dataClasses/innerDataClass.kt index 7292cb32b1f..840b4bb62aa 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/innerDataClass.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/innerDataClass.kt @@ -1,3 +1,3 @@ class Outer { - inner data class Inner(val x: Int) + inner data class Inner(val x: Int) } diff --git a/compiler/testData/diagnostics/tests/dataClasses/innerOuterDataClass.kt b/compiler/testData/diagnostics/tests/dataClasses/innerOuterDataClass.kt index 9105efa3ea0..1695db0dcfc 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/innerOuterDataClass.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/innerOuterDataClass.kt @@ -1 +1 @@ -inner data class Outer(val x: Int) \ No newline at end of file +inner data class Outer(val x: Int) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.kt b/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.kt index 8aabf058039..cc65d11e001 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.kt @@ -1,4 +1,4 @@ -sealed data class My(val x: Int) { +sealed data class My(val x: Int) { object Your: My(1) class His(y: Int): My(y) } diff --git a/compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.kt b/compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.kt deleted file mode 100644 index f9e2e02e012..00000000000 --- a/compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.kt +++ /dev/null @@ -1,3 +0,0 @@ -package test - -open data class DataClass(val x: String) diff --git a/compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.txt b/compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.txt deleted file mode 100644 index d6080a50b98..00000000000 --- a/compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.txt +++ /dev/null @@ -1,9 +0,0 @@ -package test - -@kotlin.data() public open class DataClass { - /*primary*/ public constructor DataClass(/*0*/ x: kotlin.String) - public final val x: kotlin.String - public final fun (): kotlin.String - public final operator /*synthesized*/ fun component1(): kotlin.String - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.String = ...): test.DataClass -} diff --git a/compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.kt b/compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.kt deleted file mode 100644 index a4647228449..00000000000 --- a/compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package test - -open data class DataClass(open val x: String) diff --git a/compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.txt b/compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.txt deleted file mode 100644 index 8a7c772016c..00000000000 --- a/compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.txt +++ /dev/null @@ -1,9 +0,0 @@ -package test - -@kotlin.data() public open class DataClass { - /*primary*/ public constructor DataClass(/*0*/ x: kotlin.String) - public open val x: kotlin.String - public open fun (): kotlin.String - public final operator /*synthesized*/ fun component1(): kotlin.String - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.String = ...): test.DataClass -} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 9fb8eda2508..799e139cd5d 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -3324,12 +3324,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/dataClasses"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("componentFunctionInSubClass.kt") - public void testComponentFunctionInSubClass() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt"); - doTest(fileName); - } - @TestMetadata("componentNamedComponent1.kt") public void testComponentNamedComponent1() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/componentNamedComponent1.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 15ad291fe42..756d0eb6c4e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -1165,12 +1165,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("overriddenProperty.kt") - public void testOverriddenProperty() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/overriddenProperty.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("privateValParams.kt") public void testPrivateValParams() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/privateValParams.kt"); @@ -1209,12 +1203,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("copyInNestedDataClass.kt") - public void testCopyInNestedDataClass() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInNestedDataClass.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("copyInObjectNestedDataClass.kt") public void testCopyInObjectNestedDataClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/copy/copyInObjectNestedDataClass.kt"); @@ -1278,12 +1266,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("instanceof.kt") - public void testInstanceof() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/equals/instanceof.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("intarray.kt") public void testIntarray() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/equals/intarray.kt"); @@ -1440,12 +1422,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("overriddenProperty.kt") - public void testOverriddenProperty() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/overriddenProperty.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("unitComponent.kt") public void testUnitComponent() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/unitComponent.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index 90c16ea6b56..50c263d3dca 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -2926,18 +2926,6 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledKotlin(fileName); } - @TestMetadata("OpenDataClass.kt") - public void testOpenDataClass() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.kt"); - doTestCompiledKotlin(fileName); - } - - @TestMetadata("OpenPropertyFinalComponent.kt") - public void testOpenPropertyFinalComponent() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.kt"); - doTestCompiledKotlin(fileName); - } - @TestMetadata("ParamNameSameToField.kt") public void testParamNameSameToField() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java index d8e2dc6c9b1..aa5dade2dbd 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java @@ -1035,18 +1035,6 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD doTest(fileName); } - @TestMetadata("OpenDataClass.kt") - public void testOpenDataClass() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.kt"); - doTest(fileName); - } - - @TestMetadata("OpenPropertyFinalComponent.kt") - public void testOpenPropertyFinalComponent() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.kt"); - doTest(fileName); - } - @TestMetadata("ParamNameSameToField.kt") public void testParamNameSameToField() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java index 2090749ec6c..ec4d0d7dc0d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java @@ -1033,18 +1033,6 @@ public class ResolveByStubTestGenerated extends AbstractResolveByStubTest { doTest(fileName); } - @TestMetadata("OpenDataClass.kt") - public void testOpenDataClass() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OpenDataClass.kt"); - doTest(fileName); - } - - @TestMetadata("OpenPropertyFinalComponent.kt") - public void testOpenPropertyFinalComponent() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OpenPropertyFinalComponent.kt"); - doTest(fileName); - } - @TestMetadata("ParamNameSameToField.kt") public void testParamNameSameToField() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt");