From cd016af6b6bbbeeb1c14fea574914862a50c3ad6 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 25 Jun 2018 16:21:59 -0700 Subject: [PATCH] go/types: rename NewInterface2 to NewInterfaceType NewInterface2 was introduced with https://go-review.googlesource.com/114317 which fixed #25301. Changed the name to NewInterfaceType to better match Go naming styles, per discussion with @josharian, @iant, et al. Change-Id: Ifa4708a5efd4f708295b33c3d20fdc5812e1b4fc Reviewed-on: https://go-review.googlesource.com/120875 Reviewed-by: Josh Bleecher Snyder Reviewed-by: Ian Lance Taylor --- api/go1.11.txt | 2 +- src/go/internal/gccgoimporter/parser.go | 2 +- src/go/internal/gcimporter/bimport.go | 2 +- src/go/internal/gcimporter/iimport.go | 2 +- src/go/types/type.go | 16 +++++++-------- src/go/types/typestring_test.go | 26 ++++++++++++------------- src/go/types/universe.go | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/api/go1.11.txt b/api/go1.11.txt index 1c641eac51e..d474cf0e8d1 100644 --- a/api/go1.11.txt +++ b/api/go1.11.txt @@ -437,7 +437,7 @@ pkg debug/pe, const IMAGE_FILE_MACHINE_ARM64 = 43620 pkg debug/pe, const IMAGE_FILE_MACHINE_ARM64 ideal-int pkg go/ast, type CompositeLit struct, Incomplete bool pkg go/token, method (*File) AddLineColumnInfo(int, string, int, int) -pkg go/types, func NewInterface2([]*Func, []Type) *Interface +pkg go/types, func NewInterfaceType([]*Func, []Type) *Interface pkg go/types, method (*Interface) EmbeddedType(int) Type pkg go/types, method (*Var) Embedded() bool pkg net, method (*ListenConfig) Listen(context.Context, string, string) (Listener, error) diff --git a/src/go/internal/gccgoimporter/parser.go b/src/go/internal/gccgoimporter/parser.go index 5e3c31745c3..9f8c19b6388 100644 --- a/src/go/internal/gccgoimporter/parser.go +++ b/src/go/internal/gccgoimporter/parser.go @@ -600,7 +600,7 @@ func (p *parser) parseInterfaceType(pkg *types.Package) types.Type { } p.expect('}') - return types.NewInterface2(methods, embeddeds) + return types.NewInterfaceType(methods, embeddeds) } // PointerType = "*" ("any" | Type) . diff --git a/src/go/internal/gcimporter/bimport.go b/src/go/internal/gcimporter/bimport.go index 503845e31cb..4e3023b906e 100644 --- a/src/go/internal/gcimporter/bimport.go +++ b/src/go/internal/gcimporter/bimport.go @@ -536,7 +536,7 @@ func (p *importer) typ(parent *types.Package, tname *types.Named) types.Type { embeddeds = append(embeddeds, p.typ(parent, nil)) } - t := types.NewInterface2(p.methodList(parent, tname), embeddeds) + t := types.NewInterfaceType(p.methodList(parent, tname), embeddeds) p.interfaceList = append(p.interfaceList, t) if p.trackAllTypes { p.typList[n] = t diff --git a/src/go/internal/gcimporter/iimport.go b/src/go/internal/gcimporter/iimport.go index a333f98f3a0..bf480641df9 100644 --- a/src/go/internal/gcimporter/iimport.go +++ b/src/go/internal/gcimporter/iimport.go @@ -535,7 +535,7 @@ func (r *importReader) doType(base *types.Named) types.Type { methods[i] = types.NewFunc(mpos, r.currPkg, mname, msig) } - typ := types.NewInterface2(methods, embeddeds) + typ := types.NewInterfaceType(methods, embeddeds) r.p.interfaceList = append(r.p.interfaceList, typ) return typ } diff --git a/src/go/types/type.go b/src/go/types/type.go index 60e3efaec31..d9399a6587c 100644 --- a/src/go/types/type.go +++ b/src/go/types/type.go @@ -260,7 +260,7 @@ var markComplete = make([]*Func, 0) // NewInterface takes ownership of the provided methods and may modify their types by setting // missing receivers. To compute the method set of the interface, Complete must be called. // -// Deprecated: Use NewInterface2 instead which allows any (even non-defined) interface types +// Deprecated: Use NewInterfaceType instead which allows any (even non-defined) interface types // to be embedded. This is necessary for interfaces that embed alias type names referring to // non-defined (literal) interface types. func NewInterface(methods []*Func, embeddeds []*Named) *Interface { @@ -268,16 +268,16 @@ func NewInterface(methods []*Func, embeddeds []*Named) *Interface { for i, t := range embeddeds { tnames[i] = t } - return NewInterface2(methods, tnames) + return NewInterfaceType(methods, tnames) } -// NewInterface2 returns a new (incomplete) interface for the given methods and embedded types. +// NewInterfaceType returns a new (incomplete) interface for the given methods and embedded types. // Each embedded type must have an underlying type of interface type (this property is not // verified for defined types, which may be in the process of being set up and which don't // have a valid underlying type yet). -// NewInterface2 takes ownership of the provided methods and may modify their types by setting +// NewInterfaceType takes ownership of the provided methods and may modify their types by setting // missing receivers. To compute the method set of the interface, Complete must be called. -func NewInterface2(methods []*Func, embeddeds []Type) *Interface { +func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface { typ := new(Interface) if len(methods) == 0 && len(embeddeds) == 0 { @@ -344,9 +344,9 @@ func (t *Interface) Method(i int) *Func { return t.allMethods[i] } func (t *Interface) Empty() bool { return len(t.allMethods) == 0 } // Complete computes the interface's method set. It must be called by users of -// NewInterface after the interface's embedded types are fully defined and -// before using the interface type in any way other than to form other types. -// Complete returns the receiver. +// NewInterfaceType and NewInterface after the interface's embedded types are +// fully defined and before using the interface type in any way other than to +// form other types. Complete returns the receiver. func (t *Interface) Complete() *Interface { if t.allMethods != nil { return t diff --git a/src/go/types/typestring_test.go b/src/go/types/typestring_test.go index 6ed2d75dfe3..0efb7f0013f 100644 --- a/src/go/types/typestring_test.go +++ b/src/go/types/typestring_test.go @@ -162,19 +162,19 @@ func TestIncompleteInterfaces(t *testing.T) { {NewInterface(nil, []*Named{newDefined(NewInterface([]*Func{m}, nil).Complete())}), "interface{T /* incomplete */}"}, {NewInterface(nil, []*Named{newDefined(NewInterface([]*Func{m}, nil).Complete())}).Complete(), "interface{T}"}, - {NewInterface2(nil, nil), "interface{/* incomplete */}"}, - {NewInterface2(nil, nil).Complete(), "interface{}"}, - {NewInterface2([]*Func{}, nil), "interface{/* incomplete */}"}, - {NewInterface2([]*Func{}, nil).Complete(), "interface{}"}, - {NewInterface2(nil, []Type{}), "interface{/* incomplete */}"}, - {NewInterface2(nil, []Type{}).Complete(), "interface{}"}, - {NewInterface2([]*Func{m}, nil), "interface{m() /* incomplete */}"}, - {NewInterface2([]*Func{m}, nil).Complete(), "interface{m()}"}, - {NewInterface2(nil, []Type{new(Interface).Complete()}), "interface{interface{} /* incomplete */}"}, - {NewInterface2(nil, []Type{new(Interface).Complete()}).Complete(), "interface{interface{}}"}, - {NewInterface2(nil, []Type{NewInterface2([]*Func{m}, nil)}), "interface{interface{m() /* incomplete */} /* incomplete */}"}, - {NewInterface2(nil, []Type{NewInterface2([]*Func{m}, nil).Complete()}), "interface{interface{m()} /* incomplete */}"}, - {NewInterface2(nil, []Type{NewInterface2([]*Func{m}, nil).Complete()}).Complete(), "interface{interface{m()}}"}, + {NewInterfaceType(nil, nil), "interface{/* incomplete */}"}, + {NewInterfaceType(nil, nil).Complete(), "interface{}"}, + {NewInterfaceType([]*Func{}, nil), "interface{/* incomplete */}"}, + {NewInterfaceType([]*Func{}, nil).Complete(), "interface{}"}, + {NewInterfaceType(nil, []Type{}), "interface{/* incomplete */}"}, + {NewInterfaceType(nil, []Type{}).Complete(), "interface{}"}, + {NewInterfaceType([]*Func{m}, nil), "interface{m() /* incomplete */}"}, + {NewInterfaceType([]*Func{m}, nil).Complete(), "interface{m()}"}, + {NewInterfaceType(nil, []Type{new(Interface).Complete()}), "interface{interface{} /* incomplete */}"}, + {NewInterfaceType(nil, []Type{new(Interface).Complete()}).Complete(), "interface{interface{}}"}, + {NewInterfaceType(nil, []Type{NewInterfaceType([]*Func{m}, nil)}), "interface{interface{m() /* incomplete */} /* incomplete */}"}, + {NewInterfaceType(nil, []Type{NewInterfaceType([]*Func{m}, nil).Complete()}), "interface{interface{m()} /* incomplete */}"}, + {NewInterfaceType(nil, []Type{NewInterfaceType([]*Func{m}, nil).Complete()}).Complete(), "interface{interface{m()}}"}, } { got := test.typ.String() if got != test.want { diff --git a/src/go/types/universe.go b/src/go/types/universe.go index 2ae8a319707..7af6dab320e 100644 --- a/src/go/types/universe.go +++ b/src/go/types/universe.go @@ -80,7 +80,7 @@ func defPredeclaredTypes() { res := NewVar(token.NoPos, nil, "", Typ[String]) sig := &Signature{results: NewTuple(res)} err := NewFunc(token.NoPos, nil, "Error", sig) - typ := &Named{underlying: NewInterface2([]*Func{err}, nil).Complete()} + typ := &Named{underlying: NewInterfaceType([]*Func{err}, nil).Complete()} sig.recv = NewVar(token.NoPos, nil, "", typ) def(NewTypeName(token.NoPos, nil, "error", typ)) }