]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types, types2: unexport NewTypeList
authorRobert Findley <rfindley@google.com>
Mon, 6 Dec 2021 03:18:04 +0000 (22:18 -0500)
committerRobert Findley <rfindley@google.com>
Mon, 6 Dec 2021 14:58:33 +0000 (14:58 +0000)
NewTypeList was not part of the go/types API proposal, and was left in
by accident. It also shouldn't be necessary, so remove it.

Updates #47916

Change-Id: I4db3ccf036ccfb708ecf2c176ea4921fe68089a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/369475
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
doc/go1.18.html
src/cmd/compile/internal/types2/check.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/typelists.go
src/cmd/compile/internal/types2/typexpr.go
src/go/types/check.go
src/go/types/instantiate.go
src/go/types/typelists.go
src/go/types/typexpr.go

index 16a5a6723cae956113ad68bad4da6e0191282ab3..35b3d744ece46bc96c0f0d9928ca026f0b3be914 100644 (file)
@@ -516,9 +516,7 @@ Do not send CLs removing the interior tags from such phrases.
       </li>
       <li>
         The new type
-        <a href="/pkg/go/types/#TypeList"><code>TypeList</code></a> and factory function
-        <a href="/pkg/go/types/#NewTypeList"><code>NewTypeList</code></a> facilitate storing
-        a list of types.
+        <a href="/pkg/go/types/#TypeList"><code>TypeList</code></a> holds a list of types.
       </li>
       <li>
         The new factory function
index 38fc25c74db83e9cc90314cd0a47fac5d31e8402..aacbb25b3b4f4dc981edf4813acc5168ec1232ca 100644 (file)
@@ -494,7 +494,7 @@ func (check *Checker) recordInstance(expr syntax.Expr, targs []Type, typ Type) {
        assert(ident != nil)
        assert(typ != nil)
        if m := check.Instances; m != nil {
-               m[ident] = Instance{NewTypeList(targs), typ}
+               m[ident] = Instance{newTypeList(targs), typ}
        }
 }
 
index f9423dd70ef75c75f42c1fc6f32970c30029c8a6..cda6c7baf4e5c543f674903a05f01ca8a24d9a81 100644 (file)
@@ -77,7 +77,7 @@ func (check *Checker) instance(pos syntax.Pos, orig Type, targs []Type, ctxt *Co
        case *Named:
                tname := NewTypeName(pos, orig.obj.pkg, orig.obj.name, nil)
                named := check.newNamed(tname, orig, nil, nil, nil) // underlying, tparams, and methods are set when named is resolved
-               named.targs = NewTypeList(targs)
+               named.targs = newTypeList(targs)
                named.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) {
                        return expandNamed(ctxt, n, pos)
                }
index ababe85909d38b07c96130877d45379d5eead664..0b77edbde251afaa5bc5094a1c0e1d32b0793e38 100644 (file)
@@ -29,8 +29,8 @@ func (l *TypeParamList) list() []*TypeParam {
 // TypeList holds a list of types.
 type TypeList struct{ types []Type }
 
-// NewTypeList returns a new TypeList with the types in list.
-func NewTypeList(list []Type) *TypeList {
+// newTypeList returns a new TypeList with the types in list.
+func newTypeList(list []Type) *TypeList {
        if len(list) == 0 {
                return nil
        }
index 56a7dcd2032ca7c60726e7ff6a01fe9c0cc8c779..9121c2c1f64414bd0d45b205d39d3fa4bf44868a 100644 (file)
@@ -442,7 +442,7 @@ func (check *Checker) instantiatedType(x syntax.Expr, xlist []syntax.Expr, def *
        if inst == nil {
                tname := NewTypeName(x.Pos(), orig.obj.pkg, orig.obj.name, nil)
                inst = check.newNamed(tname, orig, nil, nil, nil) // underlying, methods and tparams are set when named is resolved
-               inst.targs = NewTypeList(targs)
+               inst.targs = newTypeList(targs)
                inst = ctxt.update(h, orig, targs, inst).(*Named)
        }
        def.setUnderlying(inst)
@@ -456,7 +456,7 @@ func (check *Checker) instantiatedType(x syntax.Expr, xlist []syntax.Expr, def *
                        // be set to Typ[Invalid] in expandNamed.
                        inferred = check.infer(x.Pos(), tparams, targs, nil, nil)
                        if len(inferred) > len(targs) {
-                               inst.targs = NewTypeList(inferred)
+                               inst.targs = newTypeList(inferred)
                        }
                }
 
index 38508c77a94388d4b81f6f232d01036c62dfb9cb..d967c0bd2511587ee5a9b5ae314807044a99fdfd 100644 (file)
@@ -487,7 +487,7 @@ func (check *Checker) recordInstance(expr ast.Expr, targs []Type, typ Type) {
        assert(ident != nil)
        assert(typ != nil)
        if m := check.Instances; m != nil {
-               m[ident] = Instance{NewTypeList(targs), typ}
+               m[ident] = Instance{newTypeList(targs), typ}
        }
 }
 
index 597a6da624f62fb9ebb844e8ffbc442217c81f63..e91d08cc5ee44d4c6feca84446619e38118583c0 100644 (file)
@@ -77,7 +77,7 @@ func (check *Checker) instance(pos token.Pos, orig Type, targs []Type, ctxt *Con
        case *Named:
                tname := NewTypeName(pos, orig.obj.pkg, orig.obj.name, nil)
                named := check.newNamed(tname, orig, nil, nil, nil) // underlying, tparams, and methods are set when named is resolved
-               named.targs = NewTypeList(targs)
+               named.targs = newTypeList(targs)
                named.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) {
                        return expandNamed(ctxt, n, pos)
                }
index ba74b8d45abb80d232e950818746b84f164831a3..aea19e946dd5779f941ac546ee1b27b59c3eedca 100644 (file)
@@ -29,8 +29,8 @@ func (l *TypeParamList) list() []*TypeParam {
 // TypeList holds a list of types.
 type TypeList struct{ types []Type }
 
-// NewTypeList returns a new TypeList with the types in list.
-func NewTypeList(list []Type) *TypeList {
+// newTypeList returns a new TypeList with the types in list.
+func newTypeList(list []Type) *TypeList {
        if len(list) == 0 {
                return nil
        }
index 0a74a875bcf8a840cea5c80b19e0c2ad78723a1d..b961f7c47fcc6df91ab49946903057156723c3fb 100644 (file)
@@ -427,7 +427,7 @@ func (check *Checker) instantiatedType(ix *typeparams.IndexExpr, def *Named) (re
        if inst == nil {
                tname := NewTypeName(ix.X.Pos(), orig.obj.pkg, orig.obj.name, nil)
                inst = check.newNamed(tname, orig, nil, nil, nil) // underlying, methods and tparams are set when named is resolved
-               inst.targs = NewTypeList(targs)
+               inst.targs = newTypeList(targs)
                inst = ctxt.update(h, orig, targs, inst).(*Named)
        }
        def.setUnderlying(inst)
@@ -441,7 +441,7 @@ func (check *Checker) instantiatedType(ix *typeparams.IndexExpr, def *Named) (re
                        // be set to Typ[Invalid] in expandNamed.
                        inferred = check.infer(ix.Orig, tparams, targs, nil, nil)
                        if len(inferred) > len(targs) {
-                               inst.targs = NewTypeList(inferred)
+                               inst.targs = newTypeList(inferred)
                        }
                }