File tree 6 files changed +10
-6
lines changed
cmd/compile/internal/types2
6 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -389,6 +389,8 @@ func (obj *Func) FullName() string {
389
389
}
390
390
391
391
// Scope returns the scope of the function's body block.
392
+ // The result is nil for imported or instantiated functions and methods
393
+ // (but there is also no mechanism to get to an instantiated function).
392
394
func (obj * Func ) Scope () * Scope { return obj .typ .(* Signature ).scope }
393
395
394
396
// hasPtrRecv reports whether the receiver is of the form *T for the given method obj.
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ type Signature struct {
18
18
// We then unpack the *Signature and use the scope for the literal body.
19
19
rparams * TypeParamList // receiver type parameters from left to right, or nil
20
20
tparams * TypeParamList // type parameters from left to right, or nil
21
- scope * Scope // function scope, present for package-local signatures
21
+ scope * Scope // function scope for package-local and non-instantiated signatures; nil otherwise
22
22
recv * Var // nil if not a method
23
23
params * Tuple // (incoming) parameters from left to right; or nil
24
24
results * Tuple // (outgoing) results from left to right; or nil
Original file line number Diff line number Diff line change @@ -115,8 +115,8 @@ func (subst *subster) typ(typ Type) Type {
115
115
return & Signature {
116
116
rparams : t .rparams ,
117
117
// TODO(gri) why can't we nil out tparams here, rather than in instantiate?
118
- tparams : t .tparams ,
119
- scope : t . scope ,
118
+ tparams : t .tparams ,
119
+ // instantiated signatures have a nil scope
120
120
recv : recv ,
121
121
params : params ,
122
122
results : results ,
Original file line number Diff line number Diff line change @@ -343,6 +343,8 @@ func (obj *Func) FullName() string {
343
343
}
344
344
345
345
// Scope returns the scope of the function's body block.
346
+ // The result is nil for imported or instantiated functions and methods
347
+ // (but there is also no mechanism to get to an instantiated function).
346
348
func (obj * Func ) Scope () * Scope { return obj .typ .(* Signature ).scope }
347
349
348
350
// hasPtrRecv reports whether the receiver is of the form *T for the given method obj.
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ type Signature struct {
21
21
// We then unpack the *Signature and use the scope for the literal body.
22
22
rparams * TypeParamList // receiver type parameters from left to right, or nil
23
23
tparams * TypeParamList // type parameters from left to right, or nil
24
- scope * Scope // function scope, present for package-local signatures
24
+ scope * Scope // function scope for package-local and non-instantiated signatures; nil otherwise
25
25
recv * Var // nil if not a method
26
26
params * Tuple // (incoming) parameters from left to right; or nil
27
27
results * Tuple // (outgoing) results from left to right; or nil
Original file line number Diff line number Diff line change @@ -115,8 +115,8 @@ func (subst *subster) typ(typ Type) Type {
115
115
return & Signature {
116
116
rparams : t .rparams ,
117
117
// TODO(rFindley) why can't we nil out tparams here, rather than in instantiate?
118
- tparams : t .tparams ,
119
- scope : t . scope ,
118
+ tparams : t .tparams ,
119
+ // instantiated signatures have a nil scope
120
120
recv : recv ,
121
121
params : params ,
122
122
results : results ,
You can’t perform that action at this time.
0 commit comments