open + data and inner + data are deprecated, a new test, relevant test fixes
This commit is contained in:
@@ -110,6 +110,7 @@ public interface Errors {
|
||||
// Modifiers
|
||||
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, JetModifierKeywordToken> INCOMPATIBLE_MODIFIERS = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, JetModifierKeywordToken> DEPRECATED_MODIFIER_PAIR = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, JetModifierKeywordToken> REPEATED_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, JetModifierKeywordToken> REDUNDANT_MODIFIER = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, String> WRONG_MODIFIER_TARGET = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
+1
@@ -118,6 +118,7 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(TYPE_MISMATCH, "Type mismatch: inferred type is {1} but {0} was expected", RENDER_TYPE, RENDER_TYPE);
|
||||
MAP.put(INCOMPATIBLE_MODIFIERS, "Modifier ''{0}'' is incompatible with ''{1}''", TO_STRING, TO_STRING);
|
||||
MAP.put(DEPRECATED_MODIFIER_PAIR, "Modifier ''{0}'' is deprecated in presense of ''{1}''", TO_STRING, TO_STRING);
|
||||
MAP.put(REPEATED_MODIFIER, "Repeated ''{0}''", TO_STRING);
|
||||
MAP.put(WRONG_MODIFIER_TARGET, "Modifier ''{0}'' is not applicable to ''{1}''", TO_STRING, TO_STRING);
|
||||
MAP.put(REDUNDANT_MODIFIER_FOR_TARGET, "Modifier ''{0}'' is redundant for ''{1}''", TO_STRING, TO_STRING);
|
||||
|
||||
@@ -34,6 +34,7 @@ public object ModifierCheckerCore {
|
||||
REDUNDANT,
|
||||
REVERSE_REDUNDANT,
|
||||
REPEATED,
|
||||
DEPRECATED,
|
||||
INCOMPATIBLE
|
||||
}
|
||||
|
||||
@@ -99,6 +100,9 @@ public object ModifierCheckerCore {
|
||||
result += incompatibilityRegister(PRIVATE_KEYWORD, PROTECTED_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD)
|
||||
// Abstract + open + final + sealed: incompatible
|
||||
result += incompatibilityRegister(ABSTRACT_KEYWORD, OPEN_KEYWORD, FINAL_KEYWORD, SEALED_KEYWORD)
|
||||
// data + open, data + inner
|
||||
result += deprecationRegister(DATA_KEYWORD, OPEN_KEYWORD)
|
||||
result += deprecationRegister(DATA_KEYWORD, INNER_KEYWORD)
|
||||
// open is redundant to abstract & override
|
||||
result += redundantRegister(ABSTRACT_KEYWORD, OPEN_KEYWORD)
|
||||
result += redundantRegister(OVERRIDE_KEYWORD, OPEN_KEYWORD)
|
||||
@@ -120,20 +124,24 @@ public object ModifierCheckerCore {
|
||||
Pair(redundant, sufficient) to Compatibility.REVERSE_REDUNDANT)
|
||||
}
|
||||
|
||||
private fun incompatibilityRegister(
|
||||
vararg list: JetModifierKeywordToken
|
||||
private fun compatibilityRegister(
|
||||
compatibility: Compatibility, vararg list: JetModifierKeywordToken
|
||||
): Map<Pair<JetModifierKeywordToken, JetModifierKeywordToken>, Compatibility> {
|
||||
val result = hashMapOf<Pair<JetModifierKeywordToken, JetModifierKeywordToken>, Compatibility>()
|
||||
for (first in list) {
|
||||
for (second in list) {
|
||||
if (first != second) {
|
||||
result[Pair(first, second)] = Compatibility.INCOMPATIBLE
|
||||
result[Pair(first, second)] = compatibility
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun incompatibilityRegister(vararg list: JetModifierKeywordToken) = compatibilityRegister(Compatibility.INCOMPATIBLE, *list)
|
||||
|
||||
private fun deprecationRegister(vararg list: JetModifierKeywordToken) = compatibilityRegister(Compatibility.DEPRECATED, *list)
|
||||
|
||||
private fun compatibility(first: JetModifierKeywordToken, second: JetModifierKeywordToken): Compatibility {
|
||||
if (first == second) {
|
||||
return Compatibility.REPEATED
|
||||
@@ -158,6 +166,14 @@ public object ModifierCheckerCore {
|
||||
Compatibility.REVERSE_REDUNDANT -> if (incorrectNodes.add(firstNode)) {
|
||||
trace.report(Errors.REDUNDANT_MODIFIER.on(firstNode.psi, second, first))
|
||||
}
|
||||
Compatibility.DEPRECATED -> {
|
||||
if (incorrectNodes.add(firstNode)) {
|
||||
trace.report(Errors.DEPRECATED_MODIFIER_PAIR.on(firstNode.psi, first, second))
|
||||
}
|
||||
if (incorrectNodes.add(secondNode)) {
|
||||
trace.report(Errors.DEPRECATED_MODIFIER_PAIR.on(secondNode.psi, second, first))
|
||||
}
|
||||
}
|
||||
Compatibility.INCOMPATIBLE -> {
|
||||
if (incorrectNodes.add(firstNode)) {
|
||||
trace.report(Errors.INCOMPATIBLE_MODIFIERS.on(firstNode.psi, first, second))
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
open data class A(private val x: Int)
|
||||
<!DEPRECATED_MODIFIER_PAIR!>open<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class A(private val x: Int)
|
||||
|
||||
class B : A(1) {
|
||||
fun component1(): String = ""
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
open data class A(private val x: Int, protected val y: String, public val z: Any)
|
||||
|
||||
fun foo(a: A) {
|
||||
a.<!INVISIBLE_MEMBER!>component1<!>()
|
||||
a.<!INVISIBLE_MEMBER!>component2<!>()
|
||||
a.component3()
|
||||
}
|
||||
|
||||
class B : A(42, "", "") {
|
||||
fun foo() {
|
||||
this.<!INVISIBLE_MEMBER!>component1<!>()
|
||||
this.component2()
|
||||
this.component3()
|
||||
}
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ a: A): kotlin.Unit
|
||||
|
||||
@kotlin.data() public open class A {
|
||||
public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String, /*2*/ z: kotlin.Any)
|
||||
private final val x: kotlin.Int
|
||||
protected final val y: kotlin.String
|
||||
public final val z: kotlin.Any
|
||||
private final /*synthesized*/ fun component1(): kotlin.Int
|
||||
protected final /*synthesized*/ fun component2(): kotlin.String
|
||||
public final /*synthesized*/ fun component3(): kotlin.Any
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.Any = ...): 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
|
||||
protected final override /*1*/ /*fake_override*/ val y: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val z: kotlin.Any
|
||||
invisible_fake final override /*1*/ /*fake_override*/ fun component1(): kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun component2(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun component3(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.Any = ...): A
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
open data class A(val x: Int, val y: String)
|
||||
|
||||
class B : A(42, "OK") {
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun component1(): Int = 21
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun component2(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Int<!> = 21
|
||||
}
|
||||
|
||||
fun foo(b: B) {
|
||||
b.component1()
|
||||
b.component2()
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ b: B): kotlin.Unit
|
||||
|
||||
@kotlin.data() public open class A {
|
||||
public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String)
|
||||
public final val x: kotlin.Int
|
||||
public final val y: kotlin.String
|
||||
public final /*synthesized*/ fun component1(): kotlin.Int
|
||||
public final /*synthesized*/ fun component2(): 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
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
public constructor B()
|
||||
public final override /*1*/ /*fake_override*/ val x: kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ val y: kotlin.String
|
||||
public open override /*1*/ fun component1(): kotlin.Int
|
||||
public open override /*1*/ fun component2(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ 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
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
open data class A(val x: Int, val y: String)
|
||||
|
||||
<!DATA_CLASS_OVERRIDE_CONFLICT!>data<!> class B(val z: String) : A(42, "")
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package
|
||||
|
||||
@kotlin.data() public open class A {
|
||||
public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String)
|
||||
public final val x: kotlin.Int
|
||||
public final val y: kotlin.String
|
||||
public final /*synthesized*/ fun component1(): kotlin.Int
|
||||
public final /*synthesized*/ fun component2(): 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
|
||||
}
|
||||
|
||||
@kotlin.data() public final class B : A {
|
||||
public constructor B(/*0*/ z: kotlin.String)
|
||||
public final override /*1*/ /*fake_override*/ val x: kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ val y: kotlin.String
|
||||
public final val z: kotlin.String
|
||||
public final override /*1*/ /*synthesized*/ fun component1(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun component2(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ...): A
|
||||
public final /*synthesized*/ fun copy(/*0*/ z: kotlin.String = ...): B
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Outer {
|
||||
<!DEPRECATED_MODIFIER_PAIR!>inner<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class Inner(val x: Int)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
public final class Outer {
|
||||
public constructor Outer()
|
||||
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 inner class Inner {
|
||||
public constructor Inner(/*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 = ...): Outer.Inner
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
open data class D(private final val x: Int)
|
||||
|
||||
data class E(internal <!CANNOT_OVERRIDE_INVISIBLE_MEMBER!>override<!> val x: Int) : D(42)
|
||||
@@ -1,21 +0,0 @@
|
||||
package
|
||||
|
||||
@kotlin.data() public open class D {
|
||||
public constructor D(/*0*/ x: kotlin.Int)
|
||||
private final val x: kotlin.Int
|
||||
private final /*synthesized*/ fun component1(): kotlin.Int
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): D
|
||||
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 E : D {
|
||||
public constructor E(/*0*/ x: kotlin.Int)
|
||||
internal open val x: kotlin.Int
|
||||
internal final /*synthesized*/ fun component1(): kotlin.Int
|
||||
public final override /*1*/ /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): E
|
||||
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
|
||||
}
|
||||
@@ -14,7 +14,7 @@ fun foo(map: MutableMap<Int, String>, value: String?) {
|
||||
|
||||
//---------------------------
|
||||
|
||||
public data open class Tag(public var tagName: String) {
|
||||
public data class Tag(public var tagName: String) {
|
||||
public val attributes: MutableMap<String, String> = HashMap<String, String>()
|
||||
public val contents: MutableList<Tag> = arrayListOf()
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ package a {
|
||||
public fun foo(/*0*/ map: kotlin.MutableMap<kotlin.Int, kotlin.String>, /*1*/ value: kotlin.String?): kotlin.Unit
|
||||
public fun </*0*/ K, /*1*/ V> kotlin.MutableMap<K, V>.set(/*0*/ key: K, /*1*/ value: V): V?
|
||||
|
||||
@kotlin.data() public open class Tag {
|
||||
@kotlin.data() public final class Tag {
|
||||
public constructor Tag(/*0*/ tagName: kotlin.String)
|
||||
public final val attributes: kotlin.MutableMap<kotlin.String, kotlin.String>
|
||||
public final val contents: kotlin.MutableList<a.Tag>
|
||||
|
||||
@@ -3306,18 +3306,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("componentFunctionVisibility.kt")
|
||||
public void testComponentFunctionVisibility() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/componentFunctionVisibility.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("componentFunctionsAreFinal.kt")
|
||||
public void testComponentFunctionsAreFinal() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/componentFunctionsAreFinal.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("componentNamedComponent1.kt")
|
||||
public void testComponentNamedComponent1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/componentNamedComponent1.kt");
|
||||
@@ -3342,12 +3330,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClassOverrideConflict.kt")
|
||||
public void testDataClassOverrideConflict() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/dataClassOverrideConflict.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("emptyConstructor.kt")
|
||||
public void testEmptyConstructor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/emptyConstructor.kt");
|
||||
@@ -3378,6 +3360,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("innerDataClass.kt")
|
||||
public void testInnerDataClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/innerDataClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multiDeclaration.kt")
|
||||
public void testMultiDeclaration() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/multiDeclaration.kt");
|
||||
@@ -3408,12 +3396,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("overrideInvisibleMember.kt")
|
||||
public void testOverrideInvisibleMember() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/overrideInvisibleMember.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("paramNameSameToField.kt")
|
||||
public void testParamNameSameToField() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/paramNameSameToField.kt");
|
||||
|
||||
Reference in New Issue
Block a user