diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 82f486c79ec36b88168d8a7e19e117f1e46cefbd..3d476850c4045291f9080c3e85d135d27d1f66dd 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -392,7 +392,7 @@ bool ETSChecker::CheckTypeParameterConstraint(ir::TSTypeParameter *param, Type2T void ETSChecker::SetUpTypeParameterConstraint(ir::TSTypeParameter *const param) { - ETSTypeParameter *const paramType = param->Name()->Variable()->TsType()->AsETSTypeParameter(); + ETSTypeParameter *const paramType = SetUpParameterType(param); auto const traverseReferenced = [this, scope = param->Parent()->AsTSTypeParameterDeclaration()->Scope()](ir::TypeNode *typeNode) { if (!typeNode->IsETSTypeReference()) { diff --git a/ets2panda/test/ast/compiler/ets/generic_lambda_constraint.ets b/ets2panda/test/ast/compiler/ets/generic_lambda_constraint.ets new file mode 100644 index 0000000000000000000000000000000000000000..05712b33247955285eb5c864f3ec5a9b6332301d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/generic_lambda_constraint.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. + */ + +let foo = (t: T, s: U) => {}; + +/* @@? 16:11 Error TypeError: Type '(t: T, s: U) => void' cannot be assigned to type '(t: T, s: U) => void' */ diff --git a/ets2panda/test/ast/compiler/ets/generic_lambda_constraint2.ets b/ets2panda/test/ast/compiler/ets/generic_lambda_constraint2.ets new file mode 100644 index 0000000000000000000000000000000000000000..68af871b315efd6c19103d74e864beb64732f4e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/generic_lambda_constraint2.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. + */ + +let foo = (t: T, s: U) => {}; + +/* @@? 16:11 Error TypeError: Type '(t: T, s: U) => void' cannot be assigned to type '(t: T, s: U) => void' */