Lines Matching refs:checker

18 #include "checker/TSchecker.h"
26 checker::Type *ForOfStatement::CreateUnionIteratorTypes(checker::ETSChecker *checker, checker::Type *exprType)
28 ArenaVector<checker::Type *> types(checker->Allocator()->Adapter());
32 types.push_back(checker->GetGlobalTypesHolder()->GlobalCharType());
34 types.push_back(this->CheckIteratorMethodForObject(checker, it->AsETSObjectType()));
36 types.push_back(it->AsETSArrayType()->ElementType()->Instantiate(checker->Allocator(), checker->Relation(),
37 checker->GetGlobalTypesHolder()));
38 types.back()->RemoveTypeFlag(checker::TypeFlag::CONSTANT);
44 return checker->CreateETSUnionType(std::move(types));
110 checker::Type *ForOfStatement::Check(checker::TSChecker *checker)
112 return checker->GetAnalyzer()->Check(this);
115 checker::Type *ForOfStatement::Check(checker::ETSChecker *checker)
117 return checker->GetAnalyzer()->Check(this);
150 checker::Type *ForOfStatement::CheckIteratorMethodForObject(checker::ETSChecker *checker,
151 checker::ETSObjectType *sourceType)
155 checker::PropertySearchFlags searchFlag =
156 checker::PropertySearchFlags::SEARCH_METHOD | checker::PropertySearchFlags::IS_FUNCTIONAL;
157 searchFlag |= checker::PropertySearchFlags::SEARCH_IN_BASE | checker::PropertySearchFlags::SEARCH_IN_INTERFACES;
158 // NOTE: maybe we need to exclude static methods: search_flag &= ~(checker::PropertySearchFlags::SEARCH_STATIC)
160 if (sourceType->HasTypeFlag(checker::TypeFlag::GENERIC)) {
161 searchFlag |= checker::PropertySearchFlags::SEARCH_ALL;
166 checker->LogTypeError("Object type doesn't have proper iterator method.", position);
170 ArenaVector<Expression *> arguments {checker->Allocator()->Adapter()};
171 auto &signatures = checker->GetTypeOfVariable(method)->AsETSFunctionType()->CallSignatures();
173 checker::Signature *signature = checker->ValidateSignatures(signatures, nullptr, arguments, position, "iterator",
174 checker::TypeRelationFlag::NO_THROW);
176 checker->LogTypeError("Cannot find iterator method with the required signature.", position);
179 checker->ValidateSignatureAccessibility(sourceType, nullptr, signature, position,
185 checker->CheckThrowingStatements(this);
188 if (!CheckReturnTypeOfIteratorMethod(checker, sourceType, signature, position)) {
195 checker->LogTypeError("Iterator object doesn't have proper next method.", position);
199 auto &nextSignatures = checker->GetTypeOfVariable(nextMethod)->AsETSFunctionType()->CallSignatures();
201 auto const *const nextSignature = checker->ValidateSignatures(nextSignatures, nullptr, arguments, position,
202 "iterator", checker::TypeRelationFlag::NO_THROW);
213 bool ForOfStatement::CheckReturnTypeOfIteratorMethod(checker::ETSChecker *checker, checker::ETSObjectType *sourceType,
214 checker::Signature *signature,
217 if ((signature->ReturnType() == nullptr || signature->ReturnType() == checker->GlobalVoidType()) &&
221 checker::SavedCheckerContext savedContext(checker, checker::CheckerStatus::IN_CLASS, sourceType);
222 it->AsReturnStatement()->Check(checker);
229 ForOfStatement::CheckIteratorInterfaceForObject(checker, signature->ReturnType()->AsETSObjectType())) {
233 checker->LogTypeError("Iterator method must return an object which implements Iterator<T>", position);
237 bool ForOfStatement::CheckIteratorInterfaceForObject(checker::ETSChecker *checker, checker::ETSObjectType *obj)
246 CheckIteratorInterfaceForObject(checker, obj->SuperType()->AsETSObjectType());
249 checker::Type *ForOfStatement::CheckIteratorMethod(checker::ETSChecker *const checker)
253 return CheckIteratorMethodForObject(checker, exprType->AsETSObjectType());
257 return this->CreateUnionIteratorTypes(checker, exprType);