From 8b5039ec16f51b5ac4d84d1a41cf59ffdb13e494 Mon Sep 17 00:00:00 2001 From: daizihan Date: Thu, 22 May 2025 09:51:53 +0800 Subject: [PATCH] Fix reexport bug with relative path Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IC9KUQ?from=project-issue Signed-off-by: daizihan --- ets2panda/parser/ETSparser.cpp | 2 +- .../test/ast/parser/ets/re_export/export_5.ets | 18 ++++++++++++++++++ .../test/ast/parser/ets/re_export/export_6.ets | 18 ++++++++++++++++++ .../ast/parser/ets/re_export/re_export_16.ets | 16 ++++++++++++++++ .../srcdumper/srcdumper-ets-ignored.txt | 3 +++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/ast/parser/ets/re_export/export_5.ets create mode 100644 ets2panda/test/ast/parser/ets/re_export/export_6.ets create mode 100644 ets2panda/test/ast/parser/ets/re_export/re_export_16.ets diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 9aa2bcd87f..5364fc13da 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -996,7 +996,7 @@ ir::Statement *ETSParser::ParseExport(lexer::SourcePosition startLoc, ir::Modifi // re-export directive auto *reExportDeclaration = ParseImportPathBuildImport(std::move(specifiers), true, startLoc, ir::ImportKinds::ALL); auto reExport = AllocNode(reExportDeclaration, std::vector(), - GetProgram()->SourceFilePath(), Allocator()); + GetProgram()->AbsoluteName(), Allocator()); reExport->AddModifier(modifiers); return reExport; } diff --git a/ets2panda/test/ast/parser/ets/re_export/export_5.ets b/ets2panda/test/ast/parser/ets/re_export/export_5.ets new file mode 100644 index 0000000000..745a950975 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/re_export/export_5.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 {test2} from './re_export_16' + +export class test1 {} diff --git a/ets2panda/test/ast/parser/ets/re_export/export_6.ets b/ets2panda/test/ast/parser/ets/re_export/export_6.ets new file mode 100644 index 0000000000..1628fe5be5 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/re_export/export_6.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 {test1} from './export_5' + +export class test2 {} diff --git a/ets2panda/test/ast/parser/ets/re_export/re_export_16.ets b/ets2panda/test/ast/parser/ets/re_export/re_export_16.ets new file mode 100644 index 0000000000..e98c8fe230 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/re_export/re_export_16.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024-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 {test2} from './export_6' \ No newline at end of file diff --git a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt index c44899c0eb..c63c252969 100644 --- a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt +++ b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt @@ -17,6 +17,9 @@ ast/parser/ets/import_tests/export_and_import_class.ets ast/parser/ets/import_tests/export_and_import_top_level.ets ast/parser/ets/re_export/import_11.ets ast/parser/ets/re_export/import_12.ets +ast/parser/ets/re_export/export_5.ets +ast/parser/ets/re_export/export_6.ets +ast/parser/ets/re_export/re_export_16.ets ast/parser/ets/re_export/re_export_11.ets ast/parser/ets/re_export/re_export_12.ets ast/parser/ets/re_export/re_export_5.ets -- Gitee