diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go index 50341e064c6..8d7a9ecfb24 100644 --- a/src/go/types/instantiate.go +++ b/src/go/types/instantiate.go @@ -13,6 +13,19 @@ import ( "go/token" ) +// An Environment is an opaque type checking environment. It may be used to +// share identical type instances across type checked packages or calls to +// Instantiate. +// +// Currently, Environment is just a placeholder and has no effect on +// instantiation. +type Environment struct { + // Environment is currently un-implemented, because our instantiatedHash + // logic doesn't correctly handle Named type identity across multiple + // packages. + // TODO(rfindley): implement this. +} + // Instantiate instantiates the type typ with the given type arguments targs. // typ must be a *Named or a *Signature type, and its number of type parameters // must match the number of provided type arguments. The result is a new, @@ -20,8 +33,9 @@ import ( // *Signature). Any methods attached to a *Named are simply copied; they are // not instantiated. // -// If check is non-nil, it will be used to de-dupe the instance against -// previous instances with the same identity. +// If env is non-nil, it may be used to de-dupe the instance against previous +// instances with the same identity. This functionality is currently +// unimplemented. // // If verify is set and constraint satisfaction fails, the returned error may // be of dynamic type ArgumentError indicating which type argument did not @@ -29,8 +43,8 @@ import ( // // TODO(rfindley): change this function to also return an error if lengths of // tparams and targs do not match. -func Instantiate(check *Checker, typ Type, targs []Type, validate bool) (Type, error) { - inst := check.instance(token.NoPos, typ, targs) +func Instantiate(env *Environment, typ Type, targs []Type, validate bool) (Type, error) { + inst := (*Checker)(nil).instance(token.NoPos, typ, targs) var err error if validate { @@ -41,7 +55,7 @@ func Instantiate(check *Checker, typ Type, targs []Type, validate bool) (Type, e case *Signature: tparams = t.TParams().list() } - if i, err := check.verify(token.NoPos, tparams, targs); err != nil { + if i, err := (*Checker)(nil).verify(token.NoPos, tparams, targs); err != nil { return inst, ArgumentError{i, err} } }