1
0
mirror of https://github.com/golang/go synced 2024-11-26 15:36:59 -07:00

[dev.typeparams] cmd/compile/internal/types2: return Universe for ((*Package)(nil)).Scope()

For #46594.

Change-Id: I53776cbdc1b8f6da511abe2c6659a7313d7a163a
Reviewed-on: https://go-review.googlesource.com/c/go/+/325469
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2021-06-05 21:23:48 -07:00
parent a5be3eaee2
commit c23294d6b3

View File

@ -48,7 +48,13 @@ func (pkg *Package) SetName(name string) { pkg.name = name }
// Scope returns the (complete or incomplete) package scope
// holding the objects declared at package level (TypeNames,
// Consts, Vars, and Funcs).
func (pkg *Package) Scope() *Scope { return pkg.scope }
// For a nil pkg receiver, Scope returns the Universe scope.
func (pkg *Package) Scope() *Scope {
if pkg != nil {
return pkg.scope
}
return Universe
}
// A package is complete if its scope contains (at least) all
// exported objects; otherwise it is incomplete.