[K/JS] Fix problem with saving of parameter's default values after overriding ^KT-63907 Fixed

This commit is contained in:
Artem Kobzar
2024-03-01 13:20:33 +00:00
committed by Space Team
parent 807d352ed4
commit 35acade031
7 changed files with 81 additions and 5 deletions
@@ -53,5 +53,18 @@ declare namespace JS_TESTS {
readonly "foo.ExportedChildInterface": unique symbol;
};
}
interface InterfaceWithDefaultArguments {
foo(x?: number): number;
bar(x?: number): number;
readonly __doNotUseOrImplementIt: {
readonly "foo.InterfaceWithDefaultArguments": unique symbol;
};
}
class ImplementorOfInterfaceWithDefaultArguments implements foo.InterfaceWithDefaultArguments {
constructor();
bar(x?: number): number;
foo(x?: number): number;
readonly __doNotUseOrImplementIt: foo.InterfaceWithDefaultArguments["__doNotUseOrImplementIt"];
}
}
}
@@ -68,9 +68,20 @@ interface InterfaceWithCompanion {
}
// KT-64708
external interface ExportedParentInterface
interface ExportedChildInterface : ExportedParentInterface {
fun bar()
}
// KT-63907
interface InterfaceWithDefaultArguments {
fun foo(x: Int = 0) = x
fun bar(x: Int = 0) = x
}
class ImplementorOfInterfaceWithDefaultArguments : InterfaceWithDefaultArguments {
override fun bar(x: Int) = x + 1
}
@@ -3,6 +3,7 @@ import ChildTestInterfaceImpl = JS_TESTS.foo.ChildTestInterfaceImpl;
import processInterface = JS_TESTS.foo.processInterface;
import processOptionalInterface = JS_TESTS.foo.processOptionalInterface;
import WithTheCompanion = JS_TESTS.foo.WithTheCompanion;
import ImplementorOfInterfaceWithDefaultArguments = JS_TESTS.foo.ImplementorOfInterfaceWithDefaultArguments;
function assert(condition: boolean) {
if (!condition) {
@@ -23,5 +24,11 @@ function box(): string {
assert(WithTheCompanion.companionFunction() == "FUNCTION")
const instance = new ImplementorOfInterfaceWithDefaultArguments()
assert(instance.foo() === 0);
assert(instance.foo(2) === 2);
assert(instance.bar() === 1);
assert(instance.bar(2) === 3);
return "OK";
}
@@ -53,5 +53,18 @@ declare namespace JS_TESTS {
readonly "foo.ExportedChildInterface": unique symbol;
};
}
interface InterfaceWithDefaultArguments {
foo(x?: number): number;
bar(x?: number): number;
readonly __doNotUseOrImplementIt: {
readonly "foo.InterfaceWithDefaultArguments": unique symbol;
};
}
class ImplementorOfInterfaceWithDefaultArguments implements foo.InterfaceWithDefaultArguments {
constructor();
bar(x?: number): number;
foo(x?: number): number;
readonly __doNotUseOrImplementIt: foo.InterfaceWithDefaultArguments["__doNotUseOrImplementIt"];
}
}
}
@@ -63,10 +63,23 @@ interface InterfaceWithCompanion {
}
}
// KT-64708
@JsExport
external interface ExportedParentInterface
@JsExport
interface ExportedChildInterface : ExportedParentInterface {
fun bar()
}
// KT-63907
@JsExport
interface InterfaceWithDefaultArguments {
fun foo(x: Int = 0) = x
fun bar(x: Int = 0) = x
}
@JsExport
class ImplementorOfInterfaceWithDefaultArguments : InterfaceWithDefaultArguments {
override fun bar(x: Int) = x + 1
}
@@ -3,6 +3,7 @@ import ChildTestInterfaceImpl = JS_TESTS.foo.ChildTestInterfaceImpl;
import processInterface = JS_TESTS.foo.processInterface;
import processOptionalInterface = JS_TESTS.foo.processOptionalInterface;
import WithTheCompanion = JS_TESTS.foo.WithTheCompanion;
import ImplementorOfInterfaceWithDefaultArguments = JS_TESTS.foo.ImplementorOfInterfaceWithDefaultArguments;
function assert(condition: boolean) {
if (!condition) {
@@ -23,5 +24,11 @@ function box(): string {
assert(WithTheCompanion.companionFunction() == "FUNCTION")
const instance = new ImplementorOfInterfaceWithDefaultArguments()
assert(instance.foo() === 0);
assert(instance.foo(2) === 2);
assert(instance.bar() === 1);
assert(instance.bar(2) === 3);
return "OK";
}