implement assignability rules for underlying types

This revealed an out-of-bounds read, fix that too.

Remove RootType again, as an underlying type always points to the root
type. (I mistakenly thought it would point just one level up.)
copy over clang's TypePrinter.cpp