diff --git a/ets2panda/compiler/lowering/ets/annotationCopyLowering.cpp b/ets2panda/compiler/lowering/ets/annotationCopyLowering.cpp index 7944383399fa3ad4805b71f429a7ef4279eb4a6e..63ca3620fa2ba069fc1db3f366f5f2d8d2197f95 100644 --- a/ets2panda/compiler/lowering/ets/annotationCopyLowering.cpp +++ b/ets2panda/compiler/lowering/ets/annotationCopyLowering.cpp @@ -43,6 +43,9 @@ void CopyAnnotationProperties(public_lib::Context *ctx, ir::AnnotationUsage *st) st->Properties().front()->AsClassProperty()->Id()->Name() == compiler::Signatures::ANNOTATION_KEY_VALUE) { auto *param = st->Properties().front()->AsClassProperty(); auto singleField = annoDecl->Properties().front()->AsClassProperty(); + if (singleField == nullptr || singleField->TypeAnnotation() == nullptr) { + return; + } auto clone = singleField->TypeAnnotation()->Clone(ctx->Allocator(), param); param->SetTypeAnnotation(clone); return; diff --git a/ets2panda/test/ast/compiler/ets/singleField_typeAnnotation_nullptr.ets b/ets2panda/test/ast/compiler/ets/singleField_typeAnnotation_nullptr.ets new file mode 100755 index 0000000000000000000000000000000000000000..c65da1422e437acccc2387717acc81ea1aa4a571 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/singleField_typeAnnotation_nullptr.ets @@ -0,0 +1,30 @@ +/* + * 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. + */ + +@Retention("SOURCE") +@interface Retention(nno +()=>{} + +/* @@? 1:3 Error TypeError: Variable 'Retention' is already defined. */ +/* @@? 16:2 Error TypeError: Only standard annotations are allowed to be applied on annotations. */ +/* @@? 16:2 Error TypeError: Annotation 'Retention' requires multiple fields to be specified. */ +/* @@? 17:21 Error SyntaxError: Expected '{', got '('. */ +/* @@? 18:1 Error SyntaxError: Annotation can not have method as property. */ +/* @@? 18:1 Error SyntaxError: Missing type annotation for property 'nno'. */ +/* @@? 18:1 Error SyntaxError: Identifier expected, got '('. */ +/* @@? 18:2 Error SyntaxError: Identifier expected, got ')'. */ +/* @@? 18:3 Error SyntaxError: Identifier expected, got '=>'. */ +/* @@? 18:5 Error SyntaxError: Identifier expected, got '{'. */ +/* @@? 18:6 Error SyntaxError: Identifier expected, got '}'. */ \ No newline at end of file