]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] cmd/compile: fix crawling of embeddable types
authorMatthew Dempsky <mdempsky@google.com>
Tue, 15 Jun 2021 02:21:14 +0000 (19:21 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 16 Jun 2021 17:32:49 +0000 (17:32 +0000)
commit132ea56d292eac0226eef4bc32d784b0300c3bce
treeb3158a88a1ccfe5e1bed716e952e318b81294e9c
parent8f95eaddd334e61b1832628741b97462ddc84975
[dev.typeparams] cmd/compile: fix crawling of embeddable types

In reflectdata, we have a hack to only apply inlining for (*T).M
wrappers generated around T.M. This was a hack because I didn't
understand at the time why other cases were failing.

But I understand now: during export, we generally skip exporting the
inline bodies for unexported methods (unless they're reachable through
some other exported method). But it doesn't take into account that
embedding a type requires generating wrappers for promoted methods,
including imported, unexported methods.

For example:

package a
type T struct{}
func (T) m() {} // previously omitted by exported

package b
import "./a"
type U struct { a.T } // needs U.m -> T.m wrapper

This CL adds extra logic to the crawler to recognize that T is an
exported type directly reachable by the user, so *all* of its methods
need to be re-exported.

This finally allows simplifying reflectdata.methodWrapper to always
call inline.InlineCalls.

Change-Id: I25031d41fd6b6cd69d31c6a864b5329cdb5780e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/327872
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/reflectdata/reflect.go
src/cmd/compile/internal/typecheck/crawler.go