diff --git a/ts2panda/src/base/lreference.ts b/ts2panda/src/base/lreference.ts index b079b70bb89e2d0538d4bdff16aa07780845c735..1a89aa466263e0fa75fcca1b0c4e3ecb6527a059 100644 --- a/ts2panda/src/base/lreference.ts +++ b/ts2panda/src/base/lreference.ts @@ -20,6 +20,7 @@ import { compileDestructuring } from "../compilerUtils"; import { DiagnosticCode, DiagnosticError } from "../diagnostic"; import { getObjAndProp } from "../expression/memberAccessExpression"; import { findInnerExprOfParenthesis } from "../expression/parenthesizedExpression"; +import { findInnerExprOfPartiallyEmittedExpr } from "../expression/partiallyEmittedExpression"; import { VReg } from "../irnodes"; import * as jshelpers from "../jshelpers"; import { Scope } from "../scope"; @@ -131,8 +132,12 @@ export class LReference { let realNode: ts.Node = node; - if (ts.isParenthesizedExpression(node)) { - realNode = findInnerExprOfParenthesis(node); + if (ts.isPartiallyEmittedExpression(node)) { + realNode = findInnerExprOfPartiallyEmittedExpr(node); + } + + if (ts.isParenthesizedExpression(realNode)) { + realNode = findInnerExprOfParenthesis(realNode); } if (ts.isIdentifier(realNode)) { diff --git a/ts2panda/src/expression/partiallyEmittedExpression.ts b/ts2panda/src/expression/partiallyEmittedExpression.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1521a7f51284113e7b57ea706c27842cb314feb --- /dev/null +++ b/ts2panda/src/expression/partiallyEmittedExpression.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as ts from "typescript"; + +export function findInnerExprOfPartiallyEmittedExpr(expr: ts.PartiallyEmittedExpression): ts.Expression { + while (expr.expression.kind == ts.SyntaxKind.PartiallyEmittedExpression) { + expr = expr.expression; + } + return expr.expression; +}