From 8563a5c667bfc695e3167558fee284cc4474340b Mon Sep 17 00:00:00 2001 From: ekkoruse Date: Wed, 18 Jun 2025 14:30:05 +0800 Subject: [PATCH] fix export bug in external Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICG1RT?from=project-issue Signed-off-by: ekkoruse Change-Id: I0dfac8bdfe569dea1e169edeea4fafce6dd543f8 --- .../ets/import_export/eitest_export_A_1.ets | 16 ++ .../ets/import_export/eitest_export_A_2.ets | 18 ++ .../ets/import_export/eitest_export_B_1.ets | 16 ++ .../import_export/eitest_export_B_as_A_1.ets | 18 ++ .../eitest_export_default_A_1.ets | 16 ++ .../eitest_export_default_A_2.ets | 18 ++ .../eitest_export_default_B_1.ets | 16 ++ .../eitest_export_default_B_2.ets | 18 ++ ...test_export_default_import_default_A_1.ets | 18 ++ .../eitest_export_import_A_1.ets | 18 ++ .../eitest_export_import_A_2.ets | 18 ++ .../eitest_export_import_A_3.ets | 18 ++ .../eitest_export_import_default_A_1.ets | 18 ++ .../eitest_export_import_default_A_B_1.ets | 19 +++ .../import_export/eitest_export_type_A_1.ets | 19 +++ .../ets/import_export/eitest_import_A_1.ets | 20 +++ .../import_export/eitest_import_A_1_ne.ets | 24 +++ .../ets/import_export/eitest_import_A_2.ets | 20 +++ .../import_export/eitest_import_A_2_ne.ets | 24 +++ .../ets/import_export/eitest_import_A_3.ets | 20 +++ .../import_export/eitest_import_A_3_ne.ets | 24 +++ .../ets/import_export/eitest_import_A_4.ets | 20 +++ .../import_export/eitest_import_A_4_ne.ets | 24 +++ .../ets/import_export/eitest_import_A_5.ets | 20 +++ .../import_export/eitest_import_A_5_ne.ets | 24 +++ .../ets/import_export/eitest_import_A_6.ets | 20 +++ .../import_export/eitest_import_A_6_ne.ets | 24 +++ .../ets/import_export/eitest_import_A_7.ets | 20 +++ .../import_export/eitest_import_A_7_ne.ets | 24 +++ .../ets/import_export/eitest_import_A_B_1.ets | 21 +++ .../import_export/eitest_import_A_B_1_ne.ets | 24 +++ .../eitest_import_default_A_1.ets | 20 +++ .../eitest_import_default_A_1_ne.ets | 22 +++ .../eitest_import_default_A_2.ets | 20 +++ .../eitest_import_default_A_2_ne.ets | 24 +++ .../eitest_import_default_A_3.ets | 20 +++ .../eitest_import_default_A_3_ne.ets | 22 +++ .../import_export/eitest_import_type_A_1.ets | 20 +++ .../eitest_import_type_A_1_ne.ets | 22 +++ .../ets/import_export/external_export.ets | 16 ++ .../compiler/ets/import_export/test1_1.ets | 17 ++ .../compiler/ets/import_export/test2_1.ets | 18 ++ .../compiler/ets/import_export/test3_1.ets | 17 ++ .../srcdumper/srcdumper-ets-ignored.txt | 29 ++++ ets2panda/varbinder/ETSBinder.cpp | 159 ++++++++++++++++-- ets2panda/varbinder/ETSBinder.h | 18 +- 46 files changed, 1041 insertions(+), 20 deletions(-) create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_A_2.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_B_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_B_as_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_A_2.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_B_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_B_2.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_import_default_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_2.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_3.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_default_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_default_A_B_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_export_type_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_1_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_2.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_2_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_3.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_3_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_4.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_4_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_5.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_5_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_6.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_6_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_7.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_7_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_B_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_B_1_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_1_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_2.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_2_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_3.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_3_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_type_A_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/eitest_import_type_A_1_ne.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/external_export.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/test1_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/test2_1.ets create mode 100644 ets2panda/test/ast/compiler/ets/import_export/test3_1.ets diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_A_1.ets new file mode 100644 index 0000000000..6780a05eb1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_A_1.ets @@ -0,0 +1,16 @@ +/* + * 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 class A{} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_A_2.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_A_2.ets new file mode 100644 index 0000000000..a12a108de3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_A_2.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. + */ + +class A{} + +export A; \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_B_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_B_1.ets new file mode 100644 index 0000000000..e94062d246 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_B_1.ets @@ -0,0 +1,16 @@ +/* + * 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 class B{} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_B_as_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_B_as_A_1.ets new file mode 100644 index 0000000000..2e2d5ca5aa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_B_as_A_1.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. + */ + +class B{} + +export {B as A} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_A_1.ets new file mode 100644 index 0000000000..e7d776f8ed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_A_1.ets @@ -0,0 +1,16 @@ +/* + * 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 default class A{} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_A_2.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_A_2.ets new file mode 100644 index 0000000000..e3948e3dfb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_A_2.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. + */ + +class A{} + +export default A; \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_B_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_B_1.ets new file mode 100644 index 0000000000..c3d22a7b65 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_B_1.ets @@ -0,0 +1,16 @@ +/* + * 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 default class B{} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_B_2.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_B_2.ets new file mode 100644 index 0000000000..85a9380fbf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_B_2.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. + */ + +class B{} + +export default B; \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_import_default_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_import_default_A_1.ets new file mode 100644 index 0000000000..8ed966ae30 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_default_import_default_A_1.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 "./eitest_export_default_A_1" + +export default A \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_1.ets new file mode 100644 index 0000000000..472711f075 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_1.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 "./eitest_export_A_1" + +export A \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_2.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_2.ets new file mode 100644 index 0000000000..b815742961 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_2.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 {B} from "./eitest_export_B_1" + +export {B as A} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_3.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_3.ets new file mode 100644 index 0000000000..9d1da0fa43 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_A_3.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 as B} from "./eitest_export_A_1" + +export {B as A} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_default_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_default_A_1.ets new file mode 100644 index 0000000000..b30c26cbbe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_default_A_1.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 "./eitest_export_default_A_1" + +export A \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_default_A_B_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_default_A_B_1.ets new file mode 100644 index 0000000000..6fccdc60da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_import_default_A_B_1.ets @@ -0,0 +1,19 @@ +/* + * 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 "./eitest_export_default_A_1" +import B from "./eitest_export_default_B_1" + +export {A,B} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_export_type_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_type_A_1.ets new file mode 100644 index 0000000000..efebe3f5c0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_export_type_A_1.ets @@ -0,0 +1,19 @@ +/* + * 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 class A {} + +export default type CLASS_A = A; \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_1.ets new file mode 100644 index 0000000000..16412b6e62 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_1.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_A_1" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_1_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_1_ne.ets new file mode 100644 index 0000000000..3fed30fb92 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_1_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 "./eitest_export_A_1" + +function main(){ + let a :A = new A() +} + +/* @@? 16:15 Error TypeError: Cannot find default imported element in the target */ +/* @@? 19:12 Error TypeError: Cannot find type 'A'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'A'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_2.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_2.ets new file mode 100644 index 0000000000..4eb9ea3c1e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_2.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_A_2" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_2_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_2_ne.ets new file mode 100644 index 0000000000..a1da533413 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_2_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 "./eitest_export_A_2" + +function main(){ + let a :A = new A() +} + +/* @@? 16:15 Error TypeError: Cannot find default imported element in the target */ +/* @@? 19:12 Error TypeError: Cannot find type 'A'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'A'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_3.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_3.ets new file mode 100644 index 0000000000..d17ac7f13b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_3.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_B_as_A_1" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_3_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_3_ne.ets new file mode 100644 index 0000000000..5b0fa10162 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_3_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 "./eitest_export_B_as_A_1" + +function main(){ + let a :A = new A() +} + +/* @@? 16:15 Error TypeError: Cannot find default imported element in the target */ +/* @@? 19:12 Error TypeError: Cannot find type 'A'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'A'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_4.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_4.ets new file mode 100644 index 0000000000..48563cfcfb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_4.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_import_A_1" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_4_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_4_ne.ets new file mode 100644 index 0000000000..aa8c172b1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_4_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 "./eitest_export_import_A_1" + +function main(){ + let a :A = new A() +} + +/* @@? 16:15 Error TypeError: Cannot find default imported element in the target */ +/* @@? 19:12 Error TypeError: Cannot find type 'A'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'A'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_5.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_5.ets new file mode 100644 index 0000000000..036f643c19 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_5.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_import_A_2" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_5_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_5_ne.ets new file mode 100644 index 0000000000..38e266873e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_5_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 "./eitest_export_import_A_2" + +function main(){ + let a :A = new A() +} + +/* @@? 16:15 Error TypeError: Cannot find default imported element in the target */ +/* @@? 19:12 Error TypeError: Cannot find type 'A'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'A'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_6.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_6.ets new file mode 100644 index 0000000000..2ad8f1ce31 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_6.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_import_A_3" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_6_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_6_ne.ets new file mode 100644 index 0000000000..06251d9939 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_6_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 "./eitest_export_import_A_3" + +function main(){ + let a :A = new A() +} + +/* @@? 16:15 Error TypeError: Cannot find default imported element in the target */ +/* @@? 19:12 Error TypeError: Cannot find type 'A'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'A'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_7.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_7.ets new file mode 100644 index 0000000000..43b3cbfb6e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_7.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_import_default_A_1" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_7_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_7_ne.ets new file mode 100644 index 0000000000..2aa03a66a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_7_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 "./eitest_export_import_default_A_1" + +function main(){ + let a :A = new A() +} + +/* @@? 16:15 Error TypeError: Cannot find default imported element in the target */ +/* @@? 19:12 Error TypeError: Cannot find type 'A'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'A'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_B_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_B_1.ets new file mode 100644 index 0000000000..ad032143e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_B_1.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 {A,B} from "./eitest_export_import_default_A_B_1" + +function main(){ + let a :A = new A() + let b :B = new B() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_B_1_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_B_1_ne.ets new file mode 100644 index 0000000000..259a491d0a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_A_B_1_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 "./eitest_export_import_default_A_B_1" + +function main(){ + let a :A = new A() +} + +/* @@? 16:15 Error TypeError: Cannot find default imported element in the target */ +/* @@? 19:12 Error TypeError: Cannot find type 'A'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'A'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_1.ets new file mode 100644 index 0000000000..5fa1751e6b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_1.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_default_A_1" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_1_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_1_ne.ets new file mode 100644 index 0000000000..da65463362 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_1_ne.ets @@ -0,0 +1,22 @@ +/* + * 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 "./eitest_export_default_A_1" + +function main(){ + let a :A = new A() +} + +/* @@? 16:17 Error TypeError: Use the default import syntax to import a default exported element */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_2.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_2.ets new file mode 100644 index 0000000000..47bcf30f29 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_2.ets @@ -0,0 +1,20 @@ +/* + * 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 B from "./eitest_export_default_A_2" + +function main(){ + let a :B = new B() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_2_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_2_ne.ets new file mode 100644 index 0000000000..6758e4fdde --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_2_ne.ets @@ -0,0 +1,24 @@ +/* + * 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 {B} from "./eitest_export_default_A_2" + +function main(){ + let a :B = new B() +} + +/* @@? 16:17 Error TypeError: Cannot find imported element 'B' */ +/* @@? 19:12 Error TypeError: Cannot find type 'B'. */ +/* @@? 19:20 Error TypeError: Cannot find type 'B'. */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_3.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_3.ets new file mode 100644 index 0000000000..988105af2c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_3.ets @@ -0,0 +1,20 @@ +/* + * 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 "./eitest_export_default_import_default_A_1" + +function main(){ + let a :A = new A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_3_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_3_ne.ets new file mode 100644 index 0000000000..95df0589cc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_default_A_3_ne.ets @@ -0,0 +1,22 @@ +/* + * 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 "./eitest_export_default_import_default_A_1" + +function main(){ + let a :A = new A() +} + +/* @@? 16:17 Error TypeError: Use the default import syntax to import a default exported element */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_type_A_1.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_type_A_1.ets new file mode 100644 index 0000000000..2de45482ea --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_type_A_1.ets @@ -0,0 +1,20 @@ +/* + * 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 CLASS_A from "./eitest_export_type_A_1" + +function main(){ + let a :CLASS_A = new CLASS_A() +} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/eitest_import_type_A_1_ne.ets b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_type_A_1_ne.ets new file mode 100644 index 0000000000..a5e1725a38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/eitest_import_type_A_1_ne.ets @@ -0,0 +1,22 @@ +/* + * 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 {CLASS_A} from "./eitest_export_type_A_1" + +function main(){ + let a :CLASS_A = new CLASS_A() +} + +/* @@? 16:23 Error TypeError: Use the default import syntax to import a default exported element */ diff --git a/ets2panda/test/ast/compiler/ets/import_export/external_export.ets b/ets2panda/test/ast/compiler/ets/import_export/external_export.ets new file mode 100644 index 0000000000..01ac01d4e9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/external_export.ets @@ -0,0 +1,16 @@ +/* + * 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 {TT} from "./test1_1" diff --git a/ets2panda/test/ast/compiler/ets/import_export/test1_1.ets b/ets2panda/test/ast/compiler/ets/import_export/test1_1.ets new file mode 100644 index 0000000000..1fb57059d7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/test1_1.ets @@ -0,0 +1,17 @@ +/* + * 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 VAR_t from "./test2_1" +export class TT{} \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/test2_1.ets b/ets2panda/test/ast/compiler/ets/import_export/test2_1.ets new file mode 100644 index 0000000000..bcfbd1fa61 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/test2_1.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 {VAR_i as VAR_o} from "./test3_1" +export default VAR_o +export type VAR_j = string; \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/import_export/test3_1.ets b/ets2panda/test/ast/compiler/ets/import_export/test3_1.ets new file mode 100644 index 0000000000..7ce9d1c5be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/import_export/test3_1.ets @@ -0,0 +1,17 @@ +/* + * 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 {VAR_j as VAR_xj} from "./test2_1" +export type VAR_i = int; \ 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 cff206ab65..93f5508e79 100644 --- a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt +++ b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt @@ -192,3 +192,32 @@ runtime/ets/implicit_stringliteral_init.ets # #21051 should be log warnings, but there aren't ast/compiler/ets/not_initialized_variable/import_types.ets + +#Issue 22182 +ast/compiler/ets/implicit_package_import/package_test_5/package_module_1.sts + +#import tests, not test cases(path problem) +ast/compiler/ets/import_export/test1_1.ets +ast/compiler/ets/import_export/test1_1.ets +ast/compiler/ets/import_export/eitest_export_default_import_default_A_1.ets +ast/compiler/ets/import_export/eitest_export_import_A_1.ets +ast/compiler/ets/import_export/eitest_export_import_A_2.ets +ast/compiler/ets/import_export/eitest_export_import_A_3.ets +ast/compiler/ets/import_export/eitest_export_import_default_A_1.ets +ast/compiler/ets/import_export/eitest_export_import_default_A_B_1.ets +ast/compiler/ets/import_export/eitest_import_A_1.ets +ast/compiler/ets/import_export/eitest_import_A_2.ets +ast/compiler/ets/import_export/eitest_import_A_3.ets +ast/compiler/ets/import_export/eitest_import_A_4.ets +ast/compiler/ets/import_export/eitest_import_A_5.ets +ast/compiler/ets/import_export/eitest_import_A_6.ets +ast/compiler/ets/import_export/eitest_import_A_7.ets +ast/compiler/ets/import_export/eitest_import_A_B_1.ets +ast/compiler/ets/import_export/eitest_import_default_A_1.ets +ast/compiler/ets/import_export/eitest_import_default_A_2.ets +ast/compiler/ets/import_export/eitest_import_default_A_3.ets +ast/compiler/ets/import_export/eitest_import_type_A_1.ets +ast/compiler/ets/import_export/external_export.ets +ast/compiler/ets/import_export/test1_1.ets +ast/compiler/ets/import_export/test2_1.ets +ast/compiler/ets/import_export/test3_1.ets \ No newline at end of file diff --git a/ets2panda/varbinder/ETSBinder.cpp b/ets2panda/varbinder/ETSBinder.cpp index 0f9ae6db10..02aaed2982 100644 --- a/ets2panda/varbinder/ETSBinder.cpp +++ b/ets2panda/varbinder/ETSBinder.cpp @@ -785,11 +785,92 @@ static bool IsExportedVariable(varbinder::Variable *const var) (var->Declaration()->Node()->IsExported() || var->Declaration()->Node()->IsDefaultExported()); } -ir::ETSImportDeclaration *ETSBinder::FindImportDeclInReExports(const ir::ETSImportDeclaration *const import, - const util::StringView &imported, - const ir::StringLiteral *const importPath) +std::pair ETSBinder::FindImportDeclInExports( + const ir::ETSImportDeclaration *const import, const util::StringView &imported, + const ir::StringLiteral *const importPath) { ir::ETSImportDeclaration *implDecl = nullptr; + ir::AstNode *specifier = nullptr; + std::tie(implDecl, specifier) = FindImportDeclInReExports(import, imported, importPath); + if (implDecl != nullptr) { + return std::make_pair(implDecl, specifier); + } + std::tie(implDecl, specifier) = FindImportDeclInNamedExports(import, imported, importPath); + return std::make_pair(implDecl, specifier); +} + +static std::pair FindImportDeclInProgram(parser::Program *program, + const util::StringView &imported) +{ + for (auto stmt : program->Ast()->AsETSModule()->Statements()) { + if (!stmt->IsETSImportDeclaration()) { + continue; + } + for (auto specifier : stmt->AsETSImportDeclaration()->Specifiers()) { + if (specifier->IsImportSpecifier() && specifier->AsImportSpecifier()->Local()->Name() == imported) { + return std::make_pair(stmt->AsETSImportDeclaration(), specifier); + } else if (specifier->IsImportDefaultSpecifier() && + specifier->AsImportDefaultSpecifier()->Local()->Name() == imported) { + return std::make_pair(stmt->AsETSImportDeclaration(), specifier); + } + } + } + return std::make_pair(nullptr, nullptr); +} + +std::pair ETSBinder::FindImportDeclInNamedExports( + const ir::ETSImportDeclaration *const import, [[maybe_unused]] const util::StringView &imported, + const ir::StringLiteral *const importPath) +{ + auto importMapIter = selectiveExportAliasMultimap_.find(import->ImportMetadata().resolvedSource); + if (importMapIter == selectiveExportAliasMultimap_.end()) { + return std::make_pair(nullptr, nullptr); + } + auto pairIter = importMapIter->second.find(imported); + if (pairIter == importMapIter->second.end()) { + return std::make_pair(nullptr, nullptr); + } + auto [localName, declNode] = pairIter->second; + const auto records = GetExternalProgram(import->ImportMetadata().resolvedSource, importPath); + if (records.empty()) { + return std::make_pair(nullptr, nullptr); + } + auto currProgram = records[0]; + if (currProgram == nullptr) { + return std::make_pair(nullptr, nullptr); + } + auto [newImportDecl, specfier] = FindImportDeclInProgram(currProgram, localName); + if (newImportDecl == nullptr) { + return std::make_pair(nullptr, nullptr); + } + return std::make_pair(newImportDecl->AsETSImportDeclaration(), specfier); +} + +std::pair ETSBinder::FindImportDeclInReExports( + const ir::ETSImportDeclaration *const import, const util::StringView &imported, + const ir::StringLiteral *const importPath) +{ + ir::ETSImportDeclaration *implDecl = nullptr; + ir::AstNode *specifier = nullptr; + auto getSpecifier = [](const util::StringView &imported, ir::ETSImportDeclaration *decl) { + for (auto localSpecfier : decl->Specifiers()) { + util::StringView name; + if (localSpecfier->IsImportSpecifier()) { + name = localSpecfier->AsImportSpecifier()->Local()->Name(); + } else if (localSpecfier->IsImportNamespaceSpecifier()) { + name = localSpecfier->AsImportNamespaceSpecifier()->Local()->Name(); + } else { + name = localSpecfier->AsImportDefaultSpecifier()->Local()->Name(); + } + if (name == imported) { + return localSpecfier; + } + } + if (decl->Specifiers().size() == 1 && decl->Specifiers()[0]->IsImportNamespaceSpecifier()) { + return decl->Specifiers()[0]; + } + UNREACHABLE(); + }; for (auto item : ReExportImports()) { if (!ReexportPathMatchesImportPath(item, import)) { continue; @@ -803,6 +884,7 @@ ir::ETSImportDeclaration *ETSBinder::FindImportDeclInReExports(const ir::ETSImpo continue; } implDecl = item->GetETSImportDeclarations(); + specifier = getSpecifier(imported, implDecl); } else { const auto records = GetExternalProgram(item->GetETSImportDeclarations()->ResolvedSource(), importPath); if (records.empty()) { @@ -812,17 +894,20 @@ ir::ETSImportDeclaration *ETSBinder::FindImportDeclInReExports(const ir::ETSImpo FindImportSpecifiersVariable(imported, records[0]->GlobalScope()->Bindings(), Span {records}); if (IsExportedVariable(var)) { implDecl = item->GetETSImportDeclarations(); + specifier = getSpecifier(imported, implDecl); continue; } auto reExportImport = item->GetETSImportDeclarations(); auto reExportImportPath = reExportImport->Source(); - auto implDeclOrNullptr = FindImportDeclInReExports(reExportImport, imported, reExportImportPath); + auto [implDeclOrNullptr, localSpecifier] = + FindImportDeclInExports(reExportImport, imported, reExportImportPath); if (implDeclOrNullptr != nullptr) { implDecl = implDeclOrNullptr; + specifier = getSpecifier(imported, implDecl); } } } - return implDecl; + return std::make_pair(implDecl, specifier); } void ETSBinder::ValidateImportVariable(const ir::AstNode *node, const util::StringView &imported, @@ -856,6 +941,44 @@ bool ETSBinder::DetectNameConflict(const util::StringView localName, Variable *c return true; } +Variable *ETSBinder::AddImportSpecifierFromReExport(ir::AstNode *importSpecifier, + const ir::ETSImportDeclaration *const import, + const util::StringView &imported, + const ir::StringLiteral *const importPath) +{ + auto [implDecl, localSpecifier] = FindImportDeclInExports(import, imported, importPath); + Variable *localVar = nullptr; + auto insertBinding = [&](Variable *var) { + if (importSpecifier->IsImportSpecifier()) { + this->InsertOrAssignForeignBinding(importSpecifier->AsImportSpecifier()->Local()->Name(), var); + importSpecifier->AsImportSpecifier()->Local()->SetVariable(var); + importSpecifier->AsImportSpecifier()->Imported()->SetVariable(var); + } else if (importSpecifier->IsImportDefaultSpecifier()) { + this->InsertOrAssignForeignBinding(importSpecifier->AsImportDefaultSpecifier()->Local()->Name(), var); + importSpecifier->AsImportDefaultSpecifier()->Local()->SetVariable(var); + } + }; + if (implDecl != nullptr) { + if (localSpecifier->IsImportSpecifier() || localSpecifier->IsImportDefaultSpecifier()) { + AddSpecifiersToTopBindings(localSpecifier, implDecl); + if (localSpecifier->IsImportSpecifier()) { + localVar = localSpecifier->AsImportSpecifier()->Imported()->Variable(); + insertBinding(localVar); + } else if (localSpecifier->IsImportDefaultSpecifier()) { + localVar = localSpecifier->AsImportDefaultSpecifier()->Local()->Variable(); + insertBinding(localVar); + } + } else { + AddSpecifiersToTopBindings(importSpecifier, implDecl); + } + + return localVar; + } + + ThrowError(importPath->Start(), diagnostic::IMPORT_NOT_FOUND, {imported}); + return nullptr; +} + // CC-OFFNXT(huge_method, G.FUN.01-CPP) solid logic bool ETSBinder::AddImportSpecifiersToTopBindings(Span records, ir::ImportSpecifier *const importSpecifier, @@ -882,18 +1005,14 @@ bool ETSBinder::AddImportSpecifiersToTopBindings(Span re nameToSearchFor = imported; } - auto *const var = FindImportSpecifiersVariable(nameToSearchFor, globalBindings, records); + auto *var = FindImportSpecifiersVariable(nameToSearchFor, globalBindings, records); importSpecifier->Imported()->SetVariable(var); importSpecifier->Local()->SetVariable(var); if (var == nullptr) { - ir::ETSImportDeclaration *implDecl = FindImportDeclInReExports(import, imported, importPath); - if (implDecl != nullptr) { - AddSpecifiersToTopBindings(importSpecifier, implDecl); - return true; - } - - ThrowError(importPath->Start(), diagnostic::IMPORT_NOT_FOUND, {imported}); + var = AddImportSpecifierFromReExport(importSpecifier, import, imported, importPath); + } + if (var == nullptr) { return false; } @@ -938,9 +1057,15 @@ void ETSBinder::AddImportDefaultSpecifiersToTopBindings(Spansecond.begin(), selectMap2->second.end(), isDefaultExpored); if (item1 != selectMap2->second.end()) { - auto item2 = FindImportSpecifiersVariable(item1->first, globalBindings, records); - importDefaultSpecifier->Local()->SetVariable(item2); - InsertForeignBinding(importDefaultSpecifier, import, importDefaultSpecifier->Local()->Name(), item2); + auto var = FindImportSpecifiersVariable(item1->first, globalBindings, records); + if (var == nullptr) { + var = AddImportSpecifierFromReExport(importDefaultSpecifier, import, item1->first, import->Source()); + } + if (var == nullptr) { + return; + } + importDefaultSpecifier->Local()->SetVariable(var); + InsertOrAssignForeignBinding(importDefaultSpecifier->Local()->Name(), var); return; } } @@ -1301,7 +1426,7 @@ Variable *ETSBinder::ValidateImportSpecifier(const ir::ImportSpecifier *const sp } // Failed to find variable, go through reexports - const ir::ETSImportDeclaration *const implDecl = FindImportDeclInReExports(import, imported, import->Source()); + auto [implDecl, localSpecifier] = FindImportDeclInExports(import, imported, import->Source()); if (implDecl != nullptr) { return ValidateImportSpecifier(specifier, implDecl); } diff --git a/ets2panda/varbinder/ETSBinder.h b/ets2panda/varbinder/ETSBinder.h index 6d24b0f3c7..bc0096047f 100644 --- a/ets2panda/varbinder/ETSBinder.h +++ b/ets2panda/varbinder/ETSBinder.h @@ -154,9 +154,18 @@ public: [[nodiscard]] ArenaVector GetExternalProgram(util::StringView sourceName, const ir::StringLiteral *importPath); - ir::ETSImportDeclaration *FindImportDeclInReExports(const ir::ETSImportDeclaration *const import, - const util::StringView &imported, - const ir::StringLiteral *const importPath); + std::pair FindImportDeclInReExports( + const ir::ETSImportDeclaration *const import, const util::StringView &imported, + const ir::StringLiteral *const importPath); + std::pair FindImportDeclInNamedExports( + const ir::ETSImportDeclaration *const import, const util::StringView &imported, + const ir::StringLiteral *const importPath); + std::pair FindImportDeclInExports( + const ir::ETSImportDeclaration *const import, const util::StringView &imported, + const ir::StringLiteral *const importPath); + ir::ETSImportDeclaration *FindImportDeclIn(const ir::ETSImportDeclaration *const import, + const util::StringView &imported, + const ir::StringLiteral *const importPath); void AddImportNamespaceSpecifiersToTopBindings(Span records, ir::ImportNamespaceSpecifier *namespaceSpecifier, const ir::ETSImportDeclaration *import); @@ -171,6 +180,9 @@ public: const varbinder::Scope::VariableMap &globalBindings, Span record); Variable *FindStaticBinding(Span records, const ir::StringLiteral *importPath); + Variable *AddImportSpecifierFromReExport(ir::AstNode *importSpecifier, const ir::ETSImportDeclaration *const import, + const util::StringView &imported, + const ir::StringLiteral *const importPath); void AddSpecifiersToTopBindings(ir::AstNode *const specifier, const ir::ETSImportDeclaration *const import); void AddDynamicSpecifiersToTopBindings(ir::AstNode *const specifier, const ir::ETSImportDeclaration *const import); -- Gitee