Infer return type for permutedims

This is the same kind of issue as #4387, but in this case we should be able to statically infer the return type of the array (at least as long as we don't care to make `permutedims([1, 2], [2, 1])` work, but this currently throws anyhow).

Unfortunately this revealed a bug in type inference, which statically infers `typeof(dimsB)` for BitArrays and SubArrays as of type

```julia
(Type{TypeVar(:_,Vararg{Int})},)
```

which leads to the wrong `similar` method getting selected and inlined. I changed inference.jl to infer this as `(Vararg{Type{Int}},)` which works, but Vararg types give me the creeps and I'm not sure this is a complete solution.