Support default arguments for expected declarations
#KT-21913 Fixed
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect class Ok(x: Int, y: String = "")
|
||||
|
||||
expect class FailX(x: Int, y: String = "")
|
||||
|
||||
expect class FailY(x: Int, y: String = "")
|
||||
|
||||
fun test() {
|
||||
Ok(42)
|
||||
Ok(42, "OK")
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual class Ok actual constructor(x: Int, y: String)
|
||||
|
||||
actual class FailX actual constructor(<!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>x: Int = 0<!>, y: String)
|
||||
|
||||
actual class FailY actual constructor(x: Int, <!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>y: String = ""<!>)
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final expect class FailX {
|
||||
public constructor FailX(/*0*/ x: kotlin.Int, /*1*/ y: 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 expect class FailY {
|
||||
public constructor FailY(/*0*/ x: kotlin.Int, /*1*/ y: 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 expect class Ok {
|
||||
public constructor Ok(/*0*/ x: kotlin.Int, /*1*/ y: 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
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final actual class FailX {
|
||||
public constructor FailX(/*0*/ x: kotlin.Int = ..., /*1*/ y: 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 FailY {
|
||||
public constructor FailY(/*0*/ x: kotlin.Int, /*1*/ y: 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 Ok {
|
||||
public constructor Ok(/*0*/ x: kotlin.Int, /*1*/ y: 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
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect fun ok(x: Int, y: String = "")
|
||||
|
||||
expect fun failX(x: Int, y: String = "")
|
||||
|
||||
expect fun failY(x: Int, y: String = "")
|
||||
|
||||
expect open class Foo {
|
||||
fun ok(x: Int, y: String = "")
|
||||
|
||||
fun failX(x: Int, y: String = "")
|
||||
|
||||
fun failY(x: Int, y: String = "")
|
||||
}
|
||||
|
||||
fun test(foo: Foo) {
|
||||
ok(42)
|
||||
ok(42, "OK")
|
||||
foo.ok(42)
|
||||
foo.ok(42, "OK")
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual fun ok(x: Int, y: String) {}
|
||||
|
||||
actual fun failX(<!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>x: Int = 0<!>, y: String) {}
|
||||
|
||||
actual fun failY(x: Int, <!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>y: String = ""<!>) {}
|
||||
|
||||
actual open class Foo {
|
||||
actual fun ok(x: Int, y: String) {}
|
||||
|
||||
actual fun failX(<!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>x: Int = 0<!>, y: String) {}
|
||||
|
||||
actual fun failY(x: Int, <!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>y: String = ""<!>) {}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public expect fun failX(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public expect fun failY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public expect fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public fun test(/*0*/ foo: Foo): kotlin.Unit
|
||||
|
||||
public open expect class Foo {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final expect fun failX(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public final expect fun failY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final expect fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public actual fun failX(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String): kotlin.Unit
|
||||
public actual fun failY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public actual fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
public fun test(/*0*/ foo: Foo): kotlin.Unit
|
||||
|
||||
public open actual class Foo {
|
||||
public constructor Foo()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final actual fun failX(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String): kotlin.Unit
|
||||
public final actual fun failY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final actual fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
interface Foo {
|
||||
fun ok(x: Int, y: String = "")
|
||||
|
||||
fun failX(x: Int, y: String = "")
|
||||
|
||||
fun failY(x: Int, y: String = "")
|
||||
}
|
||||
|
||||
expect class Bar : Foo {
|
||||
override fun ok(x: Int, y: String)
|
||||
|
||||
override fun failX(x: Int, y: String)
|
||||
|
||||
override fun failY(x: Int, y: String)
|
||||
}
|
||||
|
||||
fun test(foo: Foo, bar: Bar) {
|
||||
foo.ok(42)
|
||||
foo.ok(42, "OK")
|
||||
bar.ok(42)
|
||||
bar.ok(42, "OK")
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual class Bar : Foo {
|
||||
actual override fun ok(x: Int, y: String) {}
|
||||
|
||||
actual override fun failX(<!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>x: Int = <!DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE!>0<!><!>, y: String) {}
|
||||
|
||||
actual override fun failY(x: Int, <!ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS!>y: String = <!DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE!>""<!><!>) {}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public fun test(/*0*/ foo: Foo, /*1*/ bar: Bar): kotlin.Unit
|
||||
|
||||
public final expect class Bar : Foo {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open expect override /*1*/ fun failX(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open expect override /*1*/ fun failY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open expect override /*1*/ fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Foo {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun failX(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public abstract fun failY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public fun test(/*0*/ foo: Foo, /*1*/ bar: Bar): kotlin.Unit
|
||||
|
||||
public final actual class Bar : Foo {
|
||||
public constructor Bar()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open actual override /*1*/ fun failX(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open actual override /*1*/ fun failY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open actual override /*1*/ fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Foo {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun failX(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public abstract fun failY(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect fun ok(x: Int, y: String = "")
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual fun ok(x: Int, y: String) {}
|
||||
|
||||
fun ok(x: Int, y: Long = 1L) {}
|
||||
|
||||
fun test() {
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>ok<!>(1)
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public expect fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Long = ...): kotlin.Unit
|
||||
public actual fun ok(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
Vendored
-2
@@ -21,8 +21,6 @@ expect class Foo(
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>get()<!> = "no"
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>set(value)<!> {}
|
||||
|
||||
fun defaultArg(<!EXPECTED_DECLARATION_WITH_DEFAULT_PARAMETER!>value: String = "no"<!>)
|
||||
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>fun functionWithBody(x: Int): Int<!> {
|
||||
return x + 1
|
||||
}
|
||||
|
||||
Vendored
-1
@@ -7,7 +7,6 @@ public final expect class Foo {
|
||||
public expect final val constructorProperty: kotlin.String
|
||||
public expect final var getSet: kotlin.String
|
||||
public expect final val prop: kotlin.String = "no"
|
||||
public final expect fun defaultArg(/*0*/ value: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final expect fun functionWithBody(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect fun foo(x: Int, <!EXPECTED_DECLARATION_WITH_DEFAULT_PARAMETER!>y: String = ""<!>)
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package
|
||||
|
||||
public expect fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
Reference in New Issue
Block a user