diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index 7034998575815c6518c0c4014ccf070c8b323e2e..f27f305aa716fc2e4254e244d27a52df2e09d954 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -621,6 +621,10 @@ bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, if (!ValidateSignatureInvocationContext(substitutedSig, argument, index, flags)) { return false; } + + if (argument->TsType()->HasTypeFlag(TypeFlag::ETS_INT_ENUM) && paramType->HasTypeFlag(TypeFlag::ETS_INT_ENUM)) { + argument->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + } } return CheckArrowFunctionParamIfNeeded(this, substitutedSig, arguments, flags); diff --git a/ets2panda/test/runtime/ets/overload_with_enum_param.ets b/ets2panda/test/runtime/ets/overload_with_enum_param.ets new file mode 100644 index 0000000000000000000000000000000000000000..83c65060c799c7189f284912189ea70f5fb084bd --- /dev/null +++ b/ets2panda/test/runtime/ets/overload_with_enum_param.ets @@ -0,0 +1,42 @@ +/* + * 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. + */ + +enum Myenum{ + A, + B +} + +function foo(a: Myenum): string { + return "Enum"; +} + +function foo(a: number): number { + return 42; +} + +export default function function_overload_with_enum(): number { + + let result1 = foo(Myenum.A); + let result2 = foo(10); + + let s1 = (result1 === "Enum"); + let s2 = (result2 === 42); + + return s1 && s2 ? 0 : 1; +} + +function main() { + arktest.assertEQ(function_overload_with_enum(), 0) +}