Lines Matching refs:init

564 checker::Type *ETSChecker::CheckArrayElements(ir::ArrayExpression *init)
567 for (auto e : init->AsArrayExpression()->Elements()) {
584 void ETSChecker::InferAliasLambdaType(ir::TypeNode *localTypeAnnotation, ir::ArrowFunctionExpression *init)
606 auto *const arrowFuncExpr = init;
616 ir::Expression *init)
620 if (init != nullptr && init->TsType()->IsETSEnumType()) {
621 init->SetBoxingUnboxingFlags(ir::BoxingUnboxingFlags::BOX_TO_ENUM);
657 bool ETSChecker::CheckInit(ir::Identifier *ident, ir::TypeNode *typeAnnotation, ir::Expression *init,
661 if (init->IsArrayExpression()) {
662 annotationType = CheckArrayElements(init->AsArrayExpression());
666 if (init->IsObjectExpression()) {
674 if (init->IsMemberExpression() && init->AsMemberExpression()->Object()->IsObjectExpression()) {
679 if ((init->IsMemberExpression()) && (annotationType != nullptr)) {
680 SetArrayPreferredTypeForNestedMemberExpressions(init->AsMemberExpression(), annotationType);
683 if (init->IsArrayExpression() && (annotationType != nullptr) && annotationType->IsETSArrayType()) {
685 if (!ValidateTupleMinElementSize(init->AsArrayExpression(), annotationType->AsETSTupleType())) {
690 init->AsArrayExpression()->SetPreferredType(annotationType);
693 if (init->IsObjectExpression()) {
694 init->AsObjectExpression()->SetPreferredType(PreferredObjectTypeFromAnnotation(annotationType));
697 if (typeAnnotation != nullptr && init->IsArrowFunctionExpression()) {
698 InferAliasLambdaType(typeAnnotation, init->AsArrowFunctionExpression());
702 void ETSChecker::CheckEnumType(ir::Expression *init, checker::Type *initType, const util::StringView &varName)
705 !init->IsMemberExpression()) {
707 init->Start());
722 ir::Expression *init, ir::ModifierFlags const flags)
741 if (init == nullptr) {
742 return FixOptionalVariableType(bindingVar, flags, init);
745 if (!CheckInit(ident, typeAnnotation, init, annotationType, bindingVar)) {
749 checker::Type *initType = init->Check(this);
752 LogTypeError("Cannot get the expression type", init->Start());
757 if (!init->IsArrowFunctionExpression() && (initType->AsETSFunctionType()->CallSignatures().size() != 1)) {
758 ThrowTypeError("Ambiguous function initialization because of multiple overloads", init->Start());
769 CheckAnnotationTypeForVariableDeclaration(annotationType, annotationType->IsETSUnionType(), init, initType);
774 bindingVar->SetTsType(init->TsType());
776 return FixOptionalVariableType(bindingVar, flags, init);
779 CheckEnumType(init, initType, varName);
783 !omitInitConstness && typeAnnotation == nullptr && NeedWideningBasedOnInitializerHeuristics(init);
786 return FixOptionalVariableType(bindingVar, flags, init);
790 ir::Expression *init, checker::Type *initType)
805 if (!AssignmentContext(Relation(), init, initType, annotationType, init->Start(), {},
808 LogTypeError({"Type '", sourceType, "' cannot be assigned to type '", annotationType, "'"}, init->Start());
811 if (!AssignmentContext(Relation(), init, initType, annotationType, init->Start(), {},
816 init->Start());