fix(KT-38262): add ability to create classes with methods that have reserved keyword as an identifier.
This commit is contained in:
+1
-1
@@ -588,7 +588,7 @@ class ExportModelGenerator(
|
|||||||
|
|
||||||
val name = function.getExportedIdentifier()
|
val name = function.getExportedIdentifier()
|
||||||
// TODO: Use [] syntax instead of prohibiting
|
// TODO: Use [] syntax instead of prohibiting
|
||||||
if (name in allReservedWords)
|
if (parentClass == null && name in allReservedWords)
|
||||||
return Exportability.Prohibited("Name is a reserved word")
|
return Exportability.Prohibited("Name is a reserved word")
|
||||||
|
|
||||||
return Exportability.Allowed
|
return Exportability.Allowed
|
||||||
|
|||||||
@@ -162,5 +162,10 @@ declare namespace JS_TESTS {
|
|||||||
get ordinal(): 0 | 1;
|
get ordinal(): 0 | 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class KT38262 {
|
||||||
|
constructor();
|
||||||
|
then(): number;
|
||||||
|
catch(): number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,4 +213,10 @@ class OuterClass {
|
|||||||
A,
|
A,
|
||||||
B
|
B
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
class KT38262 {
|
||||||
|
fun then(): Int = 42
|
||||||
|
fun catch(): Int = 24
|
||||||
}
|
}
|
||||||
+3
@@ -30,6 +30,7 @@ var TestEnumClass = JS_TESTS.foo.TestEnumClass;
|
|||||||
var TestInterfaceImpl = JS_TESTS.foo.TestInterfaceImpl;
|
var TestInterfaceImpl = JS_TESTS.foo.TestInterfaceImpl;
|
||||||
var processInterface = JS_TESTS.foo.processInterface;
|
var processInterface = JS_TESTS.foo.processInterface;
|
||||||
var OuterClass = JS_TESTS.foo.OuterClass;
|
var OuterClass = JS_TESTS.foo.OuterClass;
|
||||||
|
var KT38262 = JS_TESTS.foo.KT38262;
|
||||||
function assert(condition) {
|
function assert(condition) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
throw "Assertion failed";
|
throw "Assertion failed";
|
||||||
@@ -126,5 +127,7 @@ function box() {
|
|||||||
assert(OuterClass.NestedEnum.B.name === "B");
|
assert(OuterClass.NestedEnum.B.name === "B");
|
||||||
assert(OuterClass.NestedEnum.A.ordinal === 0);
|
assert(OuterClass.NestedEnum.A.ordinal === 0);
|
||||||
assert(OuterClass.NestedEnum.B.ordinal === 1);
|
assert(OuterClass.NestedEnum.B.ordinal === 1);
|
||||||
|
assert(new KT38262().then() == 42);
|
||||||
|
assert(new KT38262().catch() == 24);
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -30,6 +30,7 @@ import TestEnumClass = JS_TESTS.foo.TestEnumClass;
|
|||||||
import TestInterfaceImpl = JS_TESTS.foo.TestInterfaceImpl;
|
import TestInterfaceImpl = JS_TESTS.foo.TestInterfaceImpl;
|
||||||
import processInterface = JS_TESTS.foo.processInterface;
|
import processInterface = JS_TESTS.foo.processInterface;
|
||||||
import OuterClass = JS_TESTS.foo.OuterClass;
|
import OuterClass = JS_TESTS.foo.OuterClass;
|
||||||
|
import KT38262 = JS_TESTS.foo.KT38262;
|
||||||
|
|
||||||
function assert(condition: boolean) {
|
function assert(condition: boolean) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
@@ -152,5 +153,8 @@ function box(): string {
|
|||||||
assert(OuterClass.NestedEnum.A.ordinal === 0)
|
assert(OuterClass.NestedEnum.A.ordinal === 0)
|
||||||
assert(OuterClass.NestedEnum.B.ordinal === 1)
|
assert(OuterClass.NestedEnum.B.ordinal === 1)
|
||||||
|
|
||||||
|
assert(new KT38262().then() == 42)
|
||||||
|
assert(new KT38262().catch() == 24)
|
||||||
|
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user