go/ssa: remove outdated any normalizer setting up in test

Remove the outdated normalizer for formatting interface{} as
any during tests.

* another benefit is we remove the un-exported test function from
  example, it's clearer for pkgsite and godoc users.
This commit is contained in:
xieyuschen 2024-09-17 12:00:05 +08:00
Родитель 91d4bdb347
Коммит 40157a9970
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C4189F4DAA5C381
3 изменённых файлов: 1 добавлений и 22 удалений

Просмотреть файл

@ -60,9 +60,6 @@ func main() {
// syntax, perhaps obtained from golang.org/x/tools/go/packages.
// In that case, see the other examples for simpler approaches.
func Example_buildPackage() {
// Replace interface{} with any for this test.
ssa.SetNormalizeAnyForTesting(true)
defer ssa.SetNormalizeAnyForTesting(false)
// Parse the source files.
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "hello.go", hello, parser.ParseComments)

Просмотреть файл

@ -39,16 +39,8 @@ func relName(v Value, i Instruction) string {
return v.Name()
}
// normalizeAnyForTesting controls whether we replace occurrences of
// interface{} with any. It is only used for normalizing test output.
var normalizeAnyForTesting bool
func relType(t types.Type, from *types.Package) string {
s := types.TypeString(t, types.RelativeTo(from))
if normalizeAnyForTesting {
s = strings.ReplaceAll(s, "interface{}", "any")
}
return s
return types.TypeString(t, types.RelativeTo(from))
}
func relTerm(term *types.Term, from *types.Package) string {

Просмотреть файл

@ -1,10 +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.
package ssa
// SetNormalizeAnyForTesting is exported here for external tests.
func SetNormalizeAnyForTesting(normalize bool) {
normalizeAnyForTesting = normalize
}