diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index b10a5e7edbf30a99907595fac61122e3559db908..4f8ce5b9b344684e9be5099d54e0f5b1cfbf45be 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -474,6 +474,16 @@ bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, if (CheckLambdaAssignable(targetParm->AsETSParameterExpression(), lambda)) { continue; } + if (argument->TsType() != nullptr) { + auto *targetType = substitutedSig->Params()[index]->TsType(); + auto const invocationCtx = checker::InvocationContext(Relation(), argument, argument->TsType(), + targetType, argument->Start(), + {{diagnostic::TYPE_MISMATCH_AT_IDX, {argument->TsType(), targetType, index + 1}}}, + flags | TypeRelationFlag::ONLY_CHECK_WIDENING | TypeRelationFlag::NO_THROW); + if (invocationCtx.IsInvocable()) { + continue; + } + } return false; } diff --git a/ets2panda/test/runtime/ets/lambda_in_record_without_return_type.ets b/ets2panda/test/runtime/ets/lambda_in_record_without_return_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..1fc0dd403151ab26e5778aa8e42a342a06eb6708 --- /dev/null +++ b/ets2panda/test/runtime/ets/lambda_in_record_without_return_type.ets @@ -0,0 +1,17 @@ +/* + * 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 A {} +let a : Recordvoid)> = {"1":new A(), 2:()=>{}} \ No newline at end of file