Report errors about incompatible constructors of actual class
#KT-20540 In Progress #KT-20680 In Progress
This commit is contained in:
+9
-5
@@ -131,12 +131,16 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
|
|||||||
|
|
||||||
val hasActualModifier = descriptor.isActual && reportOn.hasActualModifier()
|
val hasActualModifier = descriptor.isActual && reportOn.hasActualModifier()
|
||||||
if (!hasActualModifier) {
|
if (!hasActualModifier) {
|
||||||
if (Compatible !in compatibility) return
|
if (compatibility.isEmpty()) return
|
||||||
|
|
||||||
// we suppress error, because annotation classes can only have one constructor and it's a 100% boilerplate
|
if (Compatible in compatibility) {
|
||||||
// to require every annotation constructor with additional parameters with default values be marked with the `actual` modifier
|
// we suppress error, because annotation classes can only have one constructor and it's a 100% boilerplate
|
||||||
if (checkActual && !descriptor.isAnnotationConstructor()) {
|
// to require every annotation constructor with additional parameters with default values be marked with the `actual` modifier
|
||||||
diagnosticHolder.report(Errors.ACTUAL_MISSING.on(reportOn))
|
if (checkActual && !descriptor.isAnnotationConstructor()) {
|
||||||
|
diagnosticHolder.report(Errors.ACTUAL_MISSING.on(reportOn))
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -7,6 +7,8 @@ expect annotation class Foo2
|
|||||||
expect annotation class Foo3
|
expect annotation class Foo3
|
||||||
expect annotation class Foo4
|
expect annotation class Foo4
|
||||||
expect annotation class Foo5()
|
expect annotation class Foo5()
|
||||||
|
expect annotation class Foo6()
|
||||||
|
expect annotation class Foo7()
|
||||||
|
|
||||||
@<!NO_CONSTRUCTOR!>Foo1<!>
|
@<!NO_CONSTRUCTOR!>Foo1<!>
|
||||||
fun foo() {}
|
fun foo() {}
|
||||||
@@ -39,4 +41,8 @@ actual annotation class Foo2(val p: String = "default")
|
|||||||
|
|
||||||
actual annotation class Foo3(val a: String = "a", val b: String = "b")
|
actual annotation class Foo3(val a: String = "a", val b: String = "b")
|
||||||
|
|
||||||
actual annotation class Foo5
|
actual annotation class Foo5
|
||||||
|
|
||||||
|
actual annotation class Foo6(val s: String = "value")
|
||||||
|
|
||||||
|
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo7<!> = Bar2
|
||||||
+7
@@ -35,6 +35,13 @@ public final expect annotation class Foo5 : kotlin.Annotation {
|
|||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final expect annotation class Foo6 : kotlin.Annotation {
|
||||||
|
public constructor Foo6()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- Module: <m2-jvm> --
|
// -- Module: <m2-jvm> --
|
||||||
package
|
package
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
// !LANGUAGE: +MultiPlatformProjects
|
||||||
|
// MODULE: m1-common
|
||||||
|
// FILE: common.kt
|
||||||
|
|
||||||
|
expect class Foo1
|
||||||
|
expect class Foo2
|
||||||
|
expect class Foo3
|
||||||
|
|
||||||
|
expect class Bar1()
|
||||||
|
expect class Bar2()
|
||||||
|
expect class Bar3()
|
||||||
|
|
||||||
|
// MODULE: m2-jvm(m1-common)
|
||||||
|
|
||||||
|
// FILE: JavaFoo.java
|
||||||
|
|
||||||
|
public class JavaFoo {
|
||||||
|
public JavaFoo(int i) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: JavaBar.java
|
||||||
|
|
||||||
|
public class JavaBar {
|
||||||
|
public JavaBar(int i) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: jvm.kt
|
||||||
|
|
||||||
|
actual class Foo1(val s: String)
|
||||||
|
actual class Foo2(val p: String = "value", <!UNUSED_PARAMETER!>i<!>: Int)
|
||||||
|
actual typealias Foo3 = JavaFoo
|
||||||
|
|
||||||
|
actual class Bar1<!ACTUAL_WITHOUT_EXPECT!>(val s: String)<!>
|
||||||
|
actual class Bar2<!ACTUAL_WITHOUT_EXPECT!>(val p: String = "value", <!UNUSED_PARAMETER!>i<!>: Int)<!>
|
||||||
|
<!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>actual typealias Bar3 = JavaBar<!>
|
||||||
+93
@@ -0,0 +1,93 @@
|
|||||||
|
// -- Module: <m1-common> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public final expect class Bar1 {
|
||||||
|
public constructor Bar1()
|
||||||
|
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 expect class Bar2 {
|
||||||
|
public constructor Bar2()
|
||||||
|
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 expect class Bar3 {
|
||||||
|
public constructor Bar3()
|
||||||
|
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 expect class Foo1 {
|
||||||
|
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 expect class Foo2 {
|
||||||
|
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 expect class Foo3 {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -- Module: <m2-jvm> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public final actual class Bar1 {
|
||||||
|
public constructor Bar1(/*0*/ s: kotlin.String)
|
||||||
|
public final val s: kotlin.String
|
||||||
|
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 actual class Bar2 {
|
||||||
|
public constructor Bar2(/*0*/ p: kotlin.String = ..., /*1*/ i: kotlin.Int)
|
||||||
|
public final val p: kotlin.String
|
||||||
|
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 actual class Foo1 {
|
||||||
|
public constructor Foo1(/*0*/ s: kotlin.String)
|
||||||
|
public final val s: kotlin.String
|
||||||
|
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 actual class Foo2 {
|
||||||
|
public constructor Foo2(/*0*/ p: kotlin.String = ..., /*1*/ i: kotlin.Int)
|
||||||
|
public final val p: kotlin.String
|
||||||
|
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 open class JavaBar {
|
||||||
|
public constructor JavaBar(/*0*/ i: kotlin.Int)
|
||||||
|
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 open class JavaFoo {
|
||||||
|
public constructor JavaFoo(/*0*/ i: kotlin.Int)
|
||||||
|
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 typealias Bar3 = JavaBar
|
||||||
|
public typealias Foo3 = JavaFoo
|
||||||
@@ -14087,6 +14087,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("actualClassWithDifferentConstructors.kt")
|
||||||
|
public void testActualClassWithDifferentConstructors() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDifferentConstructors.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("actualMissing.kt")
|
@TestMetadata("actualMissing.kt")
|
||||||
public void testActualMissing() throws Exception {
|
public void testActualMissing() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt");
|
||||||
|
|||||||
+6
@@ -14087,6 +14087,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("actualClassWithDifferentConstructors.kt")
|
||||||
|
public void testActualClassWithDifferentConstructors() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDifferentConstructors.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("actualMissing.kt")
|
@TestMetadata("actualMissing.kt")
|
||||||
public void testActualMissing() throws Exception {
|
public void testActualMissing() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user