From e63a401ccddac196c859210bfdcd8b280619dce3 Mon Sep 17 00:00:00 2001 From: renguangxuan Date: Mon, 8 Sep 2025 14:54:34 +0800 Subject: [PATCH] Fix define interface in class Issue: #ICWW7X 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 5ea56002c7..f4048ebd6f 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -709,11 +709,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 7668597d9d..dd3f9cb378 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 @@ -32,3 +32,4 @@ Multiline_string_escape_char.ets run_ok_without_semicolon.ets async_lambda_return_type_test.ets fuzz/repeated_del.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 c3722928d8..a7c61d98b5 100644 --- a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt +++ b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt @@ -57,6 +57,7 @@ runtime/ets/fuzz/too_many_new_expr.ets runtime/ets/fuzz/too_many_token.ets runtime/ets/fuzz/repeated_del.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