зеркало из https://github.com/golang/tools.git
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.
Change-Id: Ibc0513e7487a278b1275de804aa8bd3b444a5496
GitHub-Last-Rev: 40157a9970
GitHub-Pull-Request: golang/tools#522
Reviewed-on: https://go-review.googlesource.com/c/tools/+/613161
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
This commit is contained in:
Родитель
03550136e7
Коммит
18a3f0501f
|
@ -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
|
||||
}
|
Загрузка…
Ссылка в новой задаче