compiler: finalize methods when importing types

This patch changes the compiler to be more aggressive about finalizing
methods on imported types, to avoid problems with interface types that
are imported but remain unreachable until a later stage in the compilation.

The normal pattern prior to this change was that the import process would
leave imported interface types alone, and rely on Gogo::finalize_methods
to locate and finalize all interface types at a later point. This way
of doing things was not working in all cases due to the fact that we can
import an interface type that is only reachable from the body of an
inlinable function, meaning that we can't "find" the type during
the methods finalize phase.

The importer's Import::read_types() now makes a pass over all imported
types to finalize methods on any newly imported type, which takes care
of the issue.

New test case for this problem in CL 185517.

Fixes golang/go#33013

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