Fix JS parser to properly handle "." <keyword> sequence
This commit is contained in:
@@ -995,8 +995,9 @@ public class Parser extends Observable {
|
|||||||
int tt;
|
int tt;
|
||||||
while ((tt = ts.getToken()) > ts.EOF) {
|
while ((tt = ts.getToken()) > ts.EOF) {
|
||||||
if (tt == ts.DOT) {
|
if (tt == ts.DOT) {
|
||||||
|
ts.treatKeywordAsIdentifier = true;
|
||||||
mustMatchToken(ts, ts.NAME, "msg.no.name.after.dot");
|
mustMatchToken(ts, ts.NAME, "msg.no.name.after.dot");
|
||||||
String s = ts.getString();
|
ts.treatKeywordAsIdentifier = false;
|
||||||
pn = nf.createBinary(ts.DOT, pn, nf.createName(ts.getString()));
|
pn = nf.createBinary(ts.DOT, pn, nf.createName(ts.getString()));
|
||||||
/*
|
/*
|
||||||
* pn = nf.createBinary(ts.DOT, pn, memberExpr(ts)) is the version in
|
* pn = nf.createBinary(ts.DOT, pn, memberExpr(ts)) is the version in
|
||||||
|
|||||||
@@ -695,7 +695,7 @@ public class TokenStream {
|
|||||||
in.unread();
|
in.unread();
|
||||||
|
|
||||||
String str = getStringFromBuffer();
|
String str = getStringFromBuffer();
|
||||||
if (!containsEscape) {
|
if (!containsEscape && !treatKeywordAsIdentifier) {
|
||||||
// OPT we shouldn't have to make a string (object!) to
|
// OPT we shouldn't have to make a string (object!) to
|
||||||
// check if it's a keyword.
|
// check if it's a keyword.
|
||||||
|
|
||||||
@@ -1477,6 +1477,7 @@ public class TokenStream {
|
|||||||
CodePosition lastPosition;
|
CodePosition lastPosition;
|
||||||
|
|
||||||
private int op;
|
private int op;
|
||||||
|
public boolean treatKeywordAsIdentifier;
|
||||||
|
|
||||||
// Set this to an inital non-null value so that the Parser has
|
// Set this to an inital non-null value so that the Parser has
|
||||||
// something to retrieve even if an error has occured and no
|
// something to retrieve even if an error has occured and no
|
||||||
|
|||||||
@@ -4664,6 +4664,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("keywordAsMemberName.kt")
|
||||||
|
public void testKeywordAsMemberName() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inlineMultiModule/keywordAsMemberName.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt16144.kt")
|
@TestMetadata("kt16144.kt")
|
||||||
public void testKt16144() throws Exception {
|
public void testKt16144() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inlineMultiModule/kt16144.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inlineMultiModule/kt16144.kt");
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// MINIFICATION_THRESHOLD: 481
|
||||||
|
// MODULE: lib
|
||||||
|
// FILE: lib.kt
|
||||||
|
class A {
|
||||||
|
fun instanceof() = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun foo() = A().instanceof()
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun box() = foo()
|
||||||
Reference in New Issue
Block a user