Fix loop with SUM and COUNT together.

When the default types are used, NUMBER and FIXNUM respectively, they
can conflict. Use a union of the types for the collection variable,
but only if all cases are using default types.

Fixes lp#798388.