compiler: rework type and package tracking in exporter

Revamps the way the exporter tracks exported types and imported
packages that need to be mentioned in the export data.

The previous implementation wasn't properly handling the case where an
exported non-inlinable function refers to an imported type whose
method set includes an inlinable function whose body makes a call to a
function in another package that's not directly used in the original

This patch integrates together two existing traversal helper classes,
"Collect_references_from_inline" and "Find_types_to_prepare" into a
single helper "Collect_export_references", so as to have common/shared
code that looks for indirectly imported packages.

Fixes golang/go#32778

Change-Id: Ice4bf2f7aac5bcf9b9cc2f29d72597b08714eef7
Reviewed-by: Ian Lance Taylor <>
4 files changed