]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix crawling of embeddable types during inline
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 18 Oct 2021 07:31:48 +0000 (14:31 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 20 Oct 2021 17:26:58 +0000 (17:26 +0000)
commit4e565f7372494c9c46e33a35e84f0fe4fc7d2774
tree46b02ebc7d8db7ee035b4920593a0da2fc4b5354
parent27a1454ee09b1923ddcf0cdc5e17b4dd7de8ea2a
cmd/compile: fix crawling of embeddable types during inline

In CL 327872, there's a fix for crawling of embeddable types directly
reached by the user, so all of its methods need to be re-exported. But
we missed the cased when an un-exported type may be reachable by
embedding in exported type. Example:

type t struct {}
func (t) M() {}

func F() interface{} { return struct{ t }{} }

We generate the wrapper for "struct{ t }".M, and when inlining call to
"struct{ t }".M makes "t.M" reachable.

It works well, and only be revealed in CL 327871, when we changed
methodWrapper to always call inline.InlineCalls, thus causes the crash
in #49016, which involve dot type in inlined function.

Fixes #49016

Change-Id: If174fa5575132da5cf60e4bd052f7011c4e76c5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/356254
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/typecheck/crawler.go
test/fixedbugs/issue49016.dir/a.go [new file with mode: 0644]
test/fixedbugs/issue49016.dir/b.go [new file with mode: 0644]
test/fixedbugs/issue49016.dir/c.go [new file with mode: 0644]
test/fixedbugs/issue49016.dir/d.go [new file with mode: 0644]
test/fixedbugs/issue49016.dir/e.go [new file with mode: 0644]
test/fixedbugs/issue49016.dir/f.go [new file with mode: 0644]
test/fixedbugs/issue49016.dir/g.go [new file with mode: 0644]
test/fixedbugs/issue49016.go [new file with mode: 0644]