Two used units exporting a class of the same name previously errored with
"Duplicate type name". Give types the same cross-unit semantics as consts
and vars: the units coexist, a bare reference binds to the unit later in
`uses` (last-in-uses wins), and a qualified `Unit.TName` reference binds to
that specific unit's own type — with distinct typeinfo, vtable, field
cleanup and method dispatch.
Semantic:
- DefineTypeLastWins detaches the prior unit's type on a cross-unit collision
(kept in the per-unit cache for qualified access) and installs the later
unit as the flat winner; same-unit redeclaration stays a hard error. The
duplicate-method and impl-body-link guards skip foreign-owned entries (with
a signature fallback so a generic instance whose template lives in another
unit still links). FindMethodDecl and a one-shot owner hint on
ResolveMethodOverload bind a call to the method on the type that actually
resolved, not the first-registered. FindTypeOrInstantiate resolves a
qualified type name through the directed per-unit lookup BEFORE the flat
FindType (which would strip the qualifier to the uses-chain winner).
- TTypeDesc gains OwningUnit (stamped on Define); the AST type decl gains
ResolvedDesc; a method-call expr gains QualifierUnit (set by the parser for
`Unit.Type.Create`), so a qualified constructor resolves against its unit.
Codegen (QBE and native): a type's storage symbols (typeinfo / vtable /
_FieldCleanup / __cn) are mangled by the unit currently being emitted, and
qualified reference sites mangle by the resolved descriptor's owner — so two
used units' same-named types emit and are referenced under distinct,
non-colliding symbols. Generic instances stay unprefixed.
Tests: e2e cross-unit type last-wins (+ reversed) and qualified
disambiguation; an IR-level check that the two types emit distinct symbols.