K1: Implement a checker that disallows to have different member scopes for expect open and its actual
^KT-22841 Fixed Review: https://jetbrains.team/p/kt/reviews/11603/timeline The commit also introduces `@AllowDifferentMembersInActual` annotation in stdlib which allows to suppress the diagnostic
This commit is contained in:
+3
@@ -1,4 +1,5 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// WITH_STDLIB
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// IGNORE_BACKEND_K2: ANY
|
||||
// FIR status: outdated code (expect and actual in the same module)
|
||||
@@ -20,6 +21,8 @@ actual interface I {
|
||||
actual fun test(source: String = "actual")
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual
|
||||
actual interface J : I {
|
||||
override fun test(source: String) {
|
||||
if (source != "actual") throw AssertionError(source)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Js backend is ignored because they use old test infrastructure which doesn't support HMPP
|
||||
*/
|
||||
|
||||
// WITH_STDLIB
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// TARGET_BACKEND: JVM
|
||||
@@ -25,6 +26,8 @@ fun getB(): B = B()
|
||||
|
||||
// MODULE: main()()(intermediate)
|
||||
// FILE: main.kt
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual
|
||||
actual open class A actual constructor() {
|
||||
fun bar(): String = "K"
|
||||
}
|
||||
|
||||
+5
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: JS, JS_IR, JS_IR_ES6, NATIVE, WASM
|
||||
// WITH_STDLIB
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common
|
||||
@@ -17,12 +18,16 @@ class B : A()
|
||||
// MODULE: platform()()(common)
|
||||
// FILE: platform.kt
|
||||
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual
|
||||
actual interface S1 {
|
||||
fun o(): S = "O"
|
||||
val p: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual
|
||||
actual interface S2 {
|
||||
fun k() = "K"
|
||||
}
|
||||
|
||||
+7
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: JS, JS_IR, JS_IR_ES6, NATIVE, WASM
|
||||
// WITH_STDLIB
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: common
|
||||
@@ -17,6 +18,8 @@ class B : A()
|
||||
// MODULE: platform()()(common)
|
||||
// FILE: platform.kt
|
||||
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual
|
||||
actual interface S1 {
|
||||
fun s1() = "O"
|
||||
}
|
||||
@@ -25,9 +28,13 @@ interface S20 {
|
||||
fun s2() = "K"
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual
|
||||
actual interface S2 : S20 {
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@AllowDifferentMembersInActual
|
||||
actual interface S : S1, S2 {
|
||||
fun s3() = s1() + s2()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user