package abstractSyntaxTree.StatementExpression; import TypeCheck.AbstractType; import TypeCheck.TypeCheckHelper; import TypeCheck.TypeCheckResult; import abstractSyntaxTree.Expression.IExpression; import abstractSyntaxTree.Statement.IStatement; import java.util.Objects; public class AssignStatementExpression extends AbstractType implements IExpression, IStatement { public String operator; public IExpression left; public IExpression right; @Override public TypeCheckResult typeCheck() throws Exception { TypeCheckHelper helper = new TypeCheckHelper(); TypeCheckResult result = new TypeCheckResult(); TypeCheckResult leftType = left.typeCheck(); TypeCheckResult rightType = right.typeCheck(); String upperbound = helper.upperBound(leftType.type, rightType.type); if (Objects.equals(upperbound, leftType.type)) { result.type = leftType.type; } setTypeCheckResult(result); return result; } }