]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: export Named.Orig as Named.Origin
authorRobert Griesemer <gri@golang.org>
Tue, 21 Sep 2021 03:34:17 +0000 (20:34 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 21 Sep 2021 20:28:38 +0000 (20:28 +0000)
This is a slightly adjusted port of CL 350996 from go/types to types2.

Change-Id: I8f5902ecb20a4b4d2a5ef0d3641d857bc3a618e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/351170
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/noder/types.go
src/cmd/compile/internal/noder/writer.go
src/cmd/compile/internal/types2/named.go

index 99917ad9741364bf9326040bdfededff24a5f2b7..e1cfe4a9d8a2c5cdfd079ee384df3c48d1ea17a8 100644 (file)
@@ -115,7 +115,7 @@ func (g *irgen) typ0(typ types2.Type) *types.Type {
                        // Make sure the base generic type exists in type1 (it may
                        // not yet if we are referecing an imported generic type, as
                        // opposed to a generic type declared in this package).
-                       _ = g.obj(typ.Orig().Obj())
+                       _ = g.obj(typ.Origin().Obj())
 
                        // Create a forwarding type first and put it in the g.typs
                        // map, in order to deal with recursive generic types
index 6a66bea239b02714012cefcf612b1cb9ea973d65..9edf5fc97aa6da3996fce44fa30273ef0270d5b6 100644 (file)
@@ -296,7 +296,7 @@ func (pw *pkgWriter) typIdx(typ types2.Type, dict *writerDict) typeInfo {
                // TODO(mdempsky): Why do we need to loop here?
                orig := typ
                for orig.TypeArgs() != nil {
-                       orig = orig.Orig()
+                       orig = orig.Origin()
                }
 
                w.code(typeNamed)
index bc4ac87b9dbdd0c56d0e21ed5bf0e0229b755372..36a8b88f252facad39893d4832683913721cdd6d 100644 (file)
@@ -87,13 +87,11 @@ func (check *Checker) newNamed(obj *TypeName, orig *Named, underlying Type, tpar
 
 // Obj returns the type name for the declaration defining the named type t. For
 // instantiated types, this is the type name of the base type.
-func (t *Named) Obj() *TypeName {
-       return t.orig.obj // for non-instances this is the same as t.obj
-}
+func (t *Named) Obj() *TypeName { return t.orig.obj } // for non-instances this is the same as t.obj
 
-// Orig returns the original generic type an instantiated type is derived from.
-// If t is not an instantiated type, the result is t.
-func (t *Named) Orig() *Named { return t.orig }
+// Origin returns the parameterized type from which the named type t is
+// instantiated. If t is not an instantiated type, the result is t.
+func (t *Named) Origin() *Named { return t.orig }
 
 // TODO(gri) Come up with a better representation and API to distinguish
 //           between parameterized instantiated and non-instantiated types.