From 0bdedc893bdc13778d8f85513bf5aafcc614bd69 Mon Sep 17 00:00:00 2001 From: lijincheng Date: Sun, 22 Jun 2025 18:36:38 +0800 Subject: [PATCH] Json support annotation 1. cherry pick to 0603 Issue:https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICGXDV Signed-off-by: lijincheng --- ets2panda/compiler/core/ETSemitter.cpp | 5 ++++- .../test/runtime/ets/AnnotationOfClassPropertyInherit.ets | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index 98dd37c7b5..6eba5e1753 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -437,11 +437,14 @@ void ETSEmitter::GenClassField(const ir::ClassProperty *prop, pandasm::Record &c field.type = PandasmTypeWithRank(prop->TsType()); field.metadata->SetAccessFlags(TranslateModifierFlags(prop->Modifiers())); + if (!external) { + field.metadata->SetAnnotations(GenCustomAnnotations(prop->Annotations(), field.name)); + } + if (external || prop->IsDeclare()) { field.metadata->SetAttribute(Signatures::EXTERNAL); } else if (prop->TsType()->IsETSPrimitiveType() || prop->TsType()->IsETSStringType()) { EmitDefaultFieldValue(field, prop->Value()); - field.metadata->SetAnnotations(GenCustomAnnotations(prop->Annotations(), field.name)); } classRecord.fieldList.emplace_back(std::move(field)); diff --git a/ets2panda/test/runtime/ets/AnnotationOfClassPropertyInherit.ets b/ets2panda/test/runtime/ets/AnnotationOfClassPropertyInherit.ets index f7f39edabb..1a10d2134b 100644 --- a/ets2panda/test/runtime/ets/AnnotationOfClassPropertyInherit.ets +++ b/ets2panda/test/runtime/ets/AnnotationOfClassPropertyInherit.ets @@ -13,12 +13,12 @@ * limitations under the License. */ -@interface JSONRename { +@interface JSONRenameTest { name:string = "" } class A { - @JSONRename("ID") + @JSONRenameTest("ID") name2: string = "" pwd2: string = "" } -- Gitee