From 3eac26afa8226cef3ae8681451417149f3d3d726 Mon Sep 17 00:00:00 2001 From: renguangxuan Date: Wed, 10 Sep 2025 14:28:57 +0800 Subject: [PATCH] Fix define interface in class Issue: #ICXAXQ Signed-off-by: renguangxuan --- ets2panda/checker/ets/typeCheckingHelpers.cpp | 5 +--- .../runtime/ets/fuzz/class_body_interface.ets | 27 +++++++++++++++++++ .../declgen-ets2ts-runtime-ignored.txt | 1 + .../srcdumper/srcdumper-ets-ignored.txt | 1 + 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 ets2panda/test/runtime/ets/fuzz/class_body_interface.ets diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index dd0a84f46e..5233e18ba1 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -710,11 +710,8 @@ Type *ETSChecker::GuaranteedTypeForUncheckedPropertyAccess(varbinder::Variable * case ir::AstNodeType::METHOD_DEFINITION: case ir::AstNodeType::CLASS_DEFINITION: return GetTypeOfVariable(prop); - case ir::AstNodeType::OVERLOAD_DECLARATION: - case ir::AstNodeType::TS_ENUM_DECLARATION: - return nullptr; default: - ES2PANDA_UNREACHABLE(); + return nullptr; } } diff --git a/ets2panda/test/runtime/ets/fuzz/class_body_interface.ets b/ets2panda/test/runtime/ets/fuzz/class_body_interface.ets new file mode 100644 index 0000000000..2c8c0895e4 --- /dev/null +++ b/ets2panda/test/runtime/ets/fuzz/class_body_interface.ets @@ -0,0 +1,27 @@ +/* + * 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. + */ +/*--- + tags: [compile-only, negative] +---*/ + +class A { + interface foo {} +} + +class B { + A.foo f1 = new A.foo() { + A.foo bar() {} + } +} diff --git a/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt b/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt index 4444cd873b..61fb015d81 100644 --- a/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt +++ b/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt @@ -30,3 +30,4 @@ typeAlias_2.ets Multiline_string.ets Multiline_string_escape_char.ets async_lambda_return_type_test.ets +fuzz/class_body_interface.ets diff --git a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt index 85df783af7..d834113123 100644 --- a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt +++ b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt @@ -54,6 +54,7 @@ runtime/ets/fuzz/too_many_left_brace.ets runtime/ets/fuzz/too_many_left_square_brackets.ets runtime/ets/fuzz/too_many_new_expr.ets runtime/ets/fuzz/too_many_expression.ets +runtime/ets/fuzz/class_body_interface.ets ast/compiler/ets/DeclareIndexerTest.ets ast/parser/ets/import_tests/import_class_with_static_field/import_class_with_static_field.ets -- Gitee