From 419021f2d00a4ac524a6682313c2ecdbda9ad73c Mon Sep 17 00:00:00 2001 From: zengzengran Date: Mon, 11 Aug 2025 19:47:36 +0800 Subject: [PATCH] Fix overload alias with same name function Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICRVEJ Description: 1.Fix overload alias with same name function 2.Fix inconsistent flag Settings when calling interface overlaod alias Tested-by: ninja tests (passed) ets_testrunner (passed) Signed-off-by: zengzengran # --- ets2panda/checker/checker.h | 46 ++++++++++ ets2panda/checker/checkerContext.h | 11 +++ ets2panda/checker/ets/typeCheckingHelpers.cpp | 2 +- ets2panda/checker/types/ets/etsObjectType.cpp | 17 ++-- .../ets/first_match/access_modifiers.ets | 4 +- .../ets/first_match/function_same_name.ets | 27 ++++++ .../ets/first_match/function_same_name.ets | 31 +++++++ .../ets/first_match/function_same_name2.ets | 58 ++++++++++++ .../ets/first_match/override_ambiguous.ets | 75 ++++++++++++++++ .../ets/first_match/override_ambiguous2.ets | 88 +++++++++++++++++++ .../ets/first_match/override_ambiguous3.ets | 65 ++++++++++++++ .../ets/first_match/override_interface2.ets | 51 +++++++++++ 12 files changed, 460 insertions(+), 15 deletions(-) create mode 100644 ets2panda/test/ast/compiler/ets/first_match/function_same_name.ets create mode 100644 ets2panda/test/runtime/ets/first_match/function_same_name.ets create mode 100644 ets2panda/test/runtime/ets/first_match/function_same_name2.ets create mode 100644 ets2panda/test/runtime/ets/first_match/override_ambiguous.ets create mode 100644 ets2panda/test/runtime/ets/first_match/override_ambiguous2.ets create mode 100644 ets2panda/test/runtime/ets/first_match/override_ambiguous3.ets create mode 100644 ets2panda/test/runtime/ets/first_match/override_interface2.ets diff --git a/ets2panda/checker/checker.h b/ets2panda/checker/checker.h index 2cfda48b91..d7466fb0d4 100644 --- a/ets2panda/checker/checker.h +++ b/ets2panda/checker/checker.h @@ -520,6 +520,52 @@ private: bool isLogError_; }; +class SignatureCollectContext { +public: + explicit SignatureCollectContext(Checker *checker, varbinder::LocalVariable *overloadDeclaration, + bool isCreateSyntheticVar = false) + : checker_(checker), isCreateSyntheticVar_(isCreateSyntheticVar) + { + preOverloadDeclaration_ = checker_->Context().ContainingOverloadDeclaration() != nullptr + ? checker_->Context().ContainingOverloadDeclaration()->AsLocalVariable() + : nullptr; + checker_->Context().SetContainingOverloadDeclaration(overloadDeclaration); + } + + bool IsOverloadDeclarationCall() + { + return checker_->Context().ContainingOverloadDeclaration() != nullptr; + } + + varbinder::LocalVariable *CreateSyntheticVar(ThreadSafeArenaAllocator *const allocator) + { + varbinder::VariableFlags variableFlags = + IsOverloadDeclarationCall() ? varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD | + varbinder::VariableFlags::OVERLOAD + : varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD; + varbinder::LocalVariable *syntheticVar = allocator->New(variableFlags); + return syntheticVar; + } + + ~SignatureCollectContext() + { + if (isCreateSyntheticVar_ && syntheticVar_ != nullptr) { + syntheticVar_->Reset(checker_->Context().ContainingOverloadDeclaration()->Declaration(), + syntheticVar_->Flags()); + checker_->Context().SetContainingOverloadDeclaration(preOverloadDeclaration_); + } + } + + NO_COPY_SEMANTIC(SignatureCollectContext); + NO_MOVE_SEMANTIC(SignatureCollectContext); + +private: + Checker *checker_; + bool isCreateSyntheticVar_; + varbinder::LocalVariable *preOverloadDeclaration_; + varbinder::LocalVariable *syntheticVar_ = nullptr; +}; + } // namespace ark::es2panda::checker #endif /* CHECKER_H */ diff --git a/ets2panda/checker/checkerContext.h b/ets2panda/checker/checkerContext.h index aa5e6b26fc..1c3f8cb59c 100644 --- a/ets2panda/checker/checkerContext.h +++ b/ets2panda/checker/checkerContext.h @@ -165,6 +165,11 @@ public: return status_; } + [[nodiscard]] varbinder::Variable *ContainingOverloadDeclaration() noexcept + { + return containingOverloadDeclaration_; + } + void SetContainingSignature(Signature *containingSignature) noexcept { containingSignature_ = containingSignature; @@ -175,6 +180,11 @@ public: containingClass_ = containingClass; } + void SetContainingOverloadDeclaration(varbinder::Variable *containingOverloadDeclaration) noexcept + { + containingOverloadDeclaration_ = containingOverloadDeclaration; + } + void AddCapturedVar(varbinder::Variable *var, const lexer::SourcePosition &pos) { capturedVars_.emplace(var, pos); @@ -275,6 +285,7 @@ private: const ETSObjectType *containingClass_ {nullptr}; ir::ArrowFunctionExpression *containingLambda_ {nullptr}; Signature *containingSignature_ {nullptr}; + varbinder::Variable *containingOverloadDeclaration_ {nullptr}; lexer::TokenType operatorType_ = lexer::TokenType::EOS; SmartCastCondition testCondition_ {}; diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index fe444bd85a..44084c6049 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -1750,7 +1750,7 @@ void ETSChecker::CheckFunctionOverloadDeclaration(ETSChecker *checker, ir::Overl PropertySearchFlags searchFlags = PropertySearchFlags::SEARCH_METHOD | PropertySearchFlags::SEARCH_IN_BASE | PropertySearchFlags::SEARCH_IN_INTERFACES | - PropertySearchFlags::IS_GETTER; + PropertySearchFlags::IS_GETTER | PropertySearchFlags::IGNORE_OVERLOAD; auto *variable = checker->ResolveOverloadReference(ident->AsIdentifier(), classType->AsETSObjectType(), searchFlags); if (variable == nullptr) { diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index 46e50a591a..30b33b3bef 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -252,8 +252,9 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co // Since both "first match" and "best match" exist at present, overloadDeclarationCall is temporarily used. After // "best match" removed, this marking needs to be removed. auto *overloadDeclaration = SearchFieldsDecls(name, UpdateOverloadDeclarationSearchFlags(flags)); - bool overloadDeclarationCall = overloadDeclaration != nullptr; - PropertySearchFlags syntheticFlags = overloadDeclarationCall ? UpdateOverloadDeclarationSearchFlags(flags) : flags; + SignatureCollectContext sigCtx {GetRelation()->GetChecker()->AsETSChecker(), overloadDeclaration, true}; + PropertySearchFlags syntheticFlags = + sigCtx.IsOverloadDeclarationCall() ? UpdateOverloadDeclarationSearchFlags(flags) : flags; varbinder::LocalVariable *functionalInterface = CollectSignaturesForSyntheticType(signatures, name, syntheticFlags); // #22952: the called function *always* returns nullptr @@ -264,11 +265,7 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co return nullptr; } - varbinder::VariableFlags varianceFlag = - overloadDeclarationCall ? varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD | - varbinder::VariableFlags::OVERLOAD - : varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD; - varbinder::LocalVariable *res = allocator_->New(varianceFlag); + varbinder::LocalVariable *res = sigCtx.CreateSyntheticVar(allocator_); ETSFunctionType *funcType = CreateMethodTypeForProp(name); ES2PANDA_ASSERT(funcType != nullptr); @@ -279,10 +276,6 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co res->SetTsType(funcType); funcType->SetVariable(res); - if (overloadDeclarationCall) { - res->Reset(overloadDeclaration->Declaration(), res->Flags()); - } - UpdateDeclarationForGetterSetter(res, funcType, flags); return res; @@ -351,6 +344,8 @@ void ETSObjectType::AddSignatureFromOverload(std::vector &signature return; } + SignatureCollectContext sigCtx {GetRelation()->GetChecker()->AsETSChecker(), found}; + if (overloadDeclaration->IsConstructorOverloadDeclaration()) { return AddSignatureFromConstructor(signatures, found); } diff --git a/ets2panda/test/ast/compiler/ets/first_match/access_modifiers.ets b/ets2panda/test/ast/compiler/ets/first_match/access_modifiers.ets index 4b2ca22d22..c816d68262 100644 --- a/ets2panda/test/ast/compiler/ets/first_match/access_modifiers.ets +++ b/ets2panda/test/ast/compiler/ets/first_match/access_modifiers.ets @@ -43,9 +43,7 @@ function main() { } /* @@@ label Error TypeError: Signature fooPrivate(x: String): void is not visible here. */ -/* @@@ label Error TypeError: No matching call signature for fooPrivate("abc") */ -/* @@@ label1 Error TypeError: Type '"abc"' is not compatible with type 'Double' at index 1 */ -/* @@@ label1 Error TypeError: Type '"abc"' is not compatible with type 'Boolean' at index 1 */ +/* @@@ label Error TypeError: No matching call signature for foo("abc") */ /* @@@ label2 Error TypeError: Signature fooPrivate(x: String): void is not visible here. */ /* @@@ label2 Error TypeError: No matching call signature for foo("abc") */ /* @@@ label3 Error TypeError: Signature fooProtected(x: Double): void is not visible here. */ diff --git a/ets2panda/test/ast/compiler/ets/first_match/function_same_name.ets b/ets2panda/test/ast/compiler/ets/first_match/function_same_name.ets new file mode 100644 index 0000000000..9c7fd33d5b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/first_match/function_same_name.ets @@ -0,0 +1,27 @@ +/* + * 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. + */ + +namespace NS{ + export function foo(a:number){} + export function foo2(a:string){} + export overload foo{foo2} +} + +function foo(a:number){} +function foo2(a:string){} +overload foo{foo2} + +/* @@? 19:24 Error TypeError: Method with the same name as overload declaration 'foo', overloadlist must list this medhod. */ +/* @@? 24:13 Error TypeError: Method with the same name as overload declaration 'foo', overloadlist must list this medhod. */ diff --git a/ets2panda/test/runtime/ets/first_match/function_same_name.ets b/ets2panda/test/runtime/ets/first_match/function_same_name.ets new file mode 100644 index 0000000000..1d0c7e8559 --- /dev/null +++ b/ets2panda/test/runtime/ets/first_match/function_same_name.ets @@ -0,0 +1,31 @@ +/* + * 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. + */ + +namespace NS { + export function foo(a: number) { return "namespace.invoke1" } + export function foo2(a: string) { return "namespace.invoke2" } + export overload foo{ foo, foo2 } +} + +function foo(a: number) { return "invoke1" } +function foo2(a: string) { return "invoke2" } +overload foo{ foo, foo2 } + +function main() { + arktest.assertEQ(foo(123), "invoke1") + arktest.assertEQ(foo("123"), "invoke2") + arktest.assertEQ(NS.foo(123), "namespace.invoke1") + arktest.assertEQ(NS.foo("123"), "namespace.invoke2") +} diff --git a/ets2panda/test/runtime/ets/first_match/function_same_name2.ets b/ets2panda/test/runtime/ets/first_match/function_same_name2.ets new file mode 100644 index 0000000000..19671d755b --- /dev/null +++ b/ets2panda/test/runtime/ets/first_match/function_same_name2.ets @@ -0,0 +1,58 @@ +/* + * 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. + */ + +type Callback = (data: T) => V; + +class KeyEvent { } + +namespace NS { + export overload onKeyEvent{ onKeyEvent1, onKeyEvent0 }; + export function onKeyEvent0(event: (((event: KeyEvent) => void) | undefined)): string { + return "namespace.invoke1"; + } + + export function onKeyEvent1(event: (Callback | undefined)): string { + return "namespace.invoke2"; + } +} + +overload onKeyEvent{ onKeyEvent1, onKeyEvent0 }; +function onKeyEvent0(event: (((event: KeyEvent) => void) | undefined)): string { + return "invoke1"; +} + +function onKeyEvent1(event: (Callback | undefined)): string { + return "invoke2"; +} + +function main() { + let test1 = onKeyEvent(((event: KeyEvent): boolean => { + return false; + })) + arktest.assertEQ(test1, "invoke2") + + let test2 = onKeyEvent(((event: KeyEvent): void => { + })) + arktest.assertEQ(test2, "invoke1") + + let test3 = NS.onKeyEvent(((event: KeyEvent): boolean => { + return false; + })) + arktest.assertEQ(test3, "namespace.invoke2") + + let test4 = NS.onKeyEvent(((event: KeyEvent): void => { + })) + arktest.assertEQ(test4, "namespace.invoke1") +} diff --git a/ets2panda/test/runtime/ets/first_match/override_ambiguous.ets b/ets2panda/test/runtime/ets/first_match/override_ambiguous.ets new file mode 100644 index 0000000000..38ccf779c9 --- /dev/null +++ b/ets2panda/test/runtime/ets/first_match/override_ambiguous.ets @@ -0,0 +1,75 @@ +/* + * 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 testString: string = ""; + +type Callback = (data: T) => V; + +class KeyEvent { } + +interface CommonMethod { + overload onKeyEvent{ onKeyEvent1, onKeyEvent0 }; + onKeyEvent0(event: (((event: KeyEvent) => void) | undefined)): this + onKeyEvent1(event: (Callback | undefined)): this + background(): this; +} + +export class CommonMethodImpl implements CommonMethod { + onKeyEvent0(event: (((event: KeyEvent) => void) | undefined)): this { + testString = "invoke1"; + return this; + } + + onKeyEvent1(event: (Callback | undefined)): this { + testString = "invoke2"; + return this; + } + background(): this { return this } +} + +function test1(a: CommonMethodImpl) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })).onKeyEvent(((event: KeyEvent): boolean => { + return false; + })) +} + +function test2(a: CommonMethodImpl) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })) +} + +function test3(a: CommonMethod) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })).onKeyEvent(((event: KeyEvent): boolean => { + return false; + })) +} + +function test4(a: CommonMethod) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })) +} + +function main(){ + test1(new CommonMethodImpl()); + arktest.assertEQ(testString,"invoke2"); + test2(new CommonMethodImpl()); + arktest.assertEQ(testString,"invoke1"); + test3(new CommonMethodImpl()); + arktest.assertEQ(testString,"invoke2"); + test4(new CommonMethodImpl()); + arktest.assertEQ(testString,"invoke1"); +} diff --git a/ets2panda/test/runtime/ets/first_match/override_ambiguous2.ets b/ets2panda/test/runtime/ets/first_match/override_ambiguous2.ets new file mode 100644 index 0000000000..1abc9c7fe6 --- /dev/null +++ b/ets2panda/test/runtime/ets/first_match/override_ambiguous2.ets @@ -0,0 +1,88 @@ +/* + * 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 testString: string = ""; + +type Callback = (data: T) => V; + +class KeyEvent { } + +class CommonMethod { + overload onKeyEvent{ onKeyEvent1, onKeyEvent0 }; + onKeyEvent0(event: (((event: KeyEvent) => void) | undefined)): this{ + testString = "invoke1"; + return this; + } + onKeyEvent1(event: (Callback | undefined)): this{ + testString = "invoke2"; + return this; + } + background(): this{ + return this; + } +} + +export class CommonMethodImpl extends CommonMethod { + onKeyEvent0(event: (((event: KeyEvent) => void) | undefined)): this { + testString = "invoke3"; + return this; + } + + onKeyEvent1(event: (Callback | undefined)): this { + testString = "invoke4"; + return this; + } + background(): this { return this } +} + +function test1(a: CommonMethodImpl) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })).onKeyEvent(((event: KeyEvent): boolean => { + return false; + })) +} + +function test2(a: CommonMethodImpl) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })) +} + +function test3(a: CommonMethod) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })).onKeyEvent(((event: KeyEvent): boolean => { + return false; + })) +} + +function test4(a: CommonMethod) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })) +} + +function main() { + test1(new CommonMethodImpl()); + arktest.assertEQ(testString, "invoke4"); + test2(new CommonMethodImpl()); + arktest.assertEQ(testString, "invoke3"); + test3(new CommonMethodImpl()); + arktest.assertEQ(testString, "invoke4"); + test4(new CommonMethodImpl()); + arktest.assertEQ(testString, "invoke3"); + + test3(new CommonMethod()); + arktest.assertEQ(testString, "invoke2"); + test4(new CommonMethod()); + arktest.assertEQ(testString, "invoke1"); +} diff --git a/ets2panda/test/runtime/ets/first_match/override_ambiguous3.ets b/ets2panda/test/runtime/ets/first_match/override_ambiguous3.ets new file mode 100644 index 0000000000..2ca33429c0 --- /dev/null +++ b/ets2panda/test/runtime/ets/first_match/override_ambiguous3.ets @@ -0,0 +1,65 @@ +/* + * 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 testString: string = ""; + +type Callback = (data: T) => V; + +class KeyEvent { } + +interface CommonMethod { + onKeyEvent(event: (((event: KeyEvent) => void) | undefined)): this + background(): this +} + +class CommonMethodImpl implements CommonMethod { + overload onKeyEvent{ onKeyEvent, onKeyEvent1 } + onKeyEvent(event: (((event: KeyEvent) => void) | undefined)): this { + testString = "invoke1"; + return this; + } + + onKeyEvent1(event: (Callback | undefined)): this { + testString = "invoke2"; + return this; + } + background(): this { return this } +} + +function test1(a: CommonMethodImpl) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })).onKeyEvent(((event: KeyEvent): boolean => { + return false; + })) +} + +function test2(a: CommonMethodImpl) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })) +} + +function test3(a: CommonMethod) { + a.background().onKeyEvent(((event: KeyEvent): void => { + })) +} + +function main() { + test1(new CommonMethodImpl()); + arktest.assertEQ(testString, "invoke2"); + test2(new CommonMethodImpl()); + arktest.assertEQ(testString, "invoke1"); + test3(new CommonMethodImpl()); + arktest.assertEQ(testString, "invoke1"); +} diff --git a/ets2panda/test/runtime/ets/first_match/override_interface2.ets b/ets2panda/test/runtime/ets/first_match/override_interface2.ets new file mode 100644 index 0000000000..1ee075ec74 --- /dev/null +++ b/ets2panda/test/runtime/ets/first_match/override_interface2.ets @@ -0,0 +1,51 @@ +/* + * 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. + */ + +interface I { + foo1(lambda: () => void): string + foo2(lambda: (p1: string, p2: number) => void): string + foo3(lambda: (p1: number, p2: string) => void): string + foo4(lambda: (p1: number, p2: string, p3: boolean) => void) :string + + overload foo{ foo1, foo2, foo3, foo4 } +} + +class Test implements I{ + foo1(lambda: () => void): string { + return "invoke1"; + } + foo2(lambda: (p1: string, p2: number) => void): string { + lambda("invoke2", 123456); + return "invoke2"; + } + foo3(lambda: (p1: number, p2: string) => void): string { + lambda(123456, "invoke3"); + return "invoke3"; + } + foo4(lambda: (p1: number, p2: string, p3: boolean) => void):string { + lambda(123, "123", true); + return "invoke4"; + } +} + +function main() { + let a: Test = new Test(); + arktest.assertEQ(a.foo(() => { }), "invoke1"); + arktest.assertEQ(a.foo((p1: string, p2) => { }), "invoke2"); + arktest.assertEQ(a.foo((p1: number, p2) => { }), "invoke3"); + arktest.assertEQ(a.foo((p1, p2) => { }), "invoke2"); + arktest.assertEQ(a.foo((p1: number, p2, p3) => { }), "invoke4"); + arktest.assertEQ(a.foo((p1, p2, p3) => { }), "invoke4"); +} -- Gitee