[FE 1.0] Issue a warning if expect and actual are declared in the same module
The commit is based on b09561c3c3
Co-authored-by: Dmitriy Novozhilov <dmitriy.novozhilov@jetbrains.com>
^KT-40904 Fixed
^KT-55177 Fixed
Review: https://jetbrains.team/p/kt/reviews/8731
True negative test already exist:
`compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt`
This commit is contained in:
+64
@@ -0,0 +1,64 @@
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
expect class CommonClass {
|
||||
fun memberFun()
|
||||
val memberProp: Int
|
||||
class Nested
|
||||
inner class Inner
|
||||
}
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual class CommonClass {
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual fun memberFun() {}<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual val memberProp: Int = 42<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual class Nested<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual inner class Inner<!>
|
||||
}<!>
|
||||
|
||||
expect fun commonFun()
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual fun commonFun() {}<!>
|
||||
|
||||
expect val commonProperty: String
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual val commonProperty: String
|
||||
get() = "hello"<!>
|
||||
|
||||
// MODULE: intermediate()()(common)
|
||||
// TARGET_PLATFORM: Common
|
||||
expect class IntermediateClass {
|
||||
fun memberFun()
|
||||
val memberProp: Int
|
||||
class Nested
|
||||
inner class Inner
|
||||
}
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual class IntermediateClass {
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual fun memberFun() {}<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual val memberProp: Int = 42<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual class Nested<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual inner class Inner<!>
|
||||
}<!>
|
||||
|
||||
expect fun intermediateFun()
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual fun intermediateFun() {}<!>
|
||||
|
||||
expect val intermediateProperty: String
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual val intermediateProperty: String
|
||||
get() = "hello"<!>
|
||||
|
||||
// MODULE: main()()(intermediate)
|
||||
expect class PlatformClass {
|
||||
fun memberFun()
|
||||
val memberProp: Int
|
||||
class Nested
|
||||
inner class Inner
|
||||
}
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual class PlatformClass {
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual fun memberFun() {}<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual val memberProp: Int = 42<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual class Nested<!>
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual inner class Inner<!>
|
||||
}<!>
|
||||
|
||||
expect fun platformFun()
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual fun platformFun() {}<!>
|
||||
|
||||
expect val platformProperty: String
|
||||
<!ACTUAL_WITHOUT_EXPECT!>actual val platformProperty: String
|
||||
get() = "hello"<!>
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class CommonClass<!> {
|
||||
fun memberFun()
|
||||
val memberProp: Int
|
||||
class Nested
|
||||
inner class Inner
|
||||
}
|
||||
actual <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class CommonClass<!> {
|
||||
actual fun memberFun() {}
|
||||
actual val memberProp: Int = 42
|
||||
actual class Nested
|
||||
actual inner class Inner
|
||||
}
|
||||
|
||||
expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonFun<!>()
|
||||
actual fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonFun<!>() {}
|
||||
|
||||
expect val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonProperty<!>: String
|
||||
actual val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonProperty<!>: String
|
||||
get() = "hello"
|
||||
|
||||
// MODULE: intermediate()()(common)
|
||||
// TARGET_PLATFORM: Common
|
||||
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class IntermediateClass<!> {
|
||||
fun memberFun()
|
||||
val memberProp: Int
|
||||
class Nested
|
||||
inner class Inner
|
||||
}
|
||||
actual <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class IntermediateClass<!> {
|
||||
actual fun memberFun() {}
|
||||
actual val memberProp: Int = 42
|
||||
actual class Nested
|
||||
actual inner class Inner
|
||||
}
|
||||
|
||||
expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateFun<!>()
|
||||
actual fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateFun<!>() {}
|
||||
|
||||
expect val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateProperty<!>: String
|
||||
actual val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateProperty<!>: String
|
||||
get() = "hello"
|
||||
|
||||
// MODULE: main()()(intermediate)
|
||||
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class PlatformClass<!> {
|
||||
fun memberFun()
|
||||
val memberProp: Int
|
||||
class Nested
|
||||
inner class Inner
|
||||
}
|
||||
actual <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class PlatformClass<!> {
|
||||
actual fun memberFun() {}
|
||||
actual val memberProp: Int = 42
|
||||
actual class Nested
|
||||
actual inner class Inner
|
||||
}
|
||||
|
||||
expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>platformFun<!>()
|
||||
actual fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>platformFun<!>() {}
|
||||
|
||||
expect val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>platformProperty<!>: String
|
||||
actual val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>platformProperty<!>: String
|
||||
get() = "hello"
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
// -- Module: <common> --
|
||||
package
|
||||
|
||||
public actual val commonProperty: kotlin.String
|
||||
public expect val commonProperty: kotlin.String
|
||||
public actual fun commonFun(): kotlin.Unit
|
||||
public expect fun commonFun(): kotlin.Unit
|
||||
|
||||
public final actual class CommonClass {
|
||||
public constructor CommonClass()
|
||||
public actual final val memberProp: kotlin.Int = 42
|
||||
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 final actual fun memberFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final actual inner class Inner {
|
||||
public constructor 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
|
||||
}
|
||||
|
||||
public final actual class Nested {
|
||||
public constructor Nested()
|
||||
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 CommonClass {
|
||||
public expect final val memberProp: 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 final expect fun memberFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final expect inner class 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
|
||||
}
|
||||
|
||||
public final expect class Nested {
|
||||
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: <intermediate> --
|
||||
package
|
||||
|
||||
public actual val intermediateProperty: kotlin.String
|
||||
public expect val intermediateProperty: kotlin.String
|
||||
public actual fun intermediateFun(): kotlin.Unit
|
||||
public expect fun intermediateFun(): kotlin.Unit
|
||||
|
||||
public final actual class IntermediateClass {
|
||||
public constructor IntermediateClass()
|
||||
public actual final val memberProp: kotlin.Int = 42
|
||||
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 final actual fun memberFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final actual inner class Inner {
|
||||
public constructor 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
|
||||
}
|
||||
|
||||
public final actual class Nested {
|
||||
public constructor Nested()
|
||||
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 IntermediateClass {
|
||||
public expect final val memberProp: 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 final expect fun memberFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final expect inner class 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
|
||||
}
|
||||
|
||||
public final expect class Nested {
|
||||
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: <main> --
|
||||
package
|
||||
|
||||
public actual val platformProperty: kotlin.String
|
||||
public actual fun platformFun(): kotlin.Unit
|
||||
|
||||
public final actual class PlatformClass {
|
||||
public constructor PlatformClass()
|
||||
public actual final val memberProp: kotlin.Int = 42
|
||||
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 final actual fun memberFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final actual inner class Inner {
|
||||
public constructor 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
|
||||
}
|
||||
|
||||
public final actual class Nested {
|
||||
public constructor Nested()
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user