/** * Creates a new complete constructor {@code AAssignmentDefinition} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param expression_ the {@link PExp} node for the {@code expression} child of this {@link AAssignmentDefinition} node * @param expType_ the {@link PType} <b>graph</a> node for the {@code expType} child of this {@link AAssignmentDefinition} node. * <i>The parent of this {@code expType } will not be changed by adding it to this node.</i> */ public AAssignmentDefinition(ILexLocation location_, ILexNameToken name_, NameScope nameScope_, Boolean used_, SClassDefinition classDefinition_, AAccessSpecifierAccessSpecifier access_, PType type_, Pass pass_, PExp expression_, PType expType_) { super(location_,name_,nameScope_,used_,classDefinition_,access_,type_,pass_); this.setExpression(expression_); this.setExpType(expType_); }
@Override public PType caseAAssignmentDefinition(AAssignmentDefinition node, TypeCheckInfo question) throws AnalysisException { question.qualifiers = null; node.setType(question.assistantFactory.createPTypeAssistant().typeResolve(question.assistantFactory.createPDefinitionAssistant().getType(node), null, THIS, question)); ExcludedDefinitions.setExcluded(node); node.setExpType(node.getExpression().apply(THIS, question)); ExcludedDefinitions.clearExcluded(); question.assistantFactory.getTypeComparator().checkComposeTypes(node.getType(), question.env, false); if (node.getExpType() instanceof AVoidType) { TypeCheckerErrors.report(3048, "Expression does not return a value", node.getExpression().getLocation(), node.getExpression()); } if (!question.assistantFactory.getTypeComparator().compatible(node.getType(), node.getExpType())) { TypeCheckerErrors.report(3000, "Expression does not match declared type", node.getExpression().getLocation(), node); TypeCheckerErrors.detail2("Declared", node.getType(), "Expression", node.getExpType()); } return node.getType(); }