mirror of
https://github.com/golang/go.git
synced 2026-06-28 03:40:37 +00:00
cmd/compile/internal/noder: hoist up generic methods assertion
We should assert the byte stream version for generic methods at the type directly. Otherwise, if we use generic methods without setting the UIR version to V4, they are silently dropped. Using generic methods while not at V4 is only possible using a Go 1.27 compiler without setting GOEXPERIMENT=genericmethods; the type checker itself blocks use of generic methods below Go 1.27. Thus, this is a bit more correct for users of the experiment, but otherwise has no impact. For #77273 Change-Id: I077fb74e28093878410c35d6838bd8fdbeabf9fa Reviewed-on: https://go-review.googlesource.com/c/go/+/773824 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mark Freeman <markfreeman@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
f6664a0a60
commit
4e4b780652
1 changed files with 3 additions and 2 deletions
|
|
@ -863,8 +863,6 @@ func (w *writer) doObj(wext *writer, obj types2.Object) pkgbits.CodeObj {
|
|||
|
||||
w.pos(obj)
|
||||
if isGenericMethod(sig) {
|
||||
// otherwise the reader won't know to expect the flag
|
||||
assert(w.Version().Has(pkgbits.GenericMethods))
|
||||
w.Bool(true) // generic method
|
||||
|
||||
w.selector(obj)
|
||||
|
|
@ -922,6 +920,9 @@ func (w *writer) doObj(wext *writer, obj types2.Object) pkgbits.CodeObj {
|
|||
for _, m := range methods {
|
||||
w.method(wext, m)
|
||||
}
|
||||
if len(gmethods) > 0 {
|
||||
assert(w.Version().Has(pkgbits.GenericMethods))
|
||||
}
|
||||
// encode a pointer to each generic method
|
||||
if w.Version().Has(pkgbits.GenericMethods) {
|
||||
w.Len(len(gmethods))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue