1 /*
2 * Copyright (c) 2021 - 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "checker/typeChecker/TypeChecker.h"
17 #include "generated/diagnostic.h"
18
19 namespace ark::es2panda::checker {
20
VisitArrowFunctionExpression(ir::ArrowFunctionExpression * node)21 void ETSTypeChecker::VisitArrowFunctionExpression(ir::ArrowFunctionExpression *node)
22 {
23 Iterate(node);
24 if (!node->TsType()->IsETSObjectType()) {
25 LogError(diagnostic::INFER_FAIL_ON_LAMBDA, {node->TsType()}, node->Start());
26 }
27 }
28
RunTypeChecker(Checker * checker,ScriptExtension ext,ir::AstNode * node)29 bool RunTypeChecker(Checker *checker, ScriptExtension ext, ir::AstNode *node)
30 {
31 switch (ext) {
32 case ScriptExtension::ETS:
33 return ETSTypeChecker(checker).Check(node);
34 case ScriptExtension::JS:
35 return JSTypeChecker(checker).Check(node);
36 case ScriptExtension::TS:
37 return TSTypeChecker(checker).Check(node);
38 case ScriptExtension::AS:
39 return ASTypeChecker(checker).Check(node);
40 default:
41 ES2PANDA_UNREACHABLE();
42 }
43 }
44
45 } // namespace ark::es2panda::checker
46