aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types/type.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-04-02 14:31:15 -0700
committerDan Scales <danscales@google.com>2021-04-03 18:16:29 +0000
commit6986c02d72db6806a46406ef398aa10f26018c20 (patch)
tree8dbfc5c52f171d00013221a1e362d6f89a7ce21b /src/cmd/compile/internal/types/type.go
parentfe587ce856d1dee97829fe0ed090ba7e068335cb (diff)
downloadgo-6986c02d72db6806a46406ef398aa10f26018c20.tar.gz
go-6986c02d72db6806a46406ef398aa10f26018c20.zip
cmd/compile: rename newNamedTypeWithSym, add some commemnts
Renamed newNamedTypeWithSym to newIncompleteNamedType. Added some extra comments to types.NewNamed and types.SetUnderlying. Change-Id: Idc5a6379991c26b429d91bae9fe1adef8457a75c Reviewed-on: https://go-review.googlesource.com/c/go/+/307029 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Ingo Oeser <nightlyone@googlemail.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/types/type.go')
-rw-r--r--src/cmd/compile/internal/types/type.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go
index 31a99781d1..762cdd3258 100644
--- a/src/cmd/compile/internal/types/type.go
+++ b/src/cmd/compile/internal/types/type.go
@@ -1643,7 +1643,10 @@ var (
TypeResultMem = newResults([]*Type{TypeMem})
)
-// NewNamed returns a new named type for the given type name. obj should be an ir.Name.
+// NewNamed returns a new named type for the given type name. obj should be an
+// ir.Name. The new type is incomplete, and the underlying type should be set
+// later via SetUnderlying(). References to the type are maintained until the type
+// is filled in, so those references can be updated when the type is complete.
func NewNamed(obj Object) *Type {
t := New(TFORW)
t.sym = obj.Sym()
@@ -1659,7 +1662,8 @@ func (t *Type) Obj() Object {
return nil
}
-// SetUnderlying sets the underlying type.
+// SetUnderlying sets the underlying type. SetUnderlying automatically updates any
+// types that were waiting for this type to be completed.
func (t *Type) SetUnderlying(underlying *Type) {
if underlying.kind == TFORW {
// This type isn't computed yet; when it is, update n.