diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 618cc3ab61c714e36dc7400783393c21a7222a61..e3fdd3bcce077fa80737c6a10f0f01802c0df574 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -1858,8 +1858,13 @@ void ETSChecker::SetPropertiesForModuleObject(checker::ETSObjectType *moduleObjT if (!VarBinder()->AsETSBinder()->GetGlobalRecordTable()->IsExternal()) { RemoveStatus(CheckerStatus::IN_EXTERNAL); } + auto savedProgram = Program(); + VarBinder()->AsETSBinder()->SetProgram(program); + VarBinder()->AsETSBinder()->ResetTopScope(program->GlobalScope()); program->SetASTChecked(); program->Ast()->Check(this); + VarBinder()->AsETSBinder()->SetProgram(savedProgram); + VarBinder()->AsETSBinder()->ResetTopScope(savedProgram->GlobalScope()); } BindingsModuleObjectAddProperty( diff --git a/ets2panda/compiler/lowering/util.cpp b/ets2panda/compiler/lowering/util.cpp index 84e9ccb559117e1aae09adbe17912d061a0cd87c..0bc3bb411e1c4a8014c9b12d7db062d9d48d184d 100644 --- a/ets2panda/compiler/lowering/util.cpp +++ b/ets2panda/compiler/lowering/util.cpp @@ -177,6 +177,7 @@ static bool IsGeneratedDynamicClass(ir::AstNode const *ast) static void ClearHelper(parser::Program *prog) { + prog->RemoveAstChecked(); ResetGlobalClass(prog); // #24256 Should be removed when code refactoring on checker is done and no ast node allocated in checker. auto &stmts = prog->Ast()->StatementsForUpdates(); diff --git a/ets2panda/driver/build_system/package.json b/ets2panda/driver/build_system/package.json index 9ba50d68693e8286b667f3a1fc36e98869731944..f574bafc4875d162c417ef751f037baf14b7f0d0 100644 --- a/ets2panda/driver/build_system/package.json +++ b/ets2panda/driver/build_system/package.json @@ -52,7 +52,9 @@ "build_system_Utest": "jest --testMatch='**/test/ut/**/*.test.ts' --testPathIgnorePatterns='test/e2e/'", "build_system_Etest": "TEST=demo_entry1.2_hsp1.1:gen_abc jest --testMatch='**/test/e2e/*.test.ts' --testPathIgnorePatterns='test/ut/'", "IncrementCompileTest1": "npm run build && node ./dist/entry.js test/e2e/IncrementDemo/build_config.json && sed -i 's/hello world from harA!/hello world from harA! (modified)/' \"$(pwd)/test/e2e/IncrementDemo/harB/index.ets\" && TEST=IncrementDemo:gen_abc jest --testMatch='**/test/e2e/*.test.ts' --testPathIgnorePatterns='test/ut/'", - "IncrementCompileTest2": "npm run build && node ./dist/entry.js test/e2e/IncrementDemo/build_config.json && sed -i 's/console.log(strA)/console.log(strA + \"modified\")/' \"$(pwd)/test/e2e/IncrementDemo/entry/index.ets\" && TEST=IncrementDemo:gen_abc jest --testMatch='**/test/e2e/*.test.ts' --testPathIgnorePatterns='test/ut/'" + "IncrementCompileTest2": "npm run build && node ./dist/entry.js test/e2e/IncrementDemo/build_config.json && sed -i 's/console.log(strA)/console.log(strA + \"modified\")/' \"$(pwd)/test/e2e/IncrementDemo/entry/index.ets\" && TEST=IncrementDemo:gen_abc jest --testMatch='**/test/e2e/*.test.ts' --testPathIgnorePatterns='test/ut/'", + + "simultaneous_compiling:namespace_import": "npm run build && node ./dist/entry.js test/simultaneous_compiling/namespace_import/build_config.json" }, "devDependencies": { "@babel/core": "^7.24.9", diff --git a/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/build_config.json b/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/build_config.json new file mode 100644 index 0000000000000000000000000000000000000000..55051283c8e32e45eae914316d14ff3773cc62ac --- /dev/null +++ b/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/build_config.json @@ -0,0 +1,25 @@ +{ + "compileFiles": [ + "${absolute_path_to_build_system}/test/simultaneous_compiling/namespace_import/entry/a.ets", + "${absolute_path_to_build_system}/test/simultaneous_compiling/namespace_import/entry/b.ets", + "${absolute_path_to_build_system}/test/simultaneous_compiling/namespace_import/entry/c.ets" + ], + "packageName": "entry", + "moduleType": "shared", + "buildType": "build", + "buildMode": "Debug", + "moduleRootPath": "${absolute_path_to_build_system}/test/simultaneous_compiling/namespace_import/entry/", + "sourceRoots": [ + "./", + "src/main1/ets" + ], + "loaderOutPath": "./dist", + "cachePath": "./dist/cache", + "enableDeclgenEts2Ts": false, + "declgenV1OutPath": "./dist/declgen/decl_ets", + "declgenV2OutPath": "./dist/declgen/decl_ets2", + "declgenBridgeCodePath": "./dist/declgen/ets", + "buildSdkPath": "${absolute_path_to_build_system}/test/mock_sdk/", + "dependentModuleList": [], + "hasMainModule": true +} \ No newline at end of file diff --git a/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/a.ets b/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/a.ets new file mode 100644 index 0000000000000000000000000000000000000000..57499604dd273d36e2ecb244d5db288f94ede7af --- /dev/null +++ b/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/a.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 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 { A } from "./b" + +A() \ No newline at end of file diff --git a/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/b.ets b/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/b.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a4071ec7bd2483c674400f5a71a63c42ba205a8 --- /dev/null +++ b/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/b.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 ns from "./c" + +export function A() { + let a: boolean = ns.falseRes(); + a = a && ns.falseRes(); +} \ No newline at end of file diff --git a/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/c.ets b/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/c.ets new file mode 100644 index 0000000000000000000000000000000000000000..b980c146f4ab68a31fa33d1bbdae2d573d40e44a --- /dev/null +++ b/ets2panda/driver/build_system/test/simultaneous_compiling/namespace_import/entry/c.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + +export function falseRes(): boolean { + return false; +} \ No newline at end of file diff --git a/ets2panda/parser/program/program.cpp b/ets2panda/parser/program/program.cpp index f3efae5f7bed396045c8b381689f558af6d10c25..2386dc848ad4ad7a2be23e166b0248c2334a7049 100644 --- a/ets2panda/parser/program/program.cpp +++ b/ets2panda/parser/program/program.cpp @@ -181,6 +181,11 @@ void Program::SetASTChecked() programFlags_ |= ProgramFlags::AST_CHECKED; } +void Program::RemoveAstChecked() +{ + programFlags_ &= ~ProgramFlags::AST_CHECKED; +} + bool Program::IsASTChecked() { return ((programFlags_ & ProgramFlags::AST_CHECKED) != 0U) || diff --git a/ets2panda/parser/program/program.h b/ets2panda/parser/program/program.h index 50563781160126cab72ffe51ab8c72685be37cbf..fbb24ddfd2e1089f694870eeeca6edd1bc22e76c 100644 --- a/ets2panda/parser/program/program.h +++ b/ets2panda/parser/program/program.h @@ -283,6 +283,7 @@ public: void SetFlag(ProgramFlags flag); bool GetFlag(ProgramFlags flag) const; void SetASTChecked(); + void RemoveAstChecked(); bool IsASTChecked(); void MarkASTAsLowered()