internal/typeparams: delete const Enabled=true and simplify
Change-Id: I8e95226d03d94027aee803a0431320bc7ee83600
Reviewed-on: https://go-review.googlesource.com/c/tools/+/549235
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/cmd/stringer/endtoend_test.go b/cmd/stringer/endtoend_test.go
index d513c1b..e68b612 100644
--- a/cmd/stringer/endtoend_test.go
+++ b/cmd/stringer/endtoend_test.go
@@ -23,7 +23,6 @@
"testing"
"golang.org/x/tools/internal/testenv"
- "golang.org/x/tools/internal/typeparams"
)
// This file contains a test that compiles and runs each program in testdata
@@ -62,9 +61,6 @@
if err != nil {
t.Fatalf("Readdirnames: %s", err)
}
- if typeparams.Enabled {
- names = append(names, moreTests(t, "testdata/typeparams", "typeparams")...)
- }
// Generate, compile, and run the test programs.
for _, name := range names {
if name == "typeparams" {
diff --git a/cmd/stringer/testdata/typeparams/conv2.go b/cmd/stringer/testdata/conv2.go
similarity index 100%
rename from cmd/stringer/testdata/typeparams/conv2.go
rename to cmd/stringer/testdata/conv2.go
diff --git a/cmd/stringer/testdata/typeparams/prime2.go b/cmd/stringer/testdata/prime2.go
similarity index 100%
rename from cmd/stringer/testdata/typeparams/prime2.go
rename to cmd/stringer/testdata/prime2.go
diff --git a/go/analysis/passes/assign/assign_test.go b/go/analysis/passes/assign/assign_test.go
index 146385f..5ca6128 100644
--- a/go/analysis/passes/assign/assign_test.go
+++ b/go/analysis/passes/assign/assign_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/assign"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.RunWithSuggestedFixes(t, testdata, assign.Analyzer, tests...)
+ analysistest.RunWithSuggestedFixes(t, testdata, assign.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/atomic/atomic_test.go b/go/analysis/passes/atomic/atomic_test.go
index c17064c..755f5de 100644
--- a/go/analysis/passes/atomic/atomic_test.go
+++ b/go/analysis/passes/atomic/atomic_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/atomic"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, atomic.Analyzer, tests...)
+ analysistest.Run(t, testdata, atomic.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/bools/bools_test.go b/go/analysis/passes/bools/bools_test.go
index ea51437..0297dea 100644
--- a/go/analysis/passes/bools/bools_test.go
+++ b/go/analysis/passes/bools/bools_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/bools"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, bools.Analyzer, tests...)
+ analysistest.Run(t, testdata, bools.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/buildssa/buildssa_test.go b/go/analysis/passes/buildssa/buildssa_test.go
index c61a9f0..cc895bb 100644
--- a/go/analysis/passes/buildssa/buildssa_test.go
+++ b/go/analysis/passes/buildssa/buildssa_test.go
@@ -11,7 +11,6 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/buildssa"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
@@ -30,9 +29,6 @@
}
func TestGenericDecls(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("TestGenericDecls requires type parameters.")
- }
testdata := analysistest.TestData()
result := analysistest.Run(t, testdata, buildssa.Analyzer, "b")[0].Result
@@ -48,9 +44,6 @@
}
func TestImporting(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("TestImporting depends on testdata/b/b/go which uses type parameters.")
- }
testdata := analysistest.TestData()
result := analysistest.Run(t, testdata, buildssa.Analyzer, "c")[0].Result
diff --git a/go/analysis/passes/cgocall/cgocall_test.go b/go/analysis/passes/cgocall/cgocall_test.go
index 45ca1da..59d2649 100644
--- a/go/analysis/passes/cgocall/cgocall_test.go
+++ b/go/analysis/passes/cgocall/cgocall_test.go
@@ -9,15 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/cgocall"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a", "b", "c"}
- if typeparams.Enabled {
- // and testdata/src/typeparams/typeparams.go when possible
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, cgocall.Analyzer, tests...)
+ analysistest.Run(t, testdata, cgocall.Analyzer, "a", "b", "c", "typeparams")
}
diff --git a/go/analysis/passes/composite/composite_test.go b/go/analysis/passes/composite/composite_test.go
index 7afaaa7..5764cf5 100644
--- a/go/analysis/passes/composite/composite_test.go
+++ b/go/analysis/passes/composite/composite_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/composite"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- pkgs := []string{"a"}
- if typeparams.Enabled {
- pkgs = append(pkgs, "typeparams")
- }
- analysistest.RunWithSuggestedFixes(t, testdata, composite.Analyzer, pkgs...)
+ analysistest.RunWithSuggestedFixes(t, testdata, composite.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/copylock/copylock_test.go b/go/analysis/passes/copylock/copylock_test.go
index 869955b..5726806 100644
--- a/go/analysis/passes/copylock/copylock_test.go
+++ b/go/analysis/passes/copylock/copylock_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/copylock"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- pkgs := []string{"a"}
- if typeparams.Enabled {
- pkgs = append(pkgs, "typeparams")
- }
- analysistest.Run(t, testdata, copylock.Analyzer, pkgs...)
+ analysistest.Run(t, testdata, copylock.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/ctrlflow/ctrlflow_test.go b/go/analysis/passes/ctrlflow/ctrlflow_test.go
index 1503c33..5afd01c 100644
--- a/go/analysis/passes/ctrlflow/ctrlflow_test.go
+++ b/go/analysis/passes/ctrlflow/ctrlflow_test.go
@@ -10,19 +10,11 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/ctrlflow"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
-
- // load testdata/src/a/a.go
- tests := []string{"a"}
- if typeparams.Enabled {
- // and testdata/src/typeparams/typeparams.go when possible
- tests = append(tests, "typeparams")
- }
- results := analysistest.Run(t, testdata, ctrlflow.Analyzer, tests...)
+ results := analysistest.Run(t, testdata, ctrlflow.Analyzer, "a", "typeparams")
// Perform a minimal smoke test on
// the result (CFG) computed by ctrlflow.
diff --git a/go/analysis/passes/deepequalerrors/deepequalerrors_test.go b/go/analysis/passes/deepequalerrors/deepequalerrors_test.go
index 0094173..0f21cd8 100644
--- a/go/analysis/passes/deepequalerrors/deepequalerrors_test.go
+++ b/go/analysis/passes/deepequalerrors/deepequalerrors_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/deepequalerrors"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, deepequalerrors.Analyzer, tests...)
+ analysistest.Run(t, testdata, deepequalerrors.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/errorsas/errorsas_test.go b/go/analysis/passes/errorsas/errorsas_test.go
index 7908e89..6689d81 100644
--- a/go/analysis/passes/errorsas/errorsas_test.go
+++ b/go/analysis/passes/errorsas/errorsas_test.go
@@ -12,14 +12,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/errorsas"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, errorsas.Analyzer, tests...)
+ analysistest.Run(t, testdata, errorsas.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/httpresponse/httpresponse_test.go b/go/analysis/passes/httpresponse/httpresponse_test.go
index 34dc78c..e5fe225 100644
--- a/go/analysis/passes/httpresponse/httpresponse_test.go
+++ b/go/analysis/passes/httpresponse/httpresponse_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/httpresponse"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, httpresponse.Analyzer, tests...)
+ analysistest.Run(t, testdata, httpresponse.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/ifaceassert/ifaceassert_test.go b/go/analysis/passes/ifaceassert/ifaceassert_test.go
index b07c276..266e2ed 100644
--- a/go/analysis/passes/ifaceassert/ifaceassert_test.go
+++ b/go/analysis/passes/ifaceassert/ifaceassert_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/ifaceassert"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- pkgs := []string{"a"}
- if typeparams.Enabled {
- pkgs = append(pkgs, "typeparams")
- }
- analysistest.Run(t, testdata, ifaceassert.Analyzer, pkgs...)
+ analysistest.Run(t, testdata, ifaceassert.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/internal/analysisutil/util_test.go b/go/analysis/passes/internal/analysisutil/util_test.go
index 2d7e94e..9f49252 100644
--- a/go/analysis/passes/internal/analysisutil/util_test.go
+++ b/go/analysis/passes/internal/analysisutil/util_test.go
@@ -12,13 +12,9 @@
"testing"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
- "golang.org/x/tools/internal/typeparams"
)
func TestHasSideEffects(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type parameters are not enabled")
- }
src := `package p
type T int
diff --git a/go/analysis/passes/loopclosure/loopclosure_test.go b/go/analysis/passes/loopclosure/loopclosure_test.go
index 896247c..386f532 100644
--- a/go/analysis/passes/loopclosure/loopclosure_test.go
+++ b/go/analysis/passes/loopclosure/loopclosure_test.go
@@ -13,17 +13,13 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/loopclosure"
"golang.org/x/tools/internal/testenv"
- "golang.org/x/tools/internal/typeparams"
"golang.org/x/tools/txtar"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a", "golang.org/...", "subtests"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, loopclosure.Analyzer, tests...)
+ analysistest.Run(t, testdata, loopclosure.Analyzer,
+ "a", "golang.org/...", "subtests", "typeparams")
}
func TestVersions22(t *testing.T) {
diff --git a/go/analysis/passes/lostcancel/lostcancel_test.go b/go/analysis/passes/lostcancel/lostcancel_test.go
index bda0293..89e9d25 100644
--- a/go/analysis/passes/lostcancel/lostcancel_test.go
+++ b/go/analysis/passes/lostcancel/lostcancel_test.go
@@ -5,17 +5,13 @@
package lostcancel_test
import (
+ "testing"
+
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/lostcancel"
- "golang.org/x/tools/internal/typeparams"
- "testing"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a", "b"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, lostcancel.Analyzer, tests...)
+ analysistest.Run(t, testdata, lostcancel.Analyzer, "a", "b", "typeparams")
}
diff --git a/go/analysis/passes/nilfunc/nilfunc_test.go b/go/analysis/passes/nilfunc/nilfunc_test.go
index e147a44..e6e7e5c 100644
--- a/go/analysis/passes/nilfunc/nilfunc_test.go
+++ b/go/analysis/passes/nilfunc/nilfunc_test.go
@@ -5,17 +5,13 @@
package nilfunc_test
import (
+ "testing"
+
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/nilfunc"
- "golang.org/x/tools/internal/typeparams"
- "testing"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, nilfunc.Analyzer, tests...)
+ analysistest.Run(t, testdata, nilfunc.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/nilness/nilness_test.go b/go/analysis/passes/nilness/nilness_test.go
index 99c4dfb..d07a930 100644
--- a/go/analysis/passes/nilness/nilness_test.go
+++ b/go/analysis/passes/nilness/nilness_test.go
@@ -9,7 +9,6 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/nilness"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
@@ -18,17 +17,11 @@
}
func TestInstantiated(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("TestInstantiated requires type parameters")
- }
testdata := analysistest.TestData()
analysistest.Run(t, testdata, nilness.Analyzer, "c")
}
func TestTypeSet(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("TestTypeSet requires type parameters")
- }
testdata := analysistest.TestData()
analysistest.Run(t, testdata, nilness.Analyzer, "d")
}
diff --git a/go/analysis/passes/printf/printf_test.go b/go/analysis/passes/printf/printf_test.go
index ed857fe..e206a3f 100644
--- a/go/analysis/passes/printf/printf_test.go
+++ b/go/analysis/passes/printf/printf_test.go
@@ -10,7 +10,6 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/printf"
"golang.org/x/tools/internal/testenv"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
@@ -19,9 +18,5 @@
testdata := analysistest.TestData()
printf.Analyzer.Flags.Set("funcs", "Warn,Warnf")
- tests := []string{"a", "b", "nofmt"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, printf.Analyzer, tests...)
+ analysistest.Run(t, testdata, printf.Analyzer, "a", "b", "nofmt", "typeparams")
}
diff --git a/go/analysis/passes/shift/shift_test.go b/go/analysis/passes/shift/shift_test.go
index e60943e..cdce0cf 100644
--- a/go/analysis/passes/shift/shift_test.go
+++ b/go/analysis/passes/shift/shift_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/shift"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- pkgs := []string{"a"}
- if typeparams.Enabled {
- pkgs = append(pkgs, "typeparams")
- }
- analysistest.Run(t, testdata, shift.Analyzer, pkgs...)
+ analysistest.Run(t, testdata, shift.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/stdmethods/stdmethods_test.go b/go/analysis/passes/stdmethods/stdmethods_test.go
index 9bfa032..9df50fe 100644
--- a/go/analysis/passes/stdmethods/stdmethods_test.go
+++ b/go/analysis/passes/stdmethods/stdmethods_test.go
@@ -9,16 +9,11 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/stdmethods"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- pkgs := []string{"a"}
- if typeparams.Enabled {
- pkgs = append(pkgs, "typeparams")
- }
- analysistest.Run(t, testdata, stdmethods.Analyzer, pkgs...)
+ analysistest.Run(t, testdata, stdmethods.Analyzer, "a", "typeparams")
}
func TestAnalyzeEncodingXML(t *testing.T) {
diff --git a/go/analysis/passes/stringintconv/string_test.go b/go/analysis/passes/stringintconv/string_test.go
index 13f2133..0b1f99b 100644
--- a/go/analysis/passes/stringintconv/string_test.go
+++ b/go/analysis/passes/stringintconv/string_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/stringintconv"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- pkgs := []string{"a"}
- if typeparams.Enabled {
- pkgs = append(pkgs, "typeparams")
- }
- analysistest.RunWithSuggestedFixes(t, testdata, stringintconv.Analyzer, pkgs...)
+ analysistest.RunWithSuggestedFixes(t, testdata, stringintconv.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/tests/tests_test.go b/go/analysis/passes/tests/tests_test.go
index 740adc5..7454234 100644
--- a/go/analysis/passes/tests/tests_test.go
+++ b/go/analysis/passes/tests/tests_test.go
@@ -9,18 +9,14 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/tests"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- pkgs := []string{
+ analysistest.Run(t, testdata, tests.Analyzer,
"a", // loads "a", "a [a.test]", and "a.test"
"b_x_test", // loads "b" and "b_x_test"
"divergent",
- }
- if typeparams.Enabled {
- pkgs = append(pkgs, "typeparams")
- }
- analysistest.Run(t, testdata, tests.Analyzer, pkgs...)
+ "typeparams",
+ )
}
diff --git a/go/analysis/passes/unmarshal/unmarshal_test.go b/go/analysis/passes/unmarshal/unmarshal_test.go
index e6171f2..1659d8d 100644
--- a/go/analysis/passes/unmarshal/unmarshal_test.go
+++ b/go/analysis/passes/unmarshal/unmarshal_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/unmarshal"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, unmarshal.Analyzer, tests...)
+ analysistest.Run(t, testdata, unmarshal.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/unsafeptr/unsafeptr_test.go b/go/analysis/passes/unsafeptr/unsafeptr_test.go
index 424de1f..b926f04 100644
--- a/go/analysis/passes/unsafeptr/unsafeptr_test.go
+++ b/go/analysis/passes/unsafeptr/unsafeptr_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/unsafeptr"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- pkgs := []string{"a"}
- if typeparams.Enabled {
- pkgs = append(pkgs, "typeparams")
- }
- analysistest.Run(t, testdata, unsafeptr.Analyzer, pkgs...)
+ analysistest.Run(t, testdata, unsafeptr.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/unusedresult/unusedresult_test.go b/go/analysis/passes/unusedresult/unusedresult_test.go
index a2b079a..08dcf61 100644
--- a/go/analysis/passes/unusedresult/unusedresult_test.go
+++ b/go/analysis/passes/unusedresult/unusedresult_test.go
@@ -9,16 +9,11 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/unusedresult"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
funcs := "typeparams/userdefs.MustUse,errors.New,fmt.Errorf,fmt.Sprintf,fmt.Sprint"
unusedresult.Analyzer.Flags.Set("funcs", funcs)
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, unusedresult.Analyzer, tests...)
+ analysistest.Run(t, testdata, unusedresult.Analyzer, "a", "typeparams")
}
diff --git a/go/analysis/passes/usesgenerics/usesgenerics_test.go b/go/analysis/passes/usesgenerics/usesgenerics_test.go
index 3dcff24..d5fb73e 100644
--- a/go/analysis/passes/usesgenerics/usesgenerics_test.go
+++ b/go/analysis/passes/usesgenerics/usesgenerics_test.go
@@ -9,13 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/usesgenerics"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type parameters are not enabled at this Go version")
- }
testdata := analysistest.TestData()
analysistest.Run(t, testdata, usesgenerics.Analyzer, "a", "b", "c", "d")
}
diff --git a/go/ast/astutil/enclosing_test.go b/go/ast/astutil/enclosing_test.go
index de96d44..1f9d06c 100644
--- a/go/ast/astutil/enclosing_test.go
+++ b/go/ast/astutil/enclosing_test.go
@@ -19,7 +19,6 @@
"testing"
"golang.org/x/tools/go/ast/astutil"
- "golang.org/x/tools/internal/typeparams"
)
// pathToString returns a string containing the concrete types of the
@@ -59,10 +58,7 @@
}
// Common input for following tests.
-var input = makeInput()
-
-func makeInput() string {
- src := `
+const input = `
// Hello.
package main
import "fmt"
@@ -71,10 +67,7 @@
z := (x + y) // add them
f() // NB: ExprStmt and its CallExpr have same Pos/End
}
-`
- if typeparams.Enabled {
- src += `
func g[A any, P interface{ctype1| ~ctype2}](a1 A, p1 P) {}
type PT[T constraint] struct{ t T }
@@ -83,9 +76,6 @@
var h = g[ targ2, targ3]
`
- }
- return src
-}
func TestPathEnclosingInterval_Exact(t *testing.T) {
type testCase struct {
@@ -129,31 +119,27 @@
"func f() {}"},
{" f",
"f"},
- }
- if typeparams.Enabled {
- tests = append(tests, []testCase{
- dup("[A any, P interface{ctype1| ~ctype2}]"),
- {"[", "[A any, P interface{ctype1| ~ctype2}]"},
- dup("A"),
- {" any", "any"},
- dup("ctype1"),
- {"|", "ctype1| ~ctype2"},
- dup("ctype2"),
- {"~", "~ctype2"},
- dup("~ctype2"),
- {" ~ctype2", "~ctype2"},
- {"]", "[A any, P interface{ctype1| ~ctype2}]"},
- dup("a1"),
- dup("a1 A"),
- dup("(a1 A, p1 P)"),
- dup("type PT[T constraint] struct{ t T }"),
- dup("PT"),
- dup("[T constraint]"),
- dup("constraint"),
- dup("targ1"),
- {" targ2", "targ2"},
- dup("g[ targ2, targ3]"),
- }...)
+ dup("[A any, P interface{ctype1| ~ctype2}]"),
+ {"[", "[A any, P interface{ctype1| ~ctype2}]"},
+ dup("A"),
+ {" any", "any"},
+ dup("ctype1"),
+ {"|", "ctype1| ~ctype2"},
+ dup("ctype2"),
+ {"~", "~ctype2"},
+ dup("~ctype2"),
+ {" ~ctype2", "~ctype2"},
+ {"]", "[A any, P interface{ctype1| ~ctype2}]"},
+ dup("a1"),
+ dup("a1 A"),
+ dup("(a1 A, p1 P)"),
+ dup("type PT[T constraint] struct{ t T }"),
+ dup("PT"),
+ dup("[T constraint]"),
+ dup("constraint"),
+ dup("targ1"),
+ {" targ2", "targ2"},
+ dup("g[ targ2, targ3]"),
}
for _, test := range tests {
f, start, end := findInterval(t, new(token.FileSet), input, test.substr)
@@ -218,18 +204,14 @@
"[Ident File],true"},
{"f() // NB",
"[CallExpr ExprStmt BlockStmt FuncDecl File],true"},
- }
- if typeparams.Enabled {
- tests = append(tests, []testCase{
- {" any", "[Ident Field FieldList FuncDecl File],true"},
- {"|", "[BinaryExpr Field FieldList InterfaceType Field FieldList FuncDecl File],true"},
- {"ctype2",
- "[Ident UnaryExpr BinaryExpr Field FieldList InterfaceType Field FieldList FuncDecl File],true"},
- {"a1", "[Ident Field FieldList FuncDecl File],true"},
- {"PT[T constraint]", "[TypeSpec GenDecl File],false"},
- {"[T constraint]", "[FieldList TypeSpec GenDecl File],true"},
- {"targ2", "[Ident IndexListExpr ValueSpec GenDecl File],true"},
- }...)
+ {" any", "[Ident Field FieldList FuncDecl File],true"},
+ {"|", "[BinaryExpr Field FieldList InterfaceType Field FieldList FuncDecl File],true"},
+ {"ctype2",
+ "[Ident UnaryExpr BinaryExpr Field FieldList InterfaceType Field FieldList FuncDecl File],true"},
+ {"a1", "[Ident Field FieldList FuncDecl File],true"},
+ {"PT[T constraint]", "[TypeSpec GenDecl File],false"},
+ {"[T constraint]", "[FieldList TypeSpec GenDecl File],true"},
+ {"targ2", "[Ident IndexListExpr ValueSpec GenDecl File],true"},
}
for _, test := range tests {
f, start, end := findInterval(t, new(token.FileSet), input, test.substr)
diff --git a/go/ast/astutil/rewrite_test.go b/go/ast/astutil/rewrite_test.go
index 4ef6fe9..57136a0 100644
--- a/go/ast/astutil/rewrite_test.go
+++ b/go/ast/astutil/rewrite_test.go
@@ -13,7 +13,6 @@
"testing"
"golang.org/x/tools/go/ast/astutil"
- "golang.org/x/tools/internal/typeparams"
)
type rewriteTest struct {
@@ -191,13 +190,9 @@
return true
},
},
-}
-
-func init() {
- if typeparams.Enabled {
- rewriteTests = append(rewriteTests, rewriteTest{
- name: "replace",
- orig: `package p
+ {
+ name: "replace",
+ orig: `package p
type T[P1, P2 any] int
@@ -205,9 +200,9 @@
func F[Q1 any](q Q1) {}
`,
- // TODO: note how the rewrite adds a trailing comma in "func F".
- // Is that a bug in the test, or in astutil.Apply?
- want: `package p
+ // TODO: note how the rewrite adds a trailing comma in "func F".
+ // Is that a bug in the test, or in astutil.Apply?
+ want: `package p
type S[R1, P2 any] int32
@@ -215,23 +210,22 @@
func F[X1 any](q X1,) {}
`,
- post: func(c *astutil.Cursor) bool {
- if ident, ok := c.Node().(*ast.Ident); ok {
- switch ident.Name {
- case "int":
- c.Replace(ast.NewIdent("int32"))
- case "T":
- c.Replace(ast.NewIdent("S"))
- case "P1":
- c.Replace(ast.NewIdent("R1"))
- case "Q1":
- c.Replace(ast.NewIdent("X1"))
- }
+ post: func(c *astutil.Cursor) bool {
+ if ident, ok := c.Node().(*ast.Ident); ok {
+ switch ident.Name {
+ case "int":
+ c.Replace(ast.NewIdent("int32"))
+ case "T":
+ c.Replace(ast.NewIdent("S"))
+ case "P1":
+ c.Replace(ast.NewIdent("R1"))
+ case "Q1":
+ c.Replace(ast.NewIdent("X1"))
}
- return true
- },
- })
- }
+ }
+ return true
+ },
+ },
}
func valspec(name, typ string) *ast.ValueSpec {
diff --git a/go/ast/inspector/inspector_test.go b/go/ast/inspector/inspector_test.go
index e88d584..4b26ff6 100644
--- a/go/ast/inspector/inspector_test.go
+++ b/go/ast/inspector/inspector_test.go
@@ -72,10 +72,6 @@
}
func TestInspectGenericNodes(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type parameters are not supported at this Go version")
- }
-
// src is using the 16 identifiers i0, i1, ... i15 so
// we can easily verify that we've found all of them.
const src = `package a
diff --git a/go/callgraph/cha/cha_test.go b/go/callgraph/cha/cha_test.go
index 0737a98..f99357b 100644
--- a/go/callgraph/cha/cha_test.go
+++ b/go/callgraph/cha/cha_test.go
@@ -26,7 +26,6 @@
"golang.org/x/tools/go/loader"
"golang.org/x/tools/go/ssa"
"golang.org/x/tools/go/ssa/ssautil"
- "golang.org/x/tools/internal/typeparams"
)
var inputs = []string{
@@ -74,10 +73,6 @@
// TestCHAGenerics is TestCHA tailored for testing generics,
func TestCHAGenerics(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("TestCHAGenerics requires type parameters")
- }
-
filename := "testdata/generics.go"
prog, f, mainPkg, err := loadProgInfo(filename, ssa.InstantiateGenerics)
if err != nil {
diff --git a/go/callgraph/rta/rta_test.go b/go/callgraph/rta/rta_test.go
index d96483b..a855dd6 100644
--- a/go/callgraph/rta/rta_test.go
+++ b/go/callgraph/rta/rta_test.go
@@ -23,7 +23,6 @@
"golang.org/x/tools/go/loader"
"golang.org/x/tools/go/ssa"
"golang.org/x/tools/go/ssa/ssautil"
- "golang.org/x/tools/internal/typeparams"
)
// TestRTA runs RTA on each testdata/*.go file and compares the
@@ -38,10 +37,6 @@
}
for _, filename := range filenames {
t.Run(filename, func(t *testing.T) {
- if !typeparams.Enabled && strings.HasSuffix(filename, "generics.go") {
- t.Skip("TestRTAGenerics requires type parameters")
- }
-
// Load main program and build SSA.
// TODO(adonovan): use go/packages instead.
conf := loader.Config{ParserMode: parser.ParseComments}
diff --git a/go/callgraph/static/static_test.go b/go/callgraph/static/static_test.go
index 0a108d3..4b61dbf 100644
--- a/go/callgraph/static/static_test.go
+++ b/go/callgraph/static/static_test.go
@@ -16,7 +16,6 @@
"golang.org/x/tools/go/loader"
"golang.org/x/tools/go/ssa"
"golang.org/x/tools/go/ssa/ssautil"
- "golang.org/x/tools/internal/typeparams"
)
const input = `package P
@@ -99,12 +98,6 @@
"instantiated[P.B] -> (B).F",
}, true},
} {
- if e.typeparams && !typeparams.Enabled {
- // Skip tests with type parameters when the build
- // environment is not supporting any.
- continue
- }
-
conf := loader.Config{ParserMode: parser.ParseComments}
f, err := conf.ParseFile("P.go", e.input)
if err != nil {
diff --git a/go/callgraph/vta/vta_test.go b/go/callgraph/vta/vta_test.go
index 69f2181..2c6538c 100644
--- a/go/callgraph/vta/vta_test.go
+++ b/go/callgraph/vta/vta_test.go
@@ -13,7 +13,6 @@
"golang.org/x/tools/go/callgraph/cha"
"golang.org/x/tools/go/ssa"
"golang.org/x/tools/go/ssa/ssautil"
- "golang.org/x/tools/internal/typeparams"
)
func TestVTACallGraph(t *testing.T) {
@@ -119,10 +118,6 @@
}
func TestVTACallGraphGenerics(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("TestVTACallGraphGenerics requires type parameters")
- }
-
// TODO(zpavlinovic): add more tests
files := []string{
"testdata/src/arrays_generics.go",
diff --git a/go/ssa/interp/interp_test.go b/go/ssa/interp/interp_test.go
index d217ded..6f8e21a 100644
--- a/go/ssa/interp/interp_test.go
+++ b/go/ssa/interp/interp_test.go
@@ -38,7 +38,6 @@
"golang.org/x/tools/go/ssa/interp"
"golang.org/x/tools/go/ssa/ssautil"
"golang.org/x/tools/internal/testenv"
- "golang.org/x/tools/internal/typeparams"
)
// Each line contains a space-separated list of $GOROOT/test/
@@ -135,19 +134,15 @@
"static.go",
"width32.go",
"rangevarlifetime_old.go",
-
"fixedbugs/issue52342.go",
"fixedbugs/issue55115.go",
+ "fixedbugs/issue52835.go",
+ "fixedbugs/issue55086.go",
+ "typeassert.go",
+ "zeros.go",
}
func init() {
- if typeparams.Enabled {
- testdataTests = append(testdataTests, "fixedbugs/issue52835.go")
- testdataTests = append(testdataTests, "fixedbugs/issue55086.go")
- testdataTests = append(testdataTests, "typeassert.go")
- testdataTests = append(testdataTests, "zeros.go")
- }
-
// GOROOT/test used to assume that GOOS and GOARCH were explicitly set in the
// environment, so do that here for TestGorootTest.
os.Setenv("GOOS", runtime.GOOS)
@@ -315,9 +310,6 @@
// in $GOROOT/test/typeparam/*.go.
func TestTypeparamTest(t *testing.T) {
- if !typeparams.Enabled {
- return
- }
goroot := makeGoroot(t)
// Skip known failures for the given reason.
diff --git a/go/types/typeutil/callee_test.go b/go/types/typeutil/callee_test.go
index ed59071..3ce6879 100644
--- a/go/types/typeutil/callee_test.go
+++ b/go/types/typeutil/callee_test.go
@@ -68,9 +68,6 @@
}
func TestTypeParamStaticCallee(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type parameters are not enabled")
- }
testStaticCallee(t, []string{
`package q
func R[T any]() {}
diff --git a/go/types/typeutil/map_test.go b/go/types/typeutil/map_test.go
index ee73ff9..4197b69 100644
--- a/go/types/typeutil/map_test.go
+++ b/go/types/typeutil/map_test.go
@@ -178,10 +178,6 @@
}
func TestMapGenerics(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type params are not enabled at this Go version")
- }
-
const src = `
package p
diff --git a/godoc/godoc_test.go b/godoc/godoc_test.go
index 7f3470e..5e54db5 100644
--- a/godoc/godoc_test.go
+++ b/godoc/godoc_test.go
@@ -10,8 +10,6 @@
"go/token"
"strings"
"testing"
-
- "golang.org/x/tools/internal/typeparams"
)
func TestPkgLinkFunc(t *testing.T) {
@@ -372,10 +370,6 @@
}
func TestLinkifyGenerics(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type params are not enabled at this Go version")
- }
-
got := linkifySource(t, []byte(`
package foo
diff --git a/godoc/server_test.go b/godoc/server_test.go
index d6cc923..7fa02c5 100644
--- a/godoc/server_test.go
+++ b/godoc/server_test.go
@@ -15,7 +15,6 @@
"text/template"
"golang.org/x/tools/godoc/vfs/mapfs"
- "golang.org/x/tools/internal/typeparams"
)
// TestIgnoredGoFiles tests the scenario where a folder has no .go or .c files,
@@ -133,10 +132,6 @@
}
func TestGenerics(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type params are not enabled at this Go version")
- }
-
c := NewCorpus(mapfs.New(map[string]string{
"blah/blah.go": `package blah
diff --git a/gopls/internal/analysis/embeddirective/embeddirective_test.go b/gopls/internal/analysis/embeddirective/embeddirective_test.go
index 1165c0b..22e43af 100644
--- a/gopls/internal/analysis/embeddirective/embeddirective_test.go
+++ b/gopls/internal/analysis/embeddirective/embeddirective_test.go
@@ -8,15 +8,9 @@
"testing"
"golang.org/x/tools/go/analysis/analysistest"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests)
- }
-
- analysistest.RunWithSuggestedFixes(t, testdata, Analyzer, tests...)
+ analysistest.RunWithSuggestedFixes(t, testdata, Analyzer, "a")
}
diff --git a/gopls/internal/analysis/fillreturns/fillreturns_test.go b/gopls/internal/analysis/fillreturns/fillreturns_test.go
index e57b4b9..f766766 100644
--- a/gopls/internal/analysis/fillreturns/fillreturns_test.go
+++ b/gopls/internal/analysis/fillreturns/fillreturns_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/gopls/internal/analysis/fillreturns"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.RunWithSuggestedFixes(t, testdata, fillreturns.Analyzer, tests...)
+ analysistest.RunWithSuggestedFixes(t, testdata, fillreturns.Analyzer, "a", "typeparams")
}
diff --git a/gopls/internal/analysis/fillstruct/fillstruct_test.go b/gopls/internal/analysis/fillstruct/fillstruct_test.go
index 3b1f8fd..39fc81f 100644
--- a/gopls/internal/analysis/fillstruct/fillstruct_test.go
+++ b/gopls/internal/analysis/fillstruct/fillstruct_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/gopls/internal/analysis/fillstruct"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.Run(t, testdata, fillstruct.Analyzer, tests...)
+ analysistest.Run(t, testdata, fillstruct.Analyzer, "a", "typeparams")
}
diff --git a/gopls/internal/analysis/infertypeargs/infertypeargs_test.go b/gopls/internal/analysis/infertypeargs/infertypeargs_test.go
index 7d3900f..25c88e8 100644
--- a/gopls/internal/analysis/infertypeargs/infertypeargs_test.go
+++ b/gopls/internal/analysis/infertypeargs/infertypeargs_test.go
@@ -9,13 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/gopls/internal/analysis/infertypeargs"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type params are not enabled")
- }
testdata := analysistest.TestData()
analysistest.RunWithSuggestedFixes(t, testdata, infertypeargs.Analyzer, "a")
}
diff --git a/gopls/internal/analysis/nonewvars/nonewvars_test.go b/gopls/internal/analysis/nonewvars/nonewvars_test.go
index a8af6c4..49e19db 100644
--- a/gopls/internal/analysis/nonewvars/nonewvars_test.go
+++ b/gopls/internal/analysis/nonewvars/nonewvars_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/gopls/internal/analysis/nonewvars"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.RunWithSuggestedFixes(t, testdata, nonewvars.Analyzer, tests...)
+ analysistest.RunWithSuggestedFixes(t, testdata, nonewvars.Analyzer, "a", "typeparams")
}
diff --git a/gopls/internal/analysis/noresultvalues/noresultvalues_test.go b/gopls/internal/analysis/noresultvalues/noresultvalues_test.go
index b7ced5d..e9f1a36 100644
--- a/gopls/internal/analysis/noresultvalues/noresultvalues_test.go
+++ b/gopls/internal/analysis/noresultvalues/noresultvalues_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/gopls/internal/analysis/noresultvalues"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.RunWithSuggestedFixes(t, testdata, noresultvalues.Analyzer, tests...)
+ analysistest.RunWithSuggestedFixes(t, testdata, noresultvalues.Analyzer, "a", "typeparams")
}
diff --git a/gopls/internal/analysis/simplifyslice/simplifyslice_test.go b/gopls/internal/analysis/simplifyslice/simplifyslice_test.go
index dd70b8b..969161e 100644
--- a/gopls/internal/analysis/simplifyslice/simplifyslice_test.go
+++ b/gopls/internal/analysis/simplifyslice/simplifyslice_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/gopls/internal/analysis/simplifyslice"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.RunWithSuggestedFixes(t, testdata, simplifyslice.Analyzer, tests...)
+ analysistest.RunWithSuggestedFixes(t, testdata, simplifyslice.Analyzer, "a", "typeparams")
}
diff --git a/gopls/internal/analysis/unusedparams/unusedparams_test.go b/gopls/internal/analysis/unusedparams/unusedparams_test.go
index 17c1516..1e2d885 100644
--- a/gopls/internal/analysis/unusedparams/unusedparams_test.go
+++ b/gopls/internal/analysis/unusedparams/unusedparams_test.go
@@ -9,14 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/gopls/internal/analysis/unusedparams"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
testdata := analysistest.TestData()
- tests := []string{"a"}
- if typeparams.Enabled {
- tests = append(tests, "typeparams")
- }
- analysistest.RunWithSuggestedFixes(t, testdata, unusedparams.Analyzer, tests...)
+ analysistest.RunWithSuggestedFixes(t, testdata, unusedparams.Analyzer, "a", "typeparams")
}
diff --git a/gopls/internal/analysis/useany/useany_test.go b/gopls/internal/analysis/useany/useany_test.go
index a8c505a..a8cb692 100644
--- a/gopls/internal/analysis/useany/useany_test.go
+++ b/gopls/internal/analysis/useany/useany_test.go
@@ -9,13 +9,9 @@
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/gopls/internal/analysis/useany"
- "golang.org/x/tools/internal/typeparams"
)
func Test(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type params are not enabled")
- }
testdata := analysistest.TestData()
analysistest.RunWithSuggestedFixes(t, testdata, useany.Analyzer, "a")
}
diff --git a/gopls/internal/test/integration/misc/semantictokens_test.go b/gopls/internal/test/integration/misc/semantictokens_test.go
index 3cecb27..b0b49ec 100644
--- a/gopls/internal/test/integration/misc/semantictokens_test.go
+++ b/gopls/internal/test/integration/misc/semantictokens_test.go
@@ -13,7 +13,6 @@
"golang.org/x/tools/gopls/internal/lsp/protocol"
. "golang.org/x/tools/gopls/internal/test/integration"
"golang.org/x/tools/gopls/internal/test/integration/fake"
- "golang.org/x/tools/internal/typeparams"
)
func TestBadURICrash_VSCodeIssue1498(t *testing.T) {
@@ -109,9 +108,6 @@
// fix inconsistency in TypeParameters
// https://github.com/golang/go/issues/57619
func TestSemantic_57619(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type parameters are needed for this test")
- }
src := `
-- go.mod --
module example.com
diff --git a/internal/facts/facts_test.go b/internal/facts/facts_test.go
index 4f1e8d6..56eb599 100644
--- a/internal/facts/facts_test.go
+++ b/internal/facts/facts_test.go
@@ -20,7 +20,6 @@
"golang.org/x/tools/go/packages"
"golang.org/x/tools/internal/facts"
"golang.org/x/tools/internal/testenv"
- "golang.org/x/tools/internal/typeparams"
)
type myFact struct {
@@ -250,9 +249,6 @@
test := tests[i]
t.Run(test.name, func(t *testing.T) {
t.Parallel()
- if test.typeparams && !typeparams.Enabled {
- t.Skip("type parameters are not enabled")
- }
testEncodeDecode(t, test.files, test.plookups)
})
}
@@ -444,9 +440,6 @@
// happen when Analyzers have RunDespiteErrors set to true. So this
// needs to robust, e.g. no infinite loops.
func TestMalformed(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("type parameters are not enabled")
- }
var findPkg func(*types.Package, string) *types.Package
findPkg = func(p *types.Package, name string) *types.Package {
if p.Name() == name {
diff --git a/internal/typeparams/coretype_test.go b/internal/typeparams/coretype_test.go
index 2884399..a9575f9 100644
--- a/internal/typeparams/coretype_test.go
+++ b/internal/typeparams/coretype_test.go
@@ -15,10 +15,6 @@
)
func TestCoreType(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("TestCoreType requires type parameters.")
- }
-
const source = `
package P
diff --git a/internal/typeparams/enabled_go117.go b/internal/typeparams/enabled_go117.go
deleted file mode 100644
index 1821239..0000000
--- a/internal/typeparams/enabled_go117.go
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !go1.18
-// +build !go1.18
-
-package typeparams
-
-// Enabled reports whether type parameters are enabled in the current build
-// environment.
-const Enabled = false
diff --git a/internal/typeparams/enabled_go118.go b/internal/typeparams/enabled_go118.go
deleted file mode 100644
index d671488..0000000
--- a/internal/typeparams/enabled_go118.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build go1.18
-// +build go1.18
-
-package typeparams
-
-// Note: this constant is in a separate file as this is the only acceptable
-// diff between the <1.18 API of this package and the 1.18 API.
-
-// Enabled reports whether type parameters are enabled in the current build
-// environment.
-const Enabled = true
diff --git a/internal/typeparams/normalize_test.go b/internal/typeparams/normalize_test.go
index 769433d..a6253fa 100644
--- a/internal/typeparams/normalize_test.go
+++ b/internal/typeparams/normalize_test.go
@@ -18,10 +18,6 @@
)
func TestStructuralTerms(t *testing.T) {
- if !Enabled {
- t.Skip("typeparams are not enabled")
- }
-
// In the following tests, src must define a type T with (at least) one type
// parameter. We will compute the structural terms of the first type
// parameter.
diff --git a/internal/typeparams/typeparams_go117.go b/internal/typeparams/typeparams_go117.go
deleted file mode 100644
index 7ed86e1..0000000
--- a/internal/typeparams/typeparams_go117.go
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !go1.18
-// +build !go1.18
-
-package typeparams
-
-import (
- "go/ast"
- "go/token"
- "go/types"
-)
-
-func unsupported() {
- panic("type parameters are unsupported at this go version")
-}
-
-// IndexListExpr is a placeholder type, as type parameters are not supported at
-// this Go version. Its methods panic on use.
-type IndexListExpr struct {
- ast.Expr
- X ast.Expr // expression
- Lbrack token.Pos // position of "["
- Indices []ast.Expr // index expressions
- Rbrack token.Pos // position of "]"
-}
-
-// ForTypeSpec returns an empty field list, as type parameters on not supported
-// at this Go version.
-func ForTypeSpec(*ast.TypeSpec) *ast.FieldList {
- return nil
-}
-
-// ForFuncType returns an empty field list, as type parameters are not
-// supported at this Go version.
-func ForFuncType(*ast.FuncType) *ast.FieldList {
- return nil
-}
-
-// TypeParam is a placeholder type, as type parameters are not supported at
-// this Go version. Its methods panic on use.
-type TypeParam struct{ types.Type }
-
-func (*TypeParam) Index() int { unsupported(); return 0 }
-func (*TypeParam) Constraint() types.Type { unsupported(); return nil }
-func (*TypeParam) Obj() *types.TypeName { unsupported(); return nil }
-
-// TypeParamList is a placeholder for an empty type parameter list.
-type TypeParamList struct{}
-
-func (*TypeParamList) Len() int { return 0 }
-func (*TypeParamList) At(int) *TypeParam { unsupported(); return nil }
-
-// TypeList is a placeholder for an empty type list.
-type TypeList struct{}
-
-func (*TypeList) Len() int { return 0 }
-func (*TypeList) At(int) types.Type { unsupported(); return nil }
-
-// NewTypeParam is unsupported at this Go version, and panics.
-func NewTypeParam(name *types.TypeName, constraint types.Type) *TypeParam {
- unsupported()
- return nil
-}
-
-// SetTypeParamConstraint is unsupported at this Go version, and panics.
-func SetTypeParamConstraint(tparam *TypeParam, constraint types.Type) {
- unsupported()
-}
-
-// NewSignatureType calls types.NewSignature, panicking if recvTypeParams or
-// typeParams is non-empty.
-func NewSignatureType(recv *types.Var, recvTypeParams, typeParams []*TypeParam, params, results *types.Tuple, variadic bool) *types.Signature {
- if len(recvTypeParams) != 0 || len(typeParams) != 0 {
- panic("signatures cannot have type parameters at this Go version")
- }
- return types.NewSignature(recv, params, results, variadic)
-}
-
-// ForSignature returns an empty slice.
-func ForSignature(*types.Signature) *TypeParamList {
- return nil
-}
-
-// RecvTypeParams returns a nil slice.
-func RecvTypeParams(sig *types.Signature) *TypeParamList {
- return nil
-}
-
-// IsComparable returns false, as no interfaces are type-restricted at this Go
-// version.
-func IsComparable(*types.Interface) bool {
- return false
-}
-
-// IsMethodSet returns true, as no interfaces are type-restricted at this Go
-// version.
-func IsMethodSet(*types.Interface) bool {
- return true
-}
-
-// IsImplicit returns false, as no interfaces are implicit at this Go version.
-func IsImplicit(*types.Interface) bool {
- return false
-}
-
-// MarkImplicit does nothing, because this Go version does not have implicit
-// interfaces.
-func MarkImplicit(*types.Interface) {}
-
-// ForNamed returns an empty type parameter list, as type parameters are not
-// supported at this Go version.
-func ForNamed(*types.Named) *TypeParamList {
- return nil
-}
-
-// SetForNamed panics if tparams is non-empty.
-func SetForNamed(_ *types.Named, tparams []*TypeParam) {
- if len(tparams) > 0 {
- unsupported()
- }
-}
-
-// NamedTypeArgs returns nil.
-func NamedTypeArgs(*types.Named) *TypeList {
- return nil
-}
-
-// NamedTypeOrigin is the identity method at this Go version.
-func NamedTypeOrigin(named *types.Named) *types.Named {
- return named
-}
-
-// Term holds information about a structural type restriction.
-type Term struct {
- tilde bool
- typ types.Type
-}
-
-func (m *Term) Tilde() bool { return m.tilde }
-func (m *Term) Type() types.Type { return m.typ }
-func (m *Term) String() string {
- pre := ""
- if m.tilde {
- pre = "~"
- }
- return pre + m.typ.String()
-}
-
-// NewTerm is unsupported at this Go version, and panics.
-func NewTerm(tilde bool, typ types.Type) *Term {
- return &Term{tilde, typ}
-}
-
-// Union is a placeholder type, as type parameters are not supported at this Go
-// version. Its methods panic on use.
-type Union struct{ types.Type }
-
-func (*Union) Len() int { return 0 }
-func (*Union) Term(i int) *Term { unsupported(); return nil }
-
-// NewUnion is unsupported at this Go version, and panics.
-func NewUnion(terms []*Term) *Union {
- unsupported()
- return nil
-}
-
-// InitInstanceInfo is a noop at this Go version.
-func InitInstanceInfo(*types.Info) {}
-
-// Instance is a placeholder type, as type parameters are not supported at this
-// Go version.
-type Instance struct {
- TypeArgs *TypeList
- Type types.Type
-}
-
-// GetInstances returns a nil map, as type parameters are not supported at this
-// Go version.
-func GetInstances(info *types.Info) map[*ast.Ident]Instance { return nil }
-
-// Context is a placeholder type, as type parameters are not supported at
-// this Go version.
-type Context struct{}
-
-// NewContext returns a placeholder Context instance.
-func NewContext() *Context {
- return &Context{}
-}
-
-// Instantiate is unsupported on this Go version, and panics.
-func Instantiate(ctxt *Context, typ types.Type, targs []types.Type, validate bool) (types.Type, error) {
- unsupported()
- return nil, nil
-}
diff --git a/internal/typeparams/typeparams_go118.go b/internal/typeparams/typeparams_go118.go
index cf301af..0bda83d 100644
--- a/internal/typeparams/typeparams_go118.go
+++ b/internal/typeparams/typeparams_go118.go
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.18
-// +build go1.18
-
package typeparams
import (
@@ -12,6 +9,8 @@
"go/types"
)
+// TODO(adonovan): melt the aliases away.
+
// IndexListExpr is an alias for ast.IndexListExpr.
type IndexListExpr = ast.IndexListExpr
diff --git a/internal/typeparams/typeparams_test.go b/internal/typeparams/typeparams_test.go
deleted file mode 100644
index cdbcae9..0000000
--- a/internal/typeparams/typeparams_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build go1.18
-// +build go1.18
-
-package typeparams_test
-
-import (
- "go/ast"
- "go/importer"
- "go/parser"
- "go/token"
- "go/types"
- "strings"
- "testing"
-
- "golang.org/x/tools/internal/apidiff"
- "golang.org/x/tools/internal/testenv"
-)
-
-func TestAPIConsistency(t *testing.T) {
- testenv.NeedsGoBuild(t) // This is a lie. We actually need the source code.
-
- // The packages below exclude enabled_*.go, as typeparams.Enabled is
- // permitted to change between versions.
- old := typeCheck(t, []string{"common.go", "typeparams_go117.go"})
- new := typeCheck(t, []string{"common.go", "typeparams_go118.go"})
-
- report := apidiff.Changes(old, new)
-
- // Temporarily ignore API diff related to Environment, so that we can use a
- // transient alias in go/types to allow renaming this type without ever
- // breaking the x/tools builder.
- // TODO(rfindley): remove this
- var filteredChanges []apidiff.Change
- for _, change := range report.Changes {
- if strings.Contains(change.Message, "Environment") {
- continue
- }
- filteredChanges = append(filteredChanges, change)
- }
- report.Changes = filteredChanges
- if len(report.Changes) > 0 {
- t.Errorf("API diff:\n%s", report)
- }
-}
-
-func typeCheck(t *testing.T, filenames []string) *types.Package {
- fset := token.NewFileSet()
- var files []*ast.File
- for _, name := range filenames {
- f, err := parser.ParseFile(fset, name, nil, 0)
- if err != nil {
- t.Fatal(err)
- }
- files = append(files, f)
- }
- conf := types.Config{
- Importer: importer.Default(),
- }
- pkg, err := conf.Check("", fset, files, nil)
- if err != nil {
- t.Fatal(err)
- }
- return pkg
-}
diff --git a/refactor/satisfy/find_test.go b/refactor/satisfy/find_test.go
index 995b95f..e6ffa42 100644
--- a/refactor/satisfy/find_test.go
+++ b/refactor/satisfy/find_test.go
@@ -23,10 +23,6 @@
// This test exercises various operations on core types of type parameters.
// (It also provides pretty decent coverage of the non-generic operations.)
func TestGenericCoreOperations(t *testing.T) {
- if !typeparams.Enabled {
- t.Skip("!typeparams.Enabled")
- }
-
const src = `package foo
import "unsafe"