diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index 8c863418787f03de6f0febfc91047f515be17453..fa04785886314f043d4cc8a599b930d4c337871c 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp @@ -1096,7 +1096,7 @@ std::string TSDeclGen::RemoveModuleExtensionName(const std::string &filepath) template void TSDeclGen::GenAnnotations(const T *node) { - if (node == nullptr) { + if (node == nullptr || (node->Annotations().size() == 0U)) { return; } GenSeparated( @@ -2275,6 +2275,7 @@ void TSDeclGen::GenMethodDeclaration(const ir::MethodDefinition *methodDef) if (ShouldSkipMethodDeclaration(methodDef)) { return; } + GenAnnotations(methodDef->Function()); const auto methodIdent = GetKeyIdent(methodDef->Key()); auto methodName = methodIdent->Name().Mutf8(); if (methodName.compare("$_iterator") == 0) { @@ -2313,10 +2314,6 @@ bool TSDeclGen::GenMethodDeclarationPrefix(const ir::MethodDefinition *methodDef !ShouldEmitDeclarationSymbol(methodIdent) && !methodDef->IsConstructor()) { return true; } - auto methDefFunc = methodDef->Function(); - if (methDefFunc != nullptr && !methDefFunc->Annotations().empty()) { - GenAnnotations(methDefFunc); - } ProcessIndent(); GenModifier(methodDef); }