diff --git a/es2panda/ir/ts/tsNonNullExpression.cpp b/es2panda/ir/ts/tsNonNullExpression.cpp index 06f51f77c7bbbbf4fb3265b3baeb0f409314e145..e43b52db35775cd55c9cc732631304b581e4d569 100644 --- a/es2panda/ir/ts/tsNonNullExpression.cpp +++ b/es2panda/ir/ts/tsNonNullExpression.cpp @@ -29,7 +29,10 @@ void TSNonNullExpression::Dump(ir::AstDumper *dumper) const dumper->Add({{"type", "TSNonNullExpression"}, {"expression", expr_}}); } -void TSNonNullExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} +void TSNonNullExpression::Compile(compiler::PandaGen *pg) const +{ + expr_->Compile(pg); +} checker::Type *TSNonNullExpression::Check([[maybe_unused]] checker::Checker *checker) const { diff --git a/es2panda/ir/ts/tsNonNullExpression.h b/es2panda/ir/ts/tsNonNullExpression.h index 9f278f49f704e3919032a316d81d307bb423fb28..5d0e858c8379986c2d5f7ec72e2361edaead29ae 100644 --- a/es2panda/ir/ts/tsNonNullExpression.h +++ b/es2panda/ir/ts/tsNonNullExpression.h @@ -40,7 +40,7 @@ public: void Iterate(const NodeTraverser &cb) const override; void Dump(ir::AstDumper *dumper) const override; - void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; + void Compile(compiler::PandaGen *pg) const override; checker::Type *Check([[maybe_unused]] checker::Checker *checker) const override; void UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) override; diff --git a/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-non-null-expression-1-expected.txt b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-non-null-expression-1-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..86f1793affed0f61b81e0e26c87edf5c9c84b940 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-non-null-expression-1-expected.txt @@ -0,0 +1 @@ +ts-test-non-null-expression-1 diff --git a/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-non-null-expression-1.ts b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-non-null-expression-1.ts new file mode 100644 index 0000000000000000000000000000000000000000..f239bef2d82be068c0a078a6f61fbc68ea3e43b9 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-non-null-expression-1.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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. + */ + + +class C { + a : string = "ts-test-non-null-expression-1"; +} +var x : C = new C(); +print(x!.a) \ No newline at end of file