diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index d70dd6580e128c896032c0d83853498d75726e41..2db130ba5549163802ba7114ae03e467dddac2d0 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -1169,6 +1169,7 @@ static varbinder::Variable *ResolveIdentifier(const ir::Identifier *ident) varbinder::ResolveBindingOptions::ALL_DECLARATION | varbinder::ResolveBindingOptions::ALL_VARIABLES; varbinder::Scope *scope = NearestScope(ident); + ES2PANDA_ASSERT(scope != nullptr); auto *resolved = scope->Find(ident->Name(), option).variable; return resolved; } diff --git a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp index d02274ff1f13745ccda4c8c013f8aaffb699c180..a6ce3452e6991f8100ef04dfbc60746344aec520 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp @@ -1251,8 +1251,7 @@ void InitScopesPhaseETS::VisitTSTypeParameter(ir::TSTypeParameter *typeParam) var->SetScope(VarBinder()->GetScope()); var->AddFlag(varbinder::VariableFlags::TYPE_PARAMETER); decl->BindNode(typeParam); - CallNode(typeParam->Annotations()); - CallNode(typeParam->DefaultType()); + Iterate(typeParam); } void InitScopesPhaseETS::VisitTSInterfaceDeclaration(ir::TSInterfaceDeclaration *interfaceDecl) diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index d9970074638f4d87b7610d70336eedddf0b3a7ca..975f9a4509d0bb3791d699d384fc5fd9d37dbded 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -2163,8 +2163,7 @@ ir::TSTypeParameter *ETSParser::ParseTypeParameter([[maybe_unused]] TypeAnnotati ir::TypeNode *constraint = nullptr; if (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_EXTENDS) { Lexer()->NextToken(); - TypeAnnotationParsingOptions newOptions = - TypeAnnotationParsingOptions::REPORT_ERROR | TypeAnnotationParsingOptions::IGNORE_FUNCTION_TYPE; + TypeAnnotationParsingOptions newOptions = TypeAnnotationParsingOptions::REPORT_ERROR; constraint = ParseTypeAnnotation(&newOptions); } diff --git a/ets2panda/test/runtime/ets/functionTypeParam.ets b/ets2panda/test/runtime/ets/functionTypeParam.ets new file mode 100644 index 0000000000000000000000000000000000000000..c4aff06bb5588c176a7978fcecd7eb394b8a07ae --- /dev/null +++ b/ets2panda/test/runtime/ets/functionTypeParam.ets @@ -0,0 +1,18 @@ +/* + * 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. + */ + +function f1 number]>(p: T): T { + return p; +}