cmd/compile: use GOEXPERIMENT from environment for generic methods

The code guarding generic method experiment uses the setting from
internal/goexperiment, which is the one used when building the
compiler. The common practice of GOEXPERIMENT is that we use the
one from the environment at build time of the user code (not the
compiler), which is internal/buildcfg.Experiment. Change the code
to do so.

Also enable the tests.

Change-Id: I1ef4e35f82d54204648c1024a5371a95612a25b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/772680
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
This commit is contained in:
Cherry Mui 2026-04-30 16:34:50 -04:00
parent 5732f4b76a
commit 87fe5fafba
4 changed files with 5 additions and 8 deletions

View file

@ -7,7 +7,7 @@ package noder
import (
"cmp"
"fmt"
"internal/goexperiment"
"internal/buildcfg"
"internal/pkgbits"
"internal/types/errors"
"io"
@ -28,7 +28,7 @@ import (
// uirVersion is the unified IR version to use for encoding/decoding.
// Use V4 for generic methods if the GOEXPERIMENT is enabled.
var uirVersion = func() pkgbits.Version {
if goexperiment.GenericMethods {
if buildcfg.Experiment.GenericMethods {
return pkgbits.V4
}
return pkgbits.V3

View file

@ -1,5 +1,4 @@
// run
//go:build goexperiment.genericmethods
// run -goexperiment genericmethods
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View file

@ -1,5 +1,4 @@
// run
//go:build goexperiment.genericmethods
// run -goexperiment genericmethods
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View file

@ -1,5 +1,4 @@
// run
//go:build goexperiment.genericmethods
// run -goexperiment genericmethods
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style