go/types: remove unused scope parameter from NewSignature

Change-Id: I93c4185d7eeafde43b6b512b6e574d3332401c09
Reviewed-on: https://go-review.googlesource.com/10994
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2015-06-12 14:29:43 -07:00
parent 3c2fc37aec
commit 44761a8f84
4 changed files with 11 additions and 9 deletions

View File

@ -406,7 +406,7 @@ func (p *parser) parseNamedType(n int) types.Type {
results := p.parseResultList(pkg)
p.expect(';')
sig := types.NewSignature(nil, receiver, params, results, isVariadic)
sig := types.NewSignature(receiver, params, results, isVariadic)
nt.AddMethod(types.NewFunc(token.NoPos, pkg, name, sig))
}
@ -529,7 +529,7 @@ func (p *parser) parseResultList(pkg *types.Package) *types.Tuple {
func (p *parser) parseFunctionType(pkg *types.Package) *types.Signature {
params, isVariadic := p.parseParamList(pkg)
results := p.parseResultList(pkg)
return types.NewSignature(pkg.Scope(), nil, params, results, isVariadic)
return types.NewSignature(nil, params, results, isVariadic)
}
// Func = Name FunctionType .

View File

@ -589,7 +589,7 @@ func (p *parser) parseSignature(recv *types.Var) *types.Signature {
}
}
return types.NewSignature(nil, recv, types.NewTuple(params...), types.NewTuple(results...), isVariadic)
return types.NewSignature(recv, types.NewTuple(params...), types.NewTuple(results...), isVariadic)
}
// InterfaceType = "interface" "{" [ MethodList ] "}" .

View File

@ -382,7 +382,7 @@ func (p *importer) signature() *types.Signature {
if p.int() != 0 {
recv = p.param()
}
return types.NewSignature(nil, recv, p.tuple(), p.tuple(), p.int() != 0)
return types.NewSignature(recv, p.tuple(), p.tuple(), p.int() != 0)
}
func (p *importer) param() *types.Var {

View File

@ -196,7 +196,11 @@ func (t *Tuple) At(i int) *Var { return t.vars[i] }
// A Signature represents a (non-builtin) function or method type.
type Signature struct {
scope *Scope // function scope, always present
// We need to keep the scope in Signature (rather than passing it around
// and store it in the Func Object) because when type-checking a function
// literal we call the general type checker which returns a general Type.
// We then unpack the *Signature and use the scope for the literal body.
scope *Scope // function scope, present for package-local signatures
recv *Var // nil if not a method
params *Tuple // (incoming) parameters from left to right; or nil
results *Tuple // (outgoing) results from left to right; or nil
@ -207,9 +211,7 @@ type Signature struct {
// and results, either of which may be nil. If variadic is set, the function
// is variadic, it must have at least one parameter, and the last parameter
// must be of unnamed slice type.
func NewSignature(scope *Scope, recv *Var, params, results *Tuple, variadic bool) *Signature {
// TODO(gri) Should we rely on the correct (non-nil) incoming scope
// or should this function allocate and populate a scope?
func NewSignature(recv *Var, params, results *Tuple, variadic bool) *Signature {
if variadic {
n := params.Len()
if n == 0 {
@ -219,7 +221,7 @@ func NewSignature(scope *Scope, recv *Var, params, results *Tuple, variadic bool
panic("types.NewSignature: variadic parameter must be of unnamed slice type")
}
}
return &Signature{scope, recv, params, results, variadic}
return &Signature{nil, recv, params, results, variadic}
}
// Recv returns the receiver of signature s (if a method), or nil if a