data modifier is now inapplicable to enum classes, annotations, objects and interfaces #KT-8302 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-09-23 13:04:13 +03:00
parent 315a304c8e
commit 789f351f6f
5 changed files with 66 additions and 3 deletions
@@ -59,7 +59,7 @@ public object ModifierCheckerCore {
VARARG_KEYWORD to EnumSet.of(VALUE_PARAMETER, PROPERTY_PARAMETER),
COMPANION_KEYWORD to EnumSet.of(OBJECT),
LATE_INIT_KEYWORD to EnumSet.of(MEMBER_PROPERTY),
DATA_KEYWORD to EnumSet.of(CLASS),
DATA_KEYWORD to EnumSet.of(CLASS_ONLY, INNER_CLASS, LOCAL_CLASS),
INLINE_KEYWORD to EnumSet.of(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, PROPERTY),
NOINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER),
TAILREC_KEYWORD to EnumSet.of(FUNCTION),
@@ -0,0 +1,10 @@
<!WRONG_MODIFIER_TARGET!>data<!> enum class First(val x: Int) {
A(1),
B(2)
}
<!WRONG_MODIFIER_TARGET!>data<!> object <!DATA_CLASS_WITHOUT_PARAMETERS!>Second<!>
<!WRONG_MODIFIER_TARGET!>data<!> interface <!DATA_CLASS_WITHOUT_PARAMETERS!>Third<!>
<!WRONG_MODIFIER_TARGET!>data<!> annotation class Fourth(val x: Int)
@@ -0,0 +1,47 @@
package
@kotlin.data() public final enum class First : kotlin.Enum<First> {
enum entry A
enum entry B
private constructor First(/*0*/ x: kotlin.Int)
public final val x: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: First): kotlin.Int
public final /*synthesized*/ fun component1(): kotlin.Int
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): First
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
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): First
public final /*synthesized*/ fun values(): kotlin.Array<First>
}
@kotlin.data() @kotlin.annotation.annotation() public final class Fourth : kotlin.Annotation {
public constructor Fourth(/*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 = ...): Fourth
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 object Second {
private constructor Second()
public final /*synthesized*/ fun copy(): Second
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 interface Third {
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
}
@@ -3408,6 +3408,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("strange.kt")
public void testStrange() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/strange.kt");
doTest(fileName);
}
@TestMetadata("twoValParams.kt")
public void testTwoValParams() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/twoValParams.kt");
@@ -9,13 +9,13 @@ interface Type {
protected fun String.withSuffix(): String = if (nullable) "$this?" else this
}
data object UnitType : Type {
object UnitType : Type {
override val nullable: Boolean
get() = false
override fun render() = "Unit"
}
data object DynamicType : Type {
object DynamicType : Type {
override val nullable: Boolean
get() = false