Skip to content

Commit f8a8a73

Browse files
committed
go/types, types2: unexport NewTypeList
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 <[email protected]> Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 20b9aac commit f8a8a73

File tree

9 files changed

+13
-15
lines changed

9 files changed

+13
-15
lines changed

Diff for: doc/go1.18.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,7 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
516516
</li>
517517
<li>
518518
The new type
519-
<a href="/pkg/go/types/#TypeList"><code>TypeList</code></a> and factory function
520-
<a href="/pkg/go/types/#NewTypeList"><code>NewTypeList</code></a> facilitate storing
521-
a list of types.
519+
<a href="/pkg/go/types/#TypeList"><code>TypeList</code></a> holds a list of types.
522520
</li>
523521
<li>
524522
The new factory function

Diff for: src/cmd/compile/internal/types2/check.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ func (check *Checker) recordInstance(expr syntax.Expr, targs []Type, typ Type) {
494494
assert(ident != nil)
495495
assert(typ != nil)
496496
if m := check.Instances; m != nil {
497-
m[ident] = Instance{NewTypeList(targs), typ}
497+
m[ident] = Instance{newTypeList(targs), typ}
498498
}
499499
}
500500

Diff for: src/cmd/compile/internal/types2/instantiate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (check *Checker) instance(pos syntax.Pos, orig Type, targs []Type, ctxt *Co
7777
case *Named:
7878
tname := NewTypeName(pos, orig.obj.pkg, orig.obj.name, nil)
7979
named := check.newNamed(tname, orig, nil, nil, nil) // underlying, tparams, and methods are set when named is resolved
80-
named.targs = NewTypeList(targs)
80+
named.targs = newTypeList(targs)
8181
named.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) {
8282
return expandNamed(ctxt, n, pos)
8383
}

Diff for: src/cmd/compile/internal/types2/typelists.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func (l *TypeParamList) list() []*TypeParam {
2929
// TypeList holds a list of types.
3030
type TypeList struct{ types []Type }
3131

32-
// NewTypeList returns a new TypeList with the types in list.
33-
func NewTypeList(list []Type) *TypeList {
32+
// newTypeList returns a new TypeList with the types in list.
33+
func newTypeList(list []Type) *TypeList {
3434
if len(list) == 0 {
3535
return nil
3636
}

Diff for: src/cmd/compile/internal/types2/typexpr.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ func (check *Checker) instantiatedType(x syntax.Expr, xlist []syntax.Expr, def *
442442
if inst == nil {
443443
tname := NewTypeName(x.Pos(), orig.obj.pkg, orig.obj.name, nil)
444444
inst = check.newNamed(tname, orig, nil, nil, nil) // underlying, methods and tparams are set when named is resolved
445-
inst.targs = NewTypeList(targs)
445+
inst.targs = newTypeList(targs)
446446
inst = ctxt.update(h, orig, targs, inst).(*Named)
447447
}
448448
def.setUnderlying(inst)
@@ -456,7 +456,7 @@ func (check *Checker) instantiatedType(x syntax.Expr, xlist []syntax.Expr, def *
456456
// be set to Typ[Invalid] in expandNamed.
457457
inferred = check.infer(x.Pos(), tparams, targs, nil, nil)
458458
if len(inferred) > len(targs) {
459-
inst.targs = NewTypeList(inferred)
459+
inst.targs = newTypeList(inferred)
460460
}
461461
}
462462

Diff for: src/go/types/check.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ func (check *Checker) recordInstance(expr ast.Expr, targs []Type, typ Type) {
487487
assert(ident != nil)
488488
assert(typ != nil)
489489
if m := check.Instances; m != nil {
490-
m[ident] = Instance{NewTypeList(targs), typ}
490+
m[ident] = Instance{newTypeList(targs), typ}
491491
}
492492
}
493493

Diff for: src/go/types/instantiate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (check *Checker) instance(pos token.Pos, orig Type, targs []Type, ctxt *Con
7777
case *Named:
7878
tname := NewTypeName(pos, orig.obj.pkg, orig.obj.name, nil)
7979
named := check.newNamed(tname, orig, nil, nil, nil) // underlying, tparams, and methods are set when named is resolved
80-
named.targs = NewTypeList(targs)
80+
named.targs = newTypeList(targs)
8181
named.resolver = func(ctxt *Context, n *Named) (*TypeParamList, Type, []*Func) {
8282
return expandNamed(ctxt, n, pos)
8383
}

Diff for: src/go/types/typelists.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func (l *TypeParamList) list() []*TypeParam {
2929
// TypeList holds a list of types.
3030
type TypeList struct{ types []Type }
3131

32-
// NewTypeList returns a new TypeList with the types in list.
33-
func NewTypeList(list []Type) *TypeList {
32+
// newTypeList returns a new TypeList with the types in list.
33+
func newTypeList(list []Type) *TypeList {
3434
if len(list) == 0 {
3535
return nil
3636
}

Diff for: src/go/types/typexpr.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ func (check *Checker) instantiatedType(ix *typeparams.IndexExpr, def *Named) (re
427427
if inst == nil {
428428
tname := NewTypeName(ix.X.Pos(), orig.obj.pkg, orig.obj.name, nil)
429429
inst = check.newNamed(tname, orig, nil, nil, nil) // underlying, methods and tparams are set when named is resolved
430-
inst.targs = NewTypeList(targs)
430+
inst.targs = newTypeList(targs)
431431
inst = ctxt.update(h, orig, targs, inst).(*Named)
432432
}
433433
def.setUnderlying(inst)
@@ -441,7 +441,7 @@ func (check *Checker) instantiatedType(ix *typeparams.IndexExpr, def *Named) (re
441441
// be set to Typ[Invalid] in expandNamed.
442442
inferred = check.infer(ix.Orig, tparams, targs, nil, nil)
443443
if len(inferred) > len(targs) {
444-
inst.targs = NewTypeList(inferred)
444+
inst.targs = newTypeList(inferred)
445445
}
446446
}
447447

0 commit comments

Comments
 (0)