data + open / inner / abstract / sealed are now forbidden
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3725ef8cdf
commit
fff434d377
@@ -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)
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ interface Id<T> {
|
||||
val id: T
|
||||
}
|
||||
|
||||
open data class Actor (
|
||||
data class Actor (
|
||||
override val id: Int,
|
||||
val firstName: String,
|
||||
val lastName: String
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ interface Id<T> {
|
||||
val id: T
|
||||
}
|
||||
|
||||
open data class Actor (
|
||||
data class Actor (
|
||||
id: Int,
|
||||
val firstName: String,
|
||||
val lastName: String
|
||||
|
||||
-15
@@ -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()
|
||||
}
|
||||
+3
-1
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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())
|
||||
}
|
||||
-11
@@ -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"
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
<!DEPRECATED_MODIFIER_PAIR!>open<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class A(private val x: Int)
|
||||
|
||||
class B : A(1) {
|
||||
fun component1(): String = ""
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val b = B()
|
||||
checkSubtype<String>(b.component1())
|
||||
checkSubtype<Int>((checkSubtype<A>(b)).<!INVISIBLE_MEMBER!>component1<!>())
|
||||
}
|
||||
-23
@@ -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
|
||||
}
|
||||
@@ -2,7 +2,7 @@ interface Allowed
|
||||
|
||||
open class NotAllowed
|
||||
|
||||
<!DEPRECATED_MODIFIER_PAIR!>abstract<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class Base(val x: Int)
|
||||
<!INCOMPATIBLE_MODIFIERS!>abstract<!> <!INCOMPATIBLE_MODIFIERS!>data<!> class Base(val x: Int)
|
||||
|
||||
class Derived: Base(42)
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class Outer {
|
||||
<!DEPRECATED_MODIFIER_PAIR!>inner<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class Inner(val x: Int)
|
||||
<!INCOMPATIBLE_MODIFIERS!>inner<!> <!INCOMPATIBLE_MODIFIERS!>data<!> class Inner(val x: Int)
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
<!WRONG_MODIFIER_CONTAINING_DECLARATION, DEPRECATED_MODIFIER_PAIR!>inner<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class Outer(val x: Int)
|
||||
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>inner<!> <!INCOMPATIBLE_MODIFIERS!>data<!> class Outer(val x: Int)
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DEPRECATED_MODIFIER_PAIR!>sealed<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class My(val x: Int) {
|
||||
<!INCOMPATIBLE_MODIFIERS!>sealed<!> <!INCOMPATIBLE_MODIFIERS!>data<!> class My(val x: Int) {
|
||||
object Your: My(1)
|
||||
class His(y: Int): My(y)
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package test
|
||||
|
||||
open data class DataClass(val x: String)
|
||||
@@ -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 <get-x>(): kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.String
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.String = ...): test.DataClass
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package test
|
||||
|
||||
open data class DataClass(open val x: String)
|
||||
-9
@@ -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 <get-x>(): kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.String
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.String = ...): test.DataClass
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
-24
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
-12
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user