[FE] Prohibit default arguments in expect declarations actualized via typealias
Cases when default argument inhertied from super class are allowed. Some tests for default arguments already exist and can be found in `testData/diagnostics/tests/multiplatform/defaultArguments`, for example `annotationsViaActualTypeAlias.kt`. ^KT-57614 Fixed Merge-request: KT-MR-10356 Merged-by: Roman Efremov <Roman.Efremov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
9829a2bf98
commit
d2eb4a0abf
+10
@@ -0,0 +1,10 @@
|
||||
// FIR_IDENTICAL
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
expect class DefaultArgsInConstructor(p1: String = "common", p2: String = "common", p3: String)
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
class DefaultArgsInConstructorImpl(p1: String = "common", p2: String = "common", p3: String)
|
||||
|
||||
<!DEFAULT_ARGUMENTS_IN_EXPECT_WITH_ACTUAL_TYPEALIAS!>actual typealias DefaultArgsInConstructor = DefaultArgsInConstructorImpl<!>
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -ACTUAL_WITHOUT_EXPECT
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
expect class A {
|
||||
fun foo(p1: String = "common", p2: String = "common", p3: String)
|
||||
}
|
||||
|
||||
expect class B {
|
||||
fun foo(s: String)
|
||||
}
|
||||
|
||||
interface I {
|
||||
fun methodWithDefaultArg(s: String = "common")
|
||||
}
|
||||
|
||||
expect class WithDefaultArgFromSuper : I {
|
||||
override fun methodWithDefaultArg(s: String)
|
||||
}
|
||||
|
||||
expect open class WithIncompatibility {
|
||||
fun foo(p: String = "common")
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
class AImpl {
|
||||
fun foo(p1: String = "impl", p2: String = "impl", p3: String) {}
|
||||
}
|
||||
|
||||
<!DEFAULT_ARGUMENTS_IN_EXPECT_WITH_ACTUAL_TYPEALIAS!>actual typealias A = AImpl<!>
|
||||
|
||||
class BImpl {
|
||||
fun foo(s: String = "impl") {}
|
||||
}
|
||||
|
||||
actual typealias B = BImpl
|
||||
|
||||
class WithDefaultArgFromSuperImpl : I {
|
||||
override fun methodWithDefaultArg(s: String) {}
|
||||
}
|
||||
|
||||
actual typealias WithDefaultArgFromSuper = WithDefaultArgFromSuperImpl
|
||||
|
||||
class WithIncompatibilityImpl {
|
||||
fun foo(p: String) {}
|
||||
}
|
||||
|
||||
<!DEFAULT_ARGUMENTS_IN_EXPECT_WITH_ACTUAL_TYPEALIAS!>actual typealias WithIncompatibility = WithIncompatibilityImpl<!>
|
||||
Reference in New Issue
Block a user