From a4af6a3076ea8248fe9fdcc118ba55597141fcfc Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 16 Oct 2015 17:10:39 +0300 Subject: [PATCH] data deprecations (empty constructors, non val/var arguments, vararg, superclasses) are now errors, relevant tests fixed --- .../jetbrains/kotlin/diagnostics/Errors.java | 8 ++++---- .../rendering/DefaultErrorMessages.java | 8 ++++---- .../testData/codegen/box/classes/kt6136_2.kt | 20 ------------------- .../box/secondaryConstructors/dataClasses.kt | 2 +- .../dataClasses/copy/paramWithoutProperty.kt | 17 ---------------- .../dataClasses/equals/sameinstance.kt | 2 +- .../dataClasses/hashcode/null.kt | 6 +++--- .../boxWithStdlib/dataClasses/mixedParams.kt | 4 ++-- .../dataClasses/tostring/alreadyInherited.kt | 10 ---------- .../dataClasses/tostring/mixedParams.kt | 4 ++-- .../dataClass/MixedComponents.kt | 2 +- .../dataClass/MixedComponents.txt | 4 ++-- .../compiledKotlin/dataClass/NoComponents.kt | 4 ---- .../dataClass/ParamNameSameToField.kt | 7 ------- .../BlackBoxCodegenTestGenerated.java | 6 ------ ...lackBoxWithStdlibCodegenTestGenerated.java | 12 ----------- .../jvm/compiler/LoadJavaTestGenerated.java | 12 ----------- .../LoadKotlinWithTypeTableTestGenerated.java | 12 ----------- ...mRuntimeDescriptorLoaderTestGenerated.java | 12 ----------- .../decompiledText/Annotations.expected.kt | 2 +- .../decompiledText/Annotations/Annotations.kt | 2 +- .../manyFilesMuitliple.after.kt | 2 +- .../manyFilesMuitliple.before.Main.kt | 2 +- .../stubs/ResolveByStubTestGenerated.java | 12 ----------- .../testData/dataClass/cases/components.kt | 4 ++-- .../testData/dataClass/cases/copy.kt | 4 ++-- .../testData/dataClass/cases/override.kt | 2 +- .../rtti/cases/collectionClassesIsCheck.kt | 2 +- .../annotatedGettersSetters.kt | 2 +- .../annotatedGettersSetters/annotations.txt | 5 +++++ .../defaultPackage/annotations.txt | 4 ++++ .../defaultPackage/defaultPackage.kt | 2 +- 32 files changed, 41 insertions(+), 156 deletions(-) delete mode 100644 compiler/testData/codegen/box/classes/kt6136_2.kt delete mode 100644 compiler/testData/codegen/boxWithStdlib/dataClasses/copy/paramWithoutProperty.kt delete mode 100644 compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/alreadyInherited.kt delete mode 100644 compiler/testData/loadJava/compiledKotlin/dataClass/NoComponents.kt delete mode 100644 compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 0b2b7f55112..aa70814073b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -185,7 +185,7 @@ public interface Errors { DiagnosticFactory0 FINAL_SUPERTYPE = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 SINGLETON_IN_SUPERTYPE = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 NULLABLE_SUPERTYPE = DiagnosticFactory0.create(ERROR, NULLABLE_TYPE); DiagnosticFactory0 DYNAMIC_SUPERTYPE = DiagnosticFactory0.create(ERROR); @@ -411,9 +411,9 @@ public interface Errors { DiagnosticFactory0 NAME_FOR_AMBIGUOUS_PARAMETER = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 DATA_CLASS_WITHOUT_PARAMETERS = DiagnosticFactory0.create(WARNING); - DiagnosticFactory0 DATA_CLASS_VARARG_PARAMETER = DiagnosticFactory0.create(WARNING); - DiagnosticFactory0 DATA_CLASS_NOT_PROPERTY_PARAMETER = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 DATA_CLASS_WITHOUT_PARAMETERS = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 DATA_CLASS_VARARG_PARAMETER = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 DATA_CLASS_NOT_PROPERTY_PARAMETER = DiagnosticFactory0.create(ERROR); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 13741f7b8f1..0bcf585b070 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -437,7 +437,7 @@ public class DefaultErrorMessages { MAP.put(INTERFACE_WITH_SUPERCLASS, "An interface cannot inherit from a class"); MAP.put(SUPERTYPE_APPEARS_TWICE, "A supertype appears twice"); MAP.put(FINAL_SUPERTYPE, "This type is final, so it cannot be inherited from"); - MAP.put(DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES, "Data class inheritance from other classes is deprecated"); + MAP.put(DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES, "Data class inheritance from other classes is forbidden"); MAP.put(SEALED_SUPERTYPE, "This type is sealed, so it can be inherited by only its own nested classes or objects"); MAP.put(SEALED_SUPERTYPE_IN_LOCAL_CLASS, "Local class cannot extend a sealed class"); MAP.put(SINGLETON_IN_SUPERTYPE, "Cannot inherit from a singleton"); @@ -659,9 +659,9 @@ public class DefaultErrorMessages { MAP.put(NAME_FOR_AMBIGUOUS_PARAMETER, "Named argument is not allowed for a parameter with an ambiguous name"); - MAP.put(DATA_CLASS_WITHOUT_PARAMETERS, "Data class without primary constructor parameters are deprecated"); - MAP.put(DATA_CLASS_VARARG_PARAMETER, "Primary constructor vararg parameters are deprecated for data classes"); - MAP.put(DATA_CLASS_NOT_PROPERTY_PARAMETER, "Primary constructor parameters without val / var are deprecated for data classes"); + MAP.put(DATA_CLASS_WITHOUT_PARAMETERS, "Data class must have at least one primary constructor parameter"); + MAP.put(DATA_CLASS_VARARG_PARAMETER, "Primary constructor vararg parameters are forbidden for data classes"); + MAP.put(DATA_CLASS_NOT_PROPERTY_PARAMETER, "Data class primary constructor must have only property (val / var) parameters"); MAP.put(AMBIGUOUS_ANONYMOUS_TYPE_INFERRED, "Right-hand side has anonymous type. Please specify type explicitly", TO_STRING); diff --git a/compiler/testData/codegen/box/classes/kt6136_2.kt b/compiler/testData/codegen/box/classes/kt6136_2.kt deleted file mode 100644 index 16ce553dd9e..00000000000 --- a/compiler/testData/codegen/box/classes/kt6136_2.kt +++ /dev/null @@ -1,20 +0,0 @@ -interface Id { - val id: T -} - -data class Actor ( - id: Int, - val firstName: String, - val lastName: String -) : Id { - override val id: Int = id -} - -fun box(): String { - val a1 = Actor(1, "Jeff", "Bridges") - val a1copy = a1.copy(id = a1.id) - - if (a1copy.id != a1.id) return "Failed: a1copy.id==${a1copy.id}" - - return "OK" -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/secondaryConstructors/dataClasses.kt b/compiler/testData/codegen/box/secondaryConstructors/dataClasses.kt index 01027d52204..074508611b6 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/dataClasses.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/dataClasses.kt @@ -12,7 +12,7 @@ internal data class A1(val prop1: String) { fun f(): String = "$prop1#$prop2#$prop3" } -internal data class A2 private constructor() { +internal class A2 private constructor() { var prop1: String = "" var prop2: String = "const2" var prop3: String = "" diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/paramWithoutProperty.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/paramWithoutProperty.kt deleted file mode 100644 index 3ca0dc0ef32..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/copy/paramWithoutProperty.kt +++ /dev/null @@ -1,17 +0,0 @@ -data class A(a: Int, b: String) {} - -fun box() : String { - for (method in javaClass().getDeclaredMethods()) { - if (method.getName() == "copy"){ - val parameterTypes = method.getParameterTypes() - if (parameterTypes != null && parameterTypes.size() == 2) { - val copy = A(1, "a").copy(a = 2, b = "b") - return "OK" - } - else { - return "Method copy has " + (if (parameterTypes == null) "0" else parameterTypes.size()) + " parameters, expected 2" - } - } - } - return "fail" -} diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/sameinstance.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/sameinstance.kt index 35d3f17d2c4..04a1cfdc4f1 100644 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/sameinstance.kt +++ b/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/sameinstance.kt @@ -1,4 +1,4 @@ -data class A() +data class A(val arg: Any? = null) fun box() : String { val a = A() diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/null.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/null.kt index 7bde4f3e135..75777abec50 100644 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/null.kt +++ b/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/null.kt @@ -1,13 +1,13 @@ data class A(val a: Any?, var x: Int) -data class B(val a: Any?, x: Int) +data class B(val a: Any?) data class C(val a: Int, var x: Int?) data class D(val a: Int?) fun box() : String { if( A(null,19).hashCode() != 19) "fail" if( A(239,19).hashCode() != (239*31+19)) "fail" - if( B(null,19).hashCode() != 0) "fail" - if( B(239,19).hashCode() != 239) "fail" + if( B(null).hashCode() != 0) "fail" + if( B(239).hashCode() != 239) "fail" if( C(239,19).hashCode() != (239*31+19)) "fail" if( C(239,null).hashCode() != 239*31) "fail" if( D(239).hashCode() != (239)) "fail" diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/mixedParams.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/mixedParams.kt index ea3e99a6ffb..90637df9768 100644 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/mixedParams.kt +++ b/compiler/testData/codegen/boxWithStdlib/dataClasses/mixedParams.kt @@ -1,7 +1,7 @@ -data class A(var x: Int, y: Int, val z: Int) +data class A(var x: Int, val z: Int) fun box(): String { - val a = A(1, 2, 3) + val a = A(1, 3) if (a.component1() != 1) return "Fail: ${a.component1()}" if (a.component2() != 3) return "Fail: ${a.component2()}" return "OK" diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/alreadyInherited.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/alreadyInherited.kt deleted file mode 100644 index cc4b0195b07..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/alreadyInherited.kt +++ /dev/null @@ -1,10 +0,0 @@ -abstract class SuperTrait { - override fun toString(): String = "!" -} - -data class A(val x: Int): SuperTrait() { -} - -fun box(): String { - return if (A(0).toString() == "!") "OK" else "fail" -} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/mixedParams.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/mixedParams.kt index 2fb2ab314d1..a8e9b7dbd20 100644 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/mixedParams.kt +++ b/compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/mixedParams.kt @@ -1,7 +1,7 @@ -data class A(var x: Int, y: Int, val z: Int?) +data class A(var x: Int, val z: Int?) fun box(): String { - val a = A(1, 2, null) + val a = A(1, null) if("$a" != "A(x=1, z=null)") return "$a" return "OK" } diff --git a/compiler/testData/loadJava/compiledKotlin/dataClass/MixedComponents.kt b/compiler/testData/loadJava/compiledKotlin/dataClass/MixedComponents.kt index fd0740fb400..fca440c9134 100644 --- a/compiler/testData/loadJava/compiledKotlin/dataClass/MixedComponents.kt +++ b/compiler/testData/loadJava/compiledKotlin/dataClass/MixedComponents.kt @@ -1,3 +1,3 @@ package test -data class DataClass(var x: String, y: Int, val z: Double) +data class DataClass(var x: String, val z: Double) diff --git a/compiler/testData/loadJava/compiledKotlin/dataClass/MixedComponents.txt b/compiler/testData/loadJava/compiledKotlin/dataClass/MixedComponents.txt index 5bf1d501386..ea80c22c59f 100644 --- a/compiler/testData/loadJava/compiledKotlin/dataClass/MixedComponents.txt +++ b/compiler/testData/loadJava/compiledKotlin/dataClass/MixedComponents.txt @@ -1,7 +1,7 @@ package test @kotlin.data() public final class DataClass { - /*primary*/ public constructor DataClass(/*0*/ x: kotlin.String, /*1*/ y: kotlin.Int, /*2*/ z: kotlin.Double) + /*primary*/ public constructor DataClass(/*0*/ x: kotlin.String, /*1*/ z: kotlin.Double) public final var x: kotlin.String public final fun (): kotlin.String public final fun (/*0*/ : kotlin.String): kotlin.Unit @@ -9,5 +9,5 @@ package test public final fun (): kotlin.Double public final operator /*synthesized*/ fun component1(): kotlin.String public final operator /*synthesized*/ fun component2(): kotlin.Double - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.Int, /*2*/ z: kotlin.Double = ...): test.DataClass + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.String = ..., /*1*/ z: kotlin.Double = ...): test.DataClass } diff --git a/compiler/testData/loadJava/compiledKotlin/dataClass/NoComponents.kt b/compiler/testData/loadJava/compiledKotlin/dataClass/NoComponents.kt deleted file mode 100644 index 304cf456282..00000000000 --- a/compiler/testData/loadJava/compiledKotlin/dataClass/NoComponents.kt +++ /dev/null @@ -1,4 +0,0 @@ -package test - -data class DataClass -data class OtherDataClass() \ No newline at end of file diff --git a/compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt b/compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt deleted file mode 100644 index ba25eadce92..00000000000 --- a/compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt +++ /dev/null @@ -1,7 +0,0 @@ -//ALLOW_AST_ACCESS -package test - -data class A(foo: String, val bar: Int, other: Long) { - val foo = foo - val other = other -} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index 69adc8f5afe..5a6b03a7601 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -1516,12 +1516,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("kt6136_2.kt") - public void testKt6136_2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/classes/kt6136_2.kt"); - doTest(fileName); - } - @TestMetadata("kt6816.kt") public void testKt6816() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/classes/kt6816.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 028f3daa40c..296267723d2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -1212,12 +1212,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("paramWithoutProperty.kt") - public void testParamWithoutProperty() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/copy/paramWithoutProperty.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("valInConstructorParams.kt") public void testValInConstructorParams() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/copy/valInConstructorParams.kt"); @@ -1389,12 +1383,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("alreadyInherited.kt") - public void testAlreadyInherited() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/alreadyInherited.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("arrayParams.kt") public void testArrayParams() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/dataClasses/tostring/arrayParams.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index 47be4880763..b674c484046 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -2944,24 +2944,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledKotlin(fileName); } - @TestMetadata("NoComponents.kt") - public void testNoComponents() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/NoComponents.kt"); - doTestCompiledKotlin(fileName); - } - @TestMetadata("OneVal.kt") public void testOneVal() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OneVal.kt"); doTestCompiledKotlin(fileName); } - @TestMetadata("ParamNameSameToField.kt") - public void testParamNameSameToField() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt"); - doTestCompiledKotlin(fileName); - } - @TestMetadata("TwoVals.kt") public void testTwoVals() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/TwoVals.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java index 298c97a2ccd..16c83ecda48 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java @@ -1033,24 +1033,12 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith doTest(fileName); } - @TestMetadata("NoComponents.kt") - public void testNoComponents() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/NoComponents.kt"); - doTest(fileName); - } - @TestMetadata("OneVal.kt") public void testOneVal() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OneVal.kt"); doTest(fileName); } - @TestMetadata("ParamNameSameToField.kt") - public void testParamNameSameToField() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt"); - doTest(fileName); - } - @TestMetadata("TwoVals.kt") public void testTwoVals() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/TwoVals.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java index 17c469d2a74..349dc272d31 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java @@ -1035,24 +1035,12 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD doTest(fileName); } - @TestMetadata("NoComponents.kt") - public void testNoComponents() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/NoComponents.kt"); - doTest(fileName); - } - @TestMetadata("OneVal.kt") public void testOneVal() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OneVal.kt"); doTest(fileName); } - @TestMetadata("ParamNameSameToField.kt") - public void testParamNameSameToField() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt"); - doTest(fileName); - } - @TestMetadata("TwoVals.kt") public void testTwoVals() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/TwoVals.kt"); diff --git a/idea/testData/decompiler/decompiledText/Annotations.expected.kt b/idea/testData/decompiler/decompiledText/Annotations.expected.kt index 1b93e5b9614..505256ae69d 100644 --- a/idea/testData/decompiler/decompiledText/Annotations.expected.kt +++ b/idea/testData/decompiler/decompiledText/Annotations.expected.kt @@ -3,7 +3,7 @@ package test -@dependency.A @dependency.B @dependency.C @kotlin.data public final class Annotations public constructor() { +@dependency.A @dependency.B @dependency.C public final class Annotations public constructor() { @dependency.A @dependency.B @dependency.C @kotlin.inline public final val p: @dependency.B kotlin.Int /* compiled code */ @dependency.A @dependency.B @dependency.C @kotlin.inline public final fun f(@dependency.A @dependency.B @dependency.C i: @dependency.A kotlin.Int): kotlin.Unit { /* compiled code */ } diff --git a/idea/testData/decompiler/decompiledText/Annotations/Annotations.kt b/idea/testData/decompiler/decompiledText/Annotations/Annotations.kt index bed0344128d..963e55ac4f2 100644 --- a/idea/testData/decompiler/decompiledText/Annotations/Annotations.kt +++ b/idea/testData/decompiler/decompiledText/Annotations/Annotations.kt @@ -2,7 +2,7 @@ package test import dependency.* -data @A("a") @B(1) @C class Annotations { +@A("a") @B(1) @C class Annotations { inline @A("f") @B(2) @C fun f(@A("i") @B(3) @C i: @A("int") Int) { } diff --git a/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.after.kt b/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.after.kt index 65cdfa8653a..0fd14918ff4 100644 --- a/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.after.kt +++ b/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.after.kt @@ -9,7 +9,7 @@ class A @Ann(1)private constructor(x: Int) { inner class B() // do not insert here inner class C protected constructor() { fun foo() { - data class Local private constructor() + class Local private constructor() } } } diff --git a/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.before.Main.kt b/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.before.Main.kt index 318e99d9b81..deca0549e60 100644 --- a/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.before.Main.kt +++ b/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.before.Main.kt @@ -9,7 +9,7 @@ class A @Ann(1)private (x: Int) { inner class B() // do not insert here inner class C protected () { fun foo() { - data class Local private() + class Local private() } } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java index 45fd0ad0e7b..1f53f431670 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java @@ -1033,24 +1033,12 @@ public class ResolveByStubTestGenerated extends AbstractResolveByStubTest { doTest(fileName); } - @TestMetadata("NoComponents.kt") - public void testNoComponents() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/NoComponents.kt"); - doTest(fileName); - } - @TestMetadata("OneVal.kt") public void testOneVal() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/OneVal.kt"); doTest(fileName); } - @TestMetadata("ParamNameSameToField.kt") - public void testParamNameSameToField() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/ParamNameSameToField.kt"); - doTest(fileName); - } - @TestMetadata("TwoVals.kt") public void testTwoVals() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/dataClass/TwoVals.kt"); diff --git a/js/js.translator/testData/dataClass/cases/components.kt b/js/js.translator/testData/dataClass/cases/components.kt index de4b637d0a2..1be517430a4 100644 --- a/js/js.translator/testData/dataClass/cases/components.kt +++ b/js/js.translator/testData/dataClass/cases/components.kt @@ -1,6 +1,6 @@ package foo -data class Dat(val start: String, middle: String, val end: String) { +data class Dat(val start: String, val middle: String, val end: String) { fun getLabel() : String { return start + end } @@ -9,7 +9,7 @@ data class Dat(val start: String, middle: String, val end: String) { fun box(): String { val d = Dat("max", "-", "min") assertEquals("maxmin", d.getLabel()) - val (p1, p2) = d + val (p1, p, p2) = d assertEquals("max", p1) assertEquals("min", p2) return "OK" diff --git a/js/js.translator/testData/dataClass/cases/copy.kt b/js/js.translator/testData/dataClass/cases/copy.kt index b39744143c2..a5142a10039 100644 --- a/js/js.translator/testData/dataClass/cases/copy.kt +++ b/js/js.translator/testData/dataClass/cases/copy.kt @@ -1,11 +1,11 @@ package foo -data class Dat(val start: String, middle: String, val end: String) +data class Dat(val start: String, val middle: String, val end: String) fun box(): String { val d1 = Dat("OO", "-", "PS") val d2: Dat = d1.copy(end = "K", middle = "+") val d3: Dat = d2.copy(start = "O", middle = "-") - val (p1, p2) = d3 + val (p1, p, p2) = d3 return p1 + p2 } diff --git a/js/js.translator/testData/dataClass/cases/override.kt b/js/js.translator/testData/dataClass/cases/override.kt index 47dc899eca4..9e052b7709e 100644 --- a/js/js.translator/testData/dataClass/cases/override.kt +++ b/js/js.translator/testData/dataClass/cases/override.kt @@ -2,7 +2,7 @@ package foo var t: Any? = null -data class Dat(val start: String, middle: String, val end: String) { +data class Dat(val start: String, val middle: String, val end: String) { override fun toString() = "another string" override fun hashCode() = 371 override fun equals(other: Any?): Boolean { diff --git a/js/js.translator/testData/rtti/cases/collectionClassesIsCheck.kt b/js/js.translator/testData/rtti/cases/collectionClassesIsCheck.kt index 1e09f0fea12..b99972e8957 100644 --- a/js/js.translator/testData/rtti/cases/collectionClassesIsCheck.kt +++ b/js/js.translator/testData/rtti/cases/collectionClassesIsCheck.kt @@ -3,7 +3,7 @@ package foo import java.util.* -data class A +class A fun checkAbstractList(obj: Any) { assertTrue(obj is AbstractList<*>, "checkAbstractList: is AbstractList") diff --git a/plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/annotatedGettersSetters.kt b/plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/annotatedGettersSetters.kt index 590ac64f0c3..4e8e16a2e56 100644 --- a/plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/annotatedGettersSetters.kt +++ b/plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/annotatedGettersSetters.kt @@ -1,6 +1,6 @@ package org.test -public data class SomeClass { +public data class SomeClass(val arg: Any? = null) { public val immutableProperty: Int = 5 @java.lang.Deprecated get diff --git a/plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/annotations.txt b/plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/annotations.txt index 726d49dd5f9..dfd5d00c039 100644 --- a/plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/annotations.txt @@ -8,4 +8,9 @@ f 2 0/SomeClass mutableProperty m 1 0/SomeClass getMutableProperty m 2 0/SomeClass getMutableProperty m 1 0/SomeClass setMutableProperty +a org.jetbrains.annotations.Nullable 3 +f 3 0/SomeClass arg +m 3 0/SomeClass getArg +m 3 0/SomeClass component1 m 2 0/SomeClass copy +m 2 0/SomeClass copy$default diff --git a/plugins/annotation-collector/testData/collectToFile/defaultPackage/annotations.txt b/plugins/annotation-collector/testData/collectToFile/defaultPackage/annotations.txt index 0acc5c332d0..448be6bec88 100644 --- a/plugins/annotation-collector/testData/collectToFile/defaultPackage/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/defaultPackage/annotations.txt @@ -8,5 +8,9 @@ m 2 SomeClass getAnnotatedProperty m 1 SomeClass annotatedFunction a kotlin.inline 3 m 3 SomeClass annotatedFunction +f 2 SomeClass arg +m 2 SomeClass getArg +m 2 SomeClass component1 a org.jetbrains.annotations.NotNull 4 m 4 SomeClass copy +m 4 SomeClass copy$default diff --git a/plugins/annotation-collector/testData/collectToFile/defaultPackage/defaultPackage.kt b/plugins/annotation-collector/testData/collectToFile/defaultPackage/defaultPackage.kt index a24f39e9776..78a830a1ffc 100644 --- a/plugins/annotation-collector/testData/collectToFile/defaultPackage/defaultPackage.kt +++ b/plugins/annotation-collector/testData/collectToFile/defaultPackage/defaultPackage.kt @@ -1,4 +1,4 @@ -data public class SomeClass { +data public class SomeClass(val arg: Any? = null) { @java.lang.Deprecated public var annotatedProperty: String? = null