diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index c356541eec892b7caeddc9a4837c66fdc74d9c47..0a8939f6c6f0260c02e72b30b1bcd1fbfaece7f4 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -1909,7 +1909,8 @@ static Type *TransformTypeForMethodReference(ETSChecker *checker, ir::Expression checker->LogError(diagnostic::OVERLOADED_METHOD_AS_VALUE, getUseSite()); return checker->GlobalTypeError(); } - return functionType->MethodToArrow(checker); + auto *otherFuncType = functionType->MethodToArrow(checker); + return otherFuncType == nullptr ? checker->GlobalTypeError() : otherFuncType; } checker::Type *ETSAnalyzer::Check(ir::Identifier *expr) const diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp index 2a963cb7376fdc0ce957b0575b2f83dad1e79a5b..669ab5d1ed0a67aaf076429635f2f8b91605e10d 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.cpp +++ b/ets2panda/checker/types/ets/etsFunctionType.cpp @@ -15,6 +15,7 @@ #include "checker/ETSchecker.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/typeError.h" #include "compiler/lowering/phase.h" namespace ark::es2panda::checker { @@ -157,7 +158,7 @@ ETSFunctionType *ETSFunctionType::MethodToArrow(ETSChecker *checker) return found->second; } - ES2PANDA_ASSERT(!IsETSArrowType() && CallSignatures().size() == 1); + ERROR_SANITY_CHECK(checker, !IsETSArrowType() && CallSignatures().size() == 1, return nullptr); return cached.emplace(this, checker->CreateETSArrowType(CallSignatures()[0])).first->second; } diff --git a/ets2panda/test/ast/compiler/ets/call_signature.ets b/ets2panda/test/ast/compiler/ets/call_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae2f208c22f3b429eb7e17cfb0dc4ca80c823e59 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/call_signature.ets @@ -0,0 +1,37 @@ +/* + * 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 Proxy { + private foo(target: T) {} + private bar( + getter:Method: void { + const result = getter.getType() + const Create = new MethodCreate(getter.getName()).addResult(resultType + Create.AddBody(new AbortController((): Byte => { + const handle = Reflect.get() + return (this.foo(handle) as Numeric).toByte.) + } + } + ) +} + +/* @@? 17:25 Error TypeError: Cannot find type 'T'. */ +/* @@? 19:22 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 21:28 Error TypeError: Cannot find type 'MethodCreate'. */ +/* @@? 22:13 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 22:32 Error TypeError: Cannot find type 'AbortController'. */ +/* @@? 24:61 Error SyntaxError: Identifier expected, got ')'. */ +/* @@? 26:9 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 27:5 Error SyntaxError: Unexpected token ')'. */