public Object visit(AssignmentStatement node) {
            VariableRef lvalue = node.getLValue();
            String lname = lvalue.getName();
            if(mLoopVariables.contains(lname)) {
                error("foreach.loopvar.nomodify", lname, node.getSourceInfo());
                return null;
            }

            Expression rvalue = node.getRValue();
            check(rvalue);

            Type type = rvalue.getType();

            // Start mod for declarative typing
            if (type != null) {
                Class<?> rclass = type.getObjectClass();
                Variable dvar = mScope.getDeclaredVariable(lname);
                if (dvar == null)
                    dvar = lvalue.getVariable();
                if (dvar != null && dvar.isStaticallyTyped()) {
                    check(dvar.getTypeName());
                    if (dvar.getType() == null) // Added this line
                        dvar.setType(dvar.getTypeName().getType());
                    if (dvar.getType() == null)
                        return null;   // Bad type
                    Class<?> lclass = dvar.getType().getObjectClass();
                    if (lvalue.getVariable() == null)
                        lvalue.setVariable(dvar);
                    if (!type.isPrimitive())
                        type = dvar.getType();
                    if (rclass != null && lclass != null && rclass.isAssignableFrom(lclass) && rclass != lclass) {
                        type = dvar.getType();
                        if (rvalue instanceof NullLiteral && type.isPrimitive()) {
                            error("variable.primitive.uninitialized", type.getNaturalClass().getName(), node);
                            return null;
                        }
                        rvalue.convertTo(type.toNullable());
                    }
                    else if (rclass == lclass) {
                        // nothing to convert (already same type)
                    }
                    else if (lclass != null && rclass != null && lclass.isAssignableFrom(rclass)) {
                        rvalue.convertTo(dvar.getType().toNullable());
                    }
                    else if (rclass != lclass) {
                        error("assignmentstatement.cast.invalid", rclass.getName(), lclass.getName(), node);
                        return null;
                    }
                }
            }
           //End mod

            if (type != null) {
                if (mExceptionGuardian &&
                    rvalue.isExceptionPossible() &&
                    type.isNonNull()) {

                    // Since the expression may throw an exception and be
                    // guarded, an assignment of null needs to work.

                    rvalue.convertTo(type.toNullable());
                    type = rvalue.getType();
                }
                defineVariable(lvalue, type);
            }

            return null;
        }