1
0
mirror of https://github.com/golang/go synced 2024-11-25 07:07:57 -07:00

go/types, types2: follow-up on comment in CL 615195

Restate deferred call for readability.

Change-Id: I3725535b18fa4f1887e6c1976f8784e092b8f965
Reviewed-on: https://go-review.googlesource.com/c/go/+/615535
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
This commit is contained in:
Robert Griesemer 2024-09-24 10:57:49 -07:00 committed by Gopher Robot
parent 2f24fdde4e
commit 03fecda02b
4 changed files with 10 additions and 10 deletions

View File

@ -182,7 +182,8 @@ func testFilesImpl(t *testing.T, filenames []string, srcs [][]byte, colDelta uin
}
if goexperiment != "" {
defer setGOEXPERIMENT(goexperiment)()
revert := setGOEXPERIMENT(goexperiment)
defer revert()
}
// By default, gotypesalias is not set.
@ -329,9 +330,7 @@ func setGOEXPERIMENT(goexperiment string) func() {
}
old := buildcfg.Experiment
buildcfg.Experiment = *exp
return func() {
buildcfg.Experiment = old
}
return func() { buildcfg.Experiment = old }
}
// TestManual is for manual testing of a package - either provided

View File

@ -115,7 +115,8 @@ func TestObjectString(t *testing.T) {
for i, test := range testObjects {
t.Run(fmt.Sprint(i), func(t *testing.T) {
if test.alias {
defer setGOEXPERIMENT("aliastypeparams")()
revert := setGOEXPERIMENT("aliastypeparams")
defer revert()
}
src := "package p; " + test.src
conf := Config{Error: func(error) {}, Importer: defaultImporter(), EnableAlias: test.alias}

View File

@ -197,7 +197,8 @@ func testFilesImpl(t *testing.T, filenames []string, srcs [][]byte, manual bool,
}
if goexperiment != "" {
defer setGOEXPERIMENT(goexperiment)()
revert := setGOEXPERIMENT(goexperiment)
defer revert()
}
// By default, gotypesalias is not set.
@ -357,9 +358,7 @@ func setGOEXPERIMENT(goexperiment string) func() {
}
old := buildcfg.Experiment
buildcfg.Experiment = *exp
return func() {
buildcfg.Experiment = old
}
return func() { buildcfg.Experiment = old }
}
// TestManual is for manual testing of a package - either provided

View File

@ -115,7 +115,8 @@ func TestObjectString(t *testing.T) {
for i, test := range testObjects {
t.Run(fmt.Sprint(i), func(t *testing.T) {
if test.alias {
defer setGOEXPERIMENT("aliastypeparams")()
revert := setGOEXPERIMENT("aliastypeparams")
defer revert()
t.Setenv("GODEBUG", "gotypesalias=1")
}