}
}
-// 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
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 {
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)
}
// 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)
}
// 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