From 55c7df8b8ddace8d5c83b6842535e48947d07d32 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 22 Sep 2015 13:25:37 +0300 Subject: [PATCH] Deprecations: data class should now have at least one primary constructor parameter, parameters should be val / var and not vararg. --- .../jetbrains/kotlin/diagnostics/Errors.java | 4 ++ .../rendering/DefaultErrorMessages.java | 4 ++ .../resolve/DataClassAnnotationChecker.kt | 13 ++++++ .../tests/annotations/options/target.kt | 3 +- .../tests/annotations/options/target.txt | 6 ++- .../dataClasses/bothParamsAreNotProperties.kt | 6 --- .../bothParamsAreNotProperties.txt | 11 ----- .../tests/dataClasses/dataClassVarargParam.kt | 3 ++ .../dataClasses/dataClassVarargParam.txt | 21 ++++++++++ .../tests/dataClasses/dataInheritance.kt | 2 +- .../tests/dataClasses/dataInheritance.txt | 6 ++- .../tests/dataClasses/emptyConstructor.kt | 2 +- .../tests/dataClasses/firstParamIsVal.kt | 8 ---- .../tests/dataClasses/firstParamIsVal.txt | 13 ------ .../tests/dataClasses/firstParamIsVar.kt | 8 ---- .../tests/dataClasses/firstParamIsVar.txt | 13 ------ .../tests/dataClasses/noConstructor.kt | 2 +- .../tests/dataClasses/paramNameSameToField.kt | 10 ----- .../dataClasses/paramNameSameToField.txt | 15 ------- .../tests/dataClasses/secondParamIsVal.kt | 8 ---- .../tests/dataClasses/secondParamIsVal.txt | 13 ------ .../tests/dataClasses/secondParamIsVar.kt | 8 ---- .../tests/dataClasses/secondParamIsVar.txt | 13 ------ .../tests/enum/enumWithAnnotationKeyword.kt | 2 +- .../tests/enum/enumWithAnnotationKeyword.txt | 3 +- .../secondaryConstructors/dataClasses.kt | 6 +-- .../secondaryConstructors/dataClasses.txt | 8 +++- .../checkers/JetDiagnosticsTestGenerated.java | 42 +++---------------- .../checker/rendering/TypeInferenceError.kt | 2 +- 29 files changed, 75 insertions(+), 180 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/bothParamsAreNotProperties.kt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/bothParamsAreNotProperties.txt create mode 100644 compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.kt create mode 100644 compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.txt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.txt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.kt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.txt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.kt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.txt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.txt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.kt delete mode 100644 compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 1fb17471519..491a8c1e1d8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -382,6 +382,10 @@ public interface Errors { DiagnosticFactory2, Integer> DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES = DiagnosticFactory2.create(WARNING, DECLARATION_NAME); + 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); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Errors/warnings inside code blocks 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 e83b45f3ce7..622bbf69640 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -622,6 +622,10 @@ public class DefaultErrorMessages { "Names of the parameter #{1} conflict in the following members of supertypes: ''{0}''. " + "This may cause problems when calling this function with named arguments.", commaSeparated(FQ_NAMES_IN_TYPES), TO_STRING); + 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(AMBIGUOUS_ANONYMOUS_TYPE_INFERRED, "Right-hand side has anonymous type. Please specify type explicitly", TO_STRING); MAP.put(EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DataClassAnnotationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DataClassAnnotationChecker.kt index 68e44ff29c3..bc114b429e5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DataClassAnnotationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DataClassAnnotationChecker.kt @@ -36,6 +36,19 @@ public class DataClassAnnotationChecker : DeclarationChecker { if (descriptor.getUnsubstitutedPrimaryConstructor() == null && descriptor.getConstructors().isNotEmpty()) { diagnosticHolder.report(Errors.PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS.on(declaration.getNameIdentifier())); } + val primaryConstructor = declaration.getPrimaryConstructor() + val parameters = primaryConstructor?.valueParameters ?: emptyList() + if (parameters.isEmpty()) { + diagnosticHolder.report(Errors.DATA_CLASS_WITHOUT_PARAMETERS.on(declaration.nameIdentifier!!)) + } + for (parameter in parameters) { + if (parameter.isVarArg) { + diagnosticHolder.report(Errors.DATA_CLASS_VARARG_PARAMETER.on(parameter)) + } + if (!parameter.hasValOrVar()) { + diagnosticHolder.report(Errors.DATA_CLASS_NOT_PROPERTY_PARAMETER.on(parameter)) + } + } } } } diff --git a/compiler/testData/diagnostics/tests/annotations/options/target.kt b/compiler/testData/diagnostics/tests/annotations/options/target.kt index 100f5def653..107ff9bb57f 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/target.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/target.kt @@ -1,5 +1,4 @@ @Target(AnnotationTarget.CLASS) annotation class base -@base data class My - +@base data class My(val x: Int) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/target.txt b/compiler/testData/diagnostics/tests/annotations/options/target.txt index 7e1ed13f34c..be92c218594 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/target.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/target.txt @@ -1,8 +1,10 @@ package @base() @kotlin.data() public final class My { - public constructor My() - public final /*synthesized*/ fun copy(): My + public constructor My(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + public final /*synthesized*/ fun component1(): kotlin.Int + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): My 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/bothParamsAreNotProperties.kt b/compiler/testData/diagnostics/tests/dataClasses/bothParamsAreNotProperties.kt deleted file mode 100644 index 1b5ffc296ab..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/bothParamsAreNotProperties.kt +++ /dev/null @@ -1,6 +0,0 @@ -data class A(x: Int, y: String) - -fun foo(a: A) { - a.component1() - a.component2() -} diff --git a/compiler/testData/diagnostics/tests/dataClasses/bothParamsAreNotProperties.txt b/compiler/testData/diagnostics/tests/dataClasses/bothParamsAreNotProperties.txt deleted file mode 100644 index 227e32f1604..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/bothParamsAreNotProperties.txt +++ /dev/null @@ -1,11 +0,0 @@ -package - -public fun foo(/*0*/ a: A): kotlin.Unit - -@kotlin.data() public final class A { - public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String) - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): 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/dataClassVarargParam.kt b/compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.kt new file mode 100644 index 00000000000..305fc4bac2e --- /dev/null +++ b/compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.kt @@ -0,0 +1,3 @@ +data class My(val x: Int, vararg val y: String) + +data class Your(vararg z: String) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.txt b/compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.txt new file mode 100644 index 00000000000..8309972d047 --- /dev/null +++ b/compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.txt @@ -0,0 +1,21 @@ +package + +@kotlin.data() public final class My { + public constructor My(/*0*/ x: kotlin.Int, /*1*/ vararg y: kotlin.String /*kotlin.Array*/) + public final val x: kotlin.Int + public final val y: kotlin.Array + public final /*synthesized*/ fun component1(): kotlin.Int + public final /*synthesized*/ fun component2(): kotlin.Array + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ vararg y: kotlin.String /*kotlin.Array*/ = ...): My + 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 +} + +@kotlin.data() public final class Your { + public constructor Your(/*0*/ vararg z: kotlin.String /*kotlin.Array*/) + public final /*synthesized*/ fun copy(/*0*/ vararg z: kotlin.String /*kotlin.Array*/): Your + 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 febb8647226..567d779fc4d 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt @@ -6,6 +6,6 @@ open class NotAllowed class Derived: Base(42) -data class Nasty(x: Int, val y: Int): Base(x) +data class Nasty(val z: Int, val y: Int): Base(z) data class Complex(val y: Int): Allowed, NotAllowed() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.txt b/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.txt index bc5eb8a0d1d..719dcc338c6 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.txt +++ b/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.txt @@ -37,12 +37,14 @@ public final class Derived : Base { } @kotlin.data() public final class Nasty : Base { - public constructor Nasty(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + public constructor Nasty(/*0*/ z: kotlin.Int, /*1*/ y: kotlin.Int) public final override /*1*/ /*fake_override*/ val x: kotlin.Int public final val y: kotlin.Int + public final val z: kotlin.Int public final override /*1*/ /*synthesized*/ fun component1(): kotlin.Int + public final /*synthesized*/ fun component2(): kotlin.Int public final override /*1*/ /*fake_override*/ fun copy(/*0*/ x: kotlin.Int = ...): Base - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): Nasty + public final /*synthesized*/ fun copy(/*0*/ z: kotlin.Int = ..., /*1*/ y: kotlin.Int = ...): Nasty 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/emptyConstructor.kt b/compiler/testData/diagnostics/tests/dataClasses/emptyConstructor.kt index ef979927e6d..19d78815006 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/emptyConstructor.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/emptyConstructor.kt @@ -1,4 +1,4 @@ -data class A() +data class A() fun foo(a: A) { a.component1() diff --git a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt b/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt deleted file mode 100644 index 881ddc7460d..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt +++ /dev/null @@ -1,8 +0,0 @@ -// !CHECK_TYPE - -data class A(val x: Int, y: String) - -fun foo(a: A) { - checkSubtype(a.component1()) - a.component2() -} diff --git a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.txt b/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.txt deleted file mode 100644 index 0e4f981bffb..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -public fun foo(/*0*/ a: A): kotlin.Unit - -@kotlin.data() public final class A { - public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String) - public final val x: kotlin.Int - public final /*synthesized*/ fun component1(): kotlin.Int - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String): 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/firstParamIsVar.kt b/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.kt deleted file mode 100644 index 4e66f1b80c0..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.kt +++ /dev/null @@ -1,8 +0,0 @@ -// !CHECK_TYPE - -data class A(var x: Int, y: String) - -fun foo(a: A) { - checkSubtype(a.component1()) - a.component2() -} diff --git a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.txt b/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.txt deleted file mode 100644 index d3714b219e7..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -public fun foo(/*0*/ a: A): kotlin.Unit - -@kotlin.data() public final class A { - public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String) - public final var x: kotlin.Int - public final /*synthesized*/ fun component1(): kotlin.Int - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String): 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/noConstructor.kt b/compiler/testData/diagnostics/tests/dataClasses/noConstructor.kt index ddaab4d82a9..d8bff653d3b 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/noConstructor.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/noConstructor.kt @@ -1,4 +1,4 @@ -data class A +data class A fun foo(a: A) { a.component1() diff --git a/compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.kt b/compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.kt deleted file mode 100644 index d95b6a261b9..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.kt +++ /dev/null @@ -1,10 +0,0 @@ -data class A(foo: String, val bar: Int, other: Long) { - val foo = foo - val other = other -} - -fun test(a: A) { - a.component1() - a.component2() - a.component3() -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.txt b/compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.txt deleted file mode 100644 index 1fcd8ac7d7c..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.txt +++ /dev/null @@ -1,15 +0,0 @@ -package - -public fun test(/*0*/ a: A): kotlin.Unit - -@kotlin.data() public final class A { - public constructor A(/*0*/ foo: kotlin.String, /*1*/ bar: kotlin.Int, /*2*/ other: kotlin.Long) - public final val bar: kotlin.Int - public final val foo: kotlin.String - public final val other: kotlin.Long - public final /*synthesized*/ fun component1(): kotlin.Int - public final /*synthesized*/ fun copy(/*0*/ foo: kotlin.String, /*1*/ bar: kotlin.Int = ..., /*2*/ other: kotlin.Long): 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/secondParamIsVal.kt b/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt deleted file mode 100644 index a4202f6b91b..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt +++ /dev/null @@ -1,8 +0,0 @@ -// !CHECK_TYPE - -data class A(x: Int, val y: String) - -fun foo(a: A) { - checkSubtype(a.component1()) - a.component2() -} diff --git a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.txt b/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.txt deleted file mode 100644 index d14928ff439..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -public fun foo(/*0*/ a: A): kotlin.Unit - -@kotlin.data() public final class A { - public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String) - public final val y: kotlin.String - public final /*synthesized*/ fun component1(): kotlin.String - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): 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/secondParamIsVar.kt b/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.kt deleted file mode 100644 index 28effe82887..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.kt +++ /dev/null @@ -1,8 +0,0 @@ -// !CHECK_TYPE - -data class A(x: Int, var y: String) - -fun foo(a: A) { - checkSubtype(a.component1()) - a.component2() -} diff --git a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.txt b/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.txt deleted file mode 100644 index c6d90a998ee..00000000000 --- a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -public fun foo(/*0*/ a: A): kotlin.Unit - -@kotlin.data() public final class A { - public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String) - public final var y: kotlin.String - public final /*synthesized*/ fun component1(): kotlin.String - public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): 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/enum/enumWithAnnotationKeyword.kt b/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.kt index 3cc8fc2dddd..e22f4be0964 100644 --- a/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.kt +++ b/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.kt @@ -1,3 +1,3 @@ -data annotation enum class E { +annotation enum class E { D } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.txt b/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.txt index b31c164b1d1..686d1c0452e 100644 --- a/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.txt +++ b/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.txt @@ -1,12 +1,11 @@ package -@kotlin.data() @kotlin.annotation.annotation() public final enum class E : kotlin.Enum { +@kotlin.annotation.annotation() public final enum class E : kotlin.Enum { enum entry D private constructor E() protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int - public final /*synthesized*/ fun copy(): E public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public final override /*1*/ /*fake_override*/ fun name(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/dataClasses.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/dataClasses.kt index 76d76fa977c..e15c8607ba5 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/dataClasses.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/dataClasses.kt @@ -3,10 +3,10 @@ data class A1(val x: String) { constructor(): this("") } -data class A2() { - constructor(x: String): this() +data class A2(val y: String, val z: Int) { + constructor(x: String): this(x, 0) } -data class A3 { +data class A3 { constructor() } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/dataClasses.txt b/compiler/testData/diagnostics/tests/secondaryConstructors/dataClasses.txt index edd8acc71d3..4524d738d8a 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/dataClasses.txt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/dataClasses.txt @@ -12,9 +12,13 @@ package } @kotlin.data() public final class A2 { - public constructor A2() public constructor A2(/*0*/ x: kotlin.String) - public final /*synthesized*/ fun copy(): A2 + public constructor A2(/*0*/ y: kotlin.String, /*1*/ z: kotlin.Int) + public final val y: kotlin.String + public final val z: kotlin.Int + public final /*synthesized*/ fun component1(): kotlin.String + public final /*synthesized*/ fun component2(): kotlin.Int + public final /*synthesized*/ fun copy(/*0*/ y: kotlin.String = ..., /*1*/ z: kotlin.Int = ...): A2 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/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 44ddcffb745..97ebc2af3a9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -3294,12 +3294,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/dataClasses"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("bothParamsAreNotProperties.kt") - public void testBothParamsAreNotProperties() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/bothParamsAreNotProperties.kt"); - doTest(fileName); - } - @TestMetadata("componentFunctionInSubClass.kt") public void testComponentFunctionInSubClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt"); @@ -3330,6 +3324,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("dataClassVarargParam.kt") + public void testDataClassVarargParam() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.kt"); + doTest(fileName); + } + @TestMetadata("dataInheritance.kt") public void testDataInheritance() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt"); @@ -3342,18 +3342,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } - @TestMetadata("firstParamIsVal.kt") - public void testFirstParamIsVal() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt"); - doTest(fileName); - } - - @TestMetadata("firstParamIsVar.kt") - public void testFirstParamIsVar() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.kt"); - doTest(fileName); - } - @TestMetadata("implementTraitWhichHasComponent1.kt") public void testImplementTraitWhichHasComponent1() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/implementTraitWhichHasComponent1.kt"); @@ -3402,12 +3390,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } - @TestMetadata("paramNameSameToField.kt") - public void testParamNameSameToField() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.kt"); - doTest(fileName); - } - @TestMetadata("repeatedProperties.kt") public void testRepeatedProperties() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.kt"); @@ -3420,18 +3402,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } - @TestMetadata("secondParamIsVal.kt") - public void testSecondParamIsVal() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt"); - doTest(fileName); - } - - @TestMetadata("secondParamIsVar.kt") - public void testSecondParamIsVar() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.kt"); - doTest(fileName); - } - @TestMetadata("twoValParams.kt") public void testTwoValParams() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/twoValParams.kt"); diff --git a/idea/testData/checker/rendering/TypeInferenceError.kt b/idea/testData/checker/rendering/TypeInferenceError.kt index 378d8003bf1..ac769f3af89 100644 --- a/idea/testData/checker/rendering/TypeInferenceError.kt +++ b/idea/testData/checker/rendering/TypeInferenceError.kt @@ -8,4 +8,4 @@ fun foo() { //extract from library fun hashMap(p: Pair): MutableMap {} fun K.to(v: V): Pair {} -data class Pair {} \ No newline at end of file +class Pair {} \ No newline at end of file