]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix generic type handling when crawling inline body
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 25 Oct 2021 07:16:53 +0000 (14:16 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 27 Oct 2021 05:33:58 +0000 (05:33 +0000)
commitca5f65d771bc24b9717dca615fa4ad25dcd94fad
tree5fc7d619b7f174711a8e8e285ff1130dbdc9dac4
parent13eccaa9902f3bb17999f1f7f14b7da39d60e0ea
cmd/compile: fix generic type handling when crawling inline body

For base generic type that is written to export file, we need to mark
all of its methods, include exported+unexported methods, as reachable,
so they can be available for instantiation if necessary. But markType
only looks for exported methods, thus causing the crash in #49143.

To fix this, we introduce new method p.markGeneric, to mark all methods
of the base generic type.

This issue has happend for a while (maybe since we add generic
import/export during go1.18 cycle), and was un-intentionally "fixed" in
CL 356254, when we agresssively call p.markEmbed(t). CL 357232 fixed
that wrong agressive behavior, thus reproduce the bug on tip.

Fixes #49143

Change-Id: Ie64574a05fffb282e9dcc8739df4378c5b6b0468
Reviewed-on: https://go-review.googlesource.com/c/go/+/358814
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/typecheck/crawler.go
test/fixedbugs/issue49143.dir/a.go [new file with mode: 0644]
test/fixedbugs/issue49143.dir/b.go [new file with mode: 0644]
test/fixedbugs/issue49143.dir/c.go [new file with mode: 0644]
test/fixedbugs/issue49143.dir/p.go [new file with mode: 0644]
test/fixedbugs/issue49143.go [new file with mode: 0644]