From 25e1ac41e621bb72a07aa6277defc4d4dcfad6f3 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Thu, 20 Jan 2022 11:28:07 -0500 Subject: [PATCH] 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 Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer gopls-CI: kokoro TryBot-Result: Gopher Robot --- go/internal/gcimporter/bexport_test.go | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/go/internal/gcimporter/bexport_test.go b/go/internal/gcimporter/bexport_test.go index f20cec4d3a..3da5397eb5 100644 --- a/go/internal/gcimporter/bexport_test.go +++ b/go/internal/gcimporter/bexport_test.go @@ -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.