diff --git a/ets2panda/ir/statements/annotationUsage.cpp b/ets2panda/ir/statements/annotationUsage.cpp index 1183e94543c49daac4bee8fd86eabf07723fc836..96a11de0b17bae8c228a5ff1eae2fb398385e89e 100644 --- a/ets2panda/ir/statements/annotationUsage.cpp +++ b/ets2panda/ir/statements/annotationUsage.cpp @@ -121,6 +121,11 @@ Identifier *AnnotationUsage::GetBaseName() const return expr_->AsIdentifier(); } auto *part = expr_->AsETSTypeReference()->Part(); + if (part->Name()->IsIdentifier()) { + ES2PANDA_ASSERT(part->Name()->AsIdentifier()->Name().Is(ERROR_LITERAL)); + return part->Name()->AsIdentifier(); + } + return part->Name()->AsTSQualifiedName()->Right(); } } // namespace ark::es2panda::ir diff --git a/ets2panda/test/ast/compiler/ets/annotation_dot_with_empty.ets b/ets2panda/test/ast/compiler/ets/annotation_dot_with_empty.ets new file mode 100644 index 0000000000000000000000000000000000000000..04581adbe9bc262665055db4ad73b3313a10c0be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/annotation_dot_with_empty.ets @@ -0,0 +1,23 @@ +/* + * 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 MyTest { + @Consume. + private property1; +} + +/* @@? 18:5 Error SyntaxError: Identifier expected. */ +/* @@? 18:5 Error TypeError: '*ERROR_LITERAL*' is not an annotation. */ +/* @@? 18:22 Error SyntaxError: Field type annotation expected. */