mirror of https://github.com/golang/go.git
go/internal/gcimporter: remove the sanitizeName helper
It not necessary to sanitize object/type strings produced by go/types, because they no longer contain subscripts. Change-Id: I3ed41359d59b01ab2cf2ad4a6b587635ce4cecf2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/379854 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
9134808125
commit
25e1ac41e6
|
|
@ -327,7 +327,7 @@ func equalType(x, y types.Type) error {
|
|||
}
|
||||
case *typeparams.TypeParam:
|
||||
y := y.(*typeparams.TypeParam)
|
||||
if sanitizeName(x.String()) != sanitizeName(y.String()) {
|
||||
if x.String() != y.String() {
|
||||
return fmt.Errorf("unequal named types: %s vs %s", x, y)
|
||||
}
|
||||
// For now, just compare constraints by type string to short-circuit
|
||||
|
|
@ -335,8 +335,8 @@ func equalType(x, y types.Type) error {
|
|||
// doesn't support marking interfaces as implicit.
|
||||
// TODO(rfindley): remove makeExplicit once export data contains an
|
||||
// implicit bit.
|
||||
xc := sanitizeName(makeExplicit(x.Constraint()).String())
|
||||
yc := sanitizeName(makeExplicit(y.Constraint()).String())
|
||||
xc := makeExplicit(x.Constraint()).String()
|
||||
yc := makeExplicit(y.Constraint()).String()
|
||||
if xc != yc {
|
||||
return fmt.Errorf("unequal constraints: %s vs %s", xc, yc)
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ func equalType(x, y types.Type) error {
|
|||
func cmpNamed(x, y *types.Named) error {
|
||||
xOrig := typeparams.NamedTypeOrigin(x)
|
||||
yOrig := typeparams.NamedTypeOrigin(y)
|
||||
if sanitizeName(xOrig.String()) != sanitizeName(yOrig.String()) {
|
||||
if xOrig.String() != yOrig.String() {
|
||||
return fmt.Errorf("unequal named types: %s vs %s", x, y)
|
||||
}
|
||||
if err := equalTypeParams(typeparams.ForNamed(x), typeparams.ForNamed(y)); err != nil {
|
||||
|
|
@ -383,7 +383,7 @@ func cmpNamed(x, y *types.Named) error {
|
|||
}
|
||||
// Calling equalType here leads to infinite recursion, so just compare
|
||||
// strings.
|
||||
if sanitizeName(xm.String()) != sanitizeName(ym.String()) {
|
||||
if xm.String() != ym.String() {
|
||||
return fmt.Errorf("unequal methods: %s vs %s", x, y)
|
||||
}
|
||||
}
|
||||
|
|
@ -431,20 +431,6 @@ func equalTypeParams(x, y *typeparams.TypeParamList) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// sanitizeName removes type parameter debugging markers from an object
|
||||
// or type string, to normalize it for comparison.
|
||||
// TODO(rfindley): remove once this is no longer necessary.
|
||||
func sanitizeName(name string) string {
|
||||
var runes []rune
|
||||
for _, r := range name {
|
||||
if '₀' <= r && r < '₀'+10 {
|
||||
continue // trim type parameter subscripts
|
||||
}
|
||||
runes = append(runes, r)
|
||||
}
|
||||
return string(runes)
|
||||
}
|
||||
|
||||
// TestVeryLongFile tests the position of an import object declared in
|
||||
// a very long input file. Line numbers greater than maxlines are
|
||||
// reported as line 1, not garbage or token.NoPos.
|
||||
|
|
|
|||
Loading…
Reference in New Issue