Skip to content

Commit

Permalink
go/types, types2: unexport NewTypeList
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
findleyr committed Dec 6, 2021
1 parent 20b9aac commit f8a8a73
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 15 deletions.
4 changes: 1 addition & 3 deletions doc/go1.18.html
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,7 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
</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
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/types2/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/types2/instantiate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/types2/typelists.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/types2/typexpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/go/types/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/go/types/instantiate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions src/go/types/typelists.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/go/types/typexpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}

Expand Down

0 comments on commit f8a8a73

Please sign in to comment.