Retain type information when unifying branches