]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: unexport Context.TypeHash
authorRobert Findley <rfindley@google.com>
Fri, 12 Nov 2021 00:07:28 +0000 (19:07 -0500)
committerRobert Findley <rfindley@google.com>
Fri, 12 Nov 2021 18:14:22 +0000 (18:14 +0000)
Context.TypeHash is not being used outside of the type checker, so
unexport it.

The TypeHash method is meant to hash instances, not arbitrary types, and
will soon be modified to differentiate origin types by pointer identity
(even if they are *Signature types).

Change-Id: Ia8d4a7c6350ce7f278b70630585efb0009fef63a
Reviewed-on: https://go-review.googlesource.com/c/go/+/363516
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/types2/context.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/named.go
src/cmd/compile/internal/types2/subst.go
src/cmd/compile/internal/types2/typexpr.go

index f6137eea43588a6419debff4afe8057231228a02..9e9eb5bdf6bb9955385e7c8f4e3cfa1dd262fcf2 100644 (file)
@@ -29,11 +29,11 @@ func NewContext() *Context {
        }
 }
 
-// TypeHash returns a string representation of typ, which can be used as an exact
+// typeHash returns a string representation of typ, which can be used as an exact
 // type hash: types that are identical produce identical string representations.
 // If typ is a *Named type and targs is not empty, typ is printed as if it were
 // instantiated with targs. The result is guaranteed to not contain blanks (" ").
-func (ctxt *Context) TypeHash(typ Type, targs []Type) string {
+func (ctxt *Context) typeHash(typ Type, targs []Type) string {
        assert(ctxt != nil)
        assert(typ != nil)
        var buf bytes.Buffer
index 44cf593ffbf1fa5e69cacdce6a758c3ce7b64b51..f814619bb03eb46edb38e7f6c0e3c8d927ff9507 100644 (file)
@@ -57,7 +57,7 @@ func (check *Checker) instance(pos syntax.Pos, typ Type, targs []Type, ctxt *Con
        case *Named:
                var h string
                if ctxt != nil {
-                       h = ctxt.TypeHash(t, targs)
+                       h = ctxt.typeHash(t, targs)
                        // typ may already have been instantiated with identical type arguments. In
                        // that case, re-use the existing instance.
                        if named := ctxt.typeForHash(h, nil); named != nil {
index 6ebad8fbb5b8ee26f1338ae5349c05ee7911b880..e73a31d42e52970576447a8b7a868c754442b990 100644 (file)
@@ -251,7 +251,7 @@ func expandNamed(ctxt *Context, n *Named, instPos syntax.Pos) (tparams *TypePara
        if n.orig.tparams.Len() == n.targs.Len() {
                // We must always have a context, to avoid infinite recursion.
                ctxt = check.bestContext(ctxt)
-               h := ctxt.TypeHash(n.orig, n.targs.list())
+               h := ctxt.typeHash(n.orig, n.targs.list())
                // ensure that an instance is recorded for h to avoid infinite recursion.
                ctxt.typeForHash(h, n)
 
index f46e895b128e36bcf35559ba379886b7b3fb2b02..5deb868a791635b1349123825b3fdbeacbd3c2d0 100644 (file)
@@ -207,7 +207,7 @@ func (subst *subster) typ(typ Type) Type {
                }
 
                // before creating a new named type, check if we have this one already
-               h := subst.ctxt.TypeHash(t.orig, newTArgs)
+               h := subst.ctxt.typeHash(t.orig, newTArgs)
                dump(">>> new type hash: %s", h)
                if named := subst.ctxt.typeForHash(h, nil); named != nil {
                        dump(">>> found %s", named)
index a08e4727033f046828d452dfc63ae6d0a690591e..82c029cfd6a6e6cc9484e6bfe79fd8cb29430556 100644 (file)
@@ -431,7 +431,7 @@ func (check *Checker) instantiatedType(x syntax.Expr, targsx []syntax.Expr, def
        }
 
        // create the instance
-       h := check.conf.Context.TypeHash(origin, targs)
+       h := check.conf.Context.typeHash(origin, targs)
        // targs may be incomplete, and require inference. In any case we should de-duplicate.
        inst := check.conf.Context.typeForHash(h, nil)
        // If inst is non-nil, we can't just return here. Inst may have been