[FE] Prohibit expect external and expect tailrec
^KT-58536 Fixed
This commit is contained in:
committed by
Space Team
parent
e6d5df18b8
commit
439cc88525
@@ -0,0 +1,38 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect <!EXPECTED_EXTERNAL_DECLARATION!>external<!> fun foo()
|
||||
expect fun bar()
|
||||
|
||||
expect <!EXPECTED_EXTERNAL_DECLARATION, WRONG_MODIFIER_TARGET!>external<!> var prop: String
|
||||
|
||||
expect var getAndSet: String
|
||||
<!EXPECTED_EXTERNAL_DECLARATION!>external<!> get
|
||||
<!EXPECTED_EXTERNAL_DECLARATION!>external<!> set
|
||||
|
||||
<!EXPECTED_EXTERNAL_DECLARATION, WRONG_MODIFIER_TARGET!>external<!> expect val explicitGetter: String
|
||||
<!EXPECTED_EXTERNAL_DECLARATION!>external<!> get
|
||||
|
||||
expect <!EXPECTED_EXTERNAL_DECLARATION, WRONG_MODIFIER_TARGET!>external<!> class A {
|
||||
<!EXPECTED_EXTERNAL_DECLARATION!>external<!> fun foo()
|
||||
fun bar()
|
||||
}
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual external fun foo()
|
||||
actual external fun bar()
|
||||
|
||||
actual <!WRONG_MODIFIER_TARGET!>external<!> var prop: String
|
||||
|
||||
actual var getAndSet: String
|
||||
external get
|
||||
external set
|
||||
|
||||
actual <!WRONG_MODIFIER_TARGET!>external<!> val explicitGetter: String
|
||||
external get
|
||||
|
||||
actual class A {
|
||||
actual external fun foo()
|
||||
actual external fun bar()
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect <!EXPECTED_EXTERNAL_DECLARATION, EXPECTED_EXTERNAL_DECLARATION{JVM}!>external<!> fun foo()
|
||||
expect fun bar()
|
||||
|
||||
expect <!EXPECTED_EXTERNAL_DECLARATION, EXPECTED_EXTERNAL_DECLARATION{JVM}, WRONG_MODIFIER_TARGET{JVM}!>external<!> var prop: String
|
||||
|
||||
expect var getAndSet: String
|
||||
<!EXPECTED_EXTERNAL_DECLARATION, EXPECTED_EXTERNAL_DECLARATION{JVM}!>external<!> get
|
||||
<!EXPECTED_EXTERNAL_DECLARATION, EXPECTED_EXTERNAL_DECLARATION{JVM}!>external<!> set
|
||||
|
||||
<!EXPECTED_EXTERNAL_DECLARATION, EXPECTED_EXTERNAL_DECLARATION{JVM}, WRONG_MODIFIER_TARGET{JVM}!>external<!> expect val explicitGetter: String
|
||||
<!EXPECTED_EXTERNAL_DECLARATION, EXPECTED_EXTERNAL_DECLARATION{JVM}!>external<!> get
|
||||
|
||||
expect <!EXPECTED_EXTERNAL_DECLARATION, EXPECTED_EXTERNAL_DECLARATION{JVM}, WRONG_MODIFIER_TARGET{JVM}!>external<!> class A {
|
||||
<!EXPECTED_EXTERNAL_DECLARATION, EXPECTED_EXTERNAL_DECLARATION{JVM}!>external<!> fun foo()
|
||||
fun bar()
|
||||
}
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual external fun foo()
|
||||
actual external fun bar()
|
||||
|
||||
actual <!WRONG_MODIFIER_TARGET!>external<!> var prop: String
|
||||
|
||||
actual var getAndSet: String
|
||||
external get
|
||||
external set
|
||||
|
||||
actual <!WRONG_MODIFIER_TARGET!>external<!> val explicitGetter: String
|
||||
external get
|
||||
|
||||
actual class A {
|
||||
actual external fun foo()
|
||||
actual external fun bar()
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect <!EXPECTED_TAILREC_FUNCTION, NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo(p: Int): Int
|
||||
expect fun bar(p: Int): Int
|
||||
|
||||
expect <!WRONG_MODIFIER_TARGET!>tailrec<!> val notReport: String
|
||||
|
||||
expect class A {
|
||||
<!EXPECTED_TAILREC_FUNCTION, NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo(p: Int): Int
|
||||
fun bar(p: Int): Int
|
||||
}
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual tailrec fun foo(p: Int): Int = foo(p)
|
||||
actual tailrec fun bar(p: Int): Int = bar(p)
|
||||
|
||||
actual val notReport: String = "123"
|
||||
|
||||
actual class A {
|
||||
actual tailrec fun foo(p: Int): Int = foo(p)
|
||||
actual tailrec fun bar(p: Int): Int = bar(p)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect <!EXPECTED_TAILREC_FUNCTION, EXPECTED_TAILREC_FUNCTION{JVM}!>tailrec<!> fun foo(p: Int): Int
|
||||
expect fun bar(p: Int): Int
|
||||
|
||||
expect <!WRONG_MODIFIER_TARGET, WRONG_MODIFIER_TARGET{JVM}!>tailrec<!> val notReport: String
|
||||
|
||||
expect class A {
|
||||
<!EXPECTED_TAILREC_FUNCTION, EXPECTED_TAILREC_FUNCTION{JVM}!>tailrec<!> fun foo(p: Int): Int
|
||||
fun bar(p: Int): Int
|
||||
}
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual tailrec fun foo(p: Int): Int = foo(p)
|
||||
actual tailrec fun bar(p: Int): Int = bar(p)
|
||||
|
||||
actual val notReport: String = "123"
|
||||
|
||||
actual class A {
|
||||
actual tailrec fun foo(p: Int): Int = foo(p)
|
||||
actual tailrec fun bar(p: Int): Int = bar(p)
|
||||
}
|
||||
@@ -2,8 +2,4 @@ expect infix fun Int.plus(s: CharSequence): Int
|
||||
|
||||
expect operator fun Double.times(x: CharArray)
|
||||
|
||||
expect external fun f1()
|
||||
|
||||
expect inline fun f2()
|
||||
|
||||
expect tailrec fun f3()
|
||||
expect inline fun f1()
|
||||
|
||||
@@ -3,7 +3,3 @@ actual fun Int.plus(s: CharSequence): Int = 0
|
||||
actual fun Double.times(x: CharArray) {}
|
||||
|
||||
actual fun f1() {}
|
||||
|
||||
actual fun f2() {}
|
||||
|
||||
actual fun f3() {}
|
||||
|
||||
@@ -6,32 +6,20 @@ Output:
|
||||
Exit code: COMPILATION_ERROR
|
||||
Output:
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:1:1: error: actual function 'plus' has no corresponding expected declaration
|
||||
The following declaration is incompatible because some modifiers on expected declaration are missing on the actual one (external, infix, inline, operator, tailrec):
|
||||
The following declaration is incompatible because some modifiers on expected declaration are missing on the actual one (infix, inline, operator):
|
||||
public expect infix fun Int.plus(s: CharSequence): Int
|
||||
|
||||
actual fun Int.plus(s: CharSequence): Int = 0
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:3:1: error: actual function 'times' has no corresponding expected declaration
|
||||
The following declaration is incompatible because some modifiers on expected declaration are missing on the actual one (external, infix, inline, operator, tailrec):
|
||||
The following declaration is incompatible because some modifiers on expected declaration are missing on the actual one (infix, inline, operator):
|
||||
public expect operator fun Double.times(x: CharArray): Unit
|
||||
|
||||
actual fun Double.times(x: CharArray) {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:5:1: error: actual function 'f1' has no corresponding expected declaration
|
||||
The following declaration is incompatible because some modifiers on expected declaration are missing on the actual one (external, infix, inline, operator, tailrec):
|
||||
public external expect fun f1(): Unit
|
||||
The following declaration is incompatible because some modifiers on expected declaration are missing on the actual one (infix, inline, operator):
|
||||
public expect inline fun f1(): Unit
|
||||
|
||||
actual fun f1() {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:7:1: error: actual function 'f2' has no corresponding expected declaration
|
||||
The following declaration is incompatible because some modifiers on expected declaration are missing on the actual one (external, infix, inline, operator, tailrec):
|
||||
public expect inline fun f2(): Unit
|
||||
|
||||
actual fun f2() {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:9:1: error: actual function 'f3' has no corresponding expected declaration
|
||||
The following declaration is incompatible because some modifiers on expected declaration are missing on the actual one (external, infix, inline, operator, tailrec):
|
||||
public expect tailrec fun f3(): Unit
|
||||
|
||||
actual fun f3() {}
|
||||
^
|
||||
|
||||
Reference in New Issue
Block a user