In type-check, we have code that tries to recognize when a bare identifier was rewritten due to a dot-imported package, but it fails when the same symbol is dot-imported as two different in packages in separate compilation units.
This CL substantially reworks how imported declarations are handled,
and fixes a number of issues with dot imports. In particular:
1. It eliminates the stub ir.Name declarations that are created
upfront during import-declaration processing, allowing this to be
deferred to when the declarations are actually needed. (Eventually,
this can be deferred even further so we never have to create ir.Names
w/ ONONAME, but this CL is already invasive/subtle enough.)
2. During noding, we now use ir.Idents to represent uses of imported
declarations, including of dot-imported declarations.
3. Unused dot imports are now reported after type checking, so that we
can correctly distinguish whether composite literal keys are a simple
identifier (struct literals) or expressions (array/slice/map literals)
and whether it might be a use of a dot-imported declaration.
4. It changes the "redeclared" error messages to report the previous
position information in the same style as other compiler error
messages that reference other source lines.
Passes buildall w/ toolstash -cmp.
Run-TryBot: Matthew Dempsky <firstname.lastname@example.org>
TryBot-Result: Go Bot <email@example.com>
Reviewed-by: Russ Cox <firstname.lastname@example.org>
Trust: Matthew Dempsky <email@example.com>