mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
go/types, types2: shorten object map assertion
It's a fairly well-known invariant that each object must exist in the object map and cannot be nil. This change just shortens a check of that invariant. Change-Id: Id15c158c3a9ad91cdc230fb0b84eb69b2451cbdc Reviewed-on: https://go-review.googlesource.com/c/go/+/722061 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mark Freeman <markfreeman@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
02d1f3a06b
commit
e704b0993b
2 changed files with 4 additions and 10 deletions
|
|
@ -133,11 +133,8 @@ func (check *Checker) objDecl(obj Object, def *TypeName) {
|
|||
check.push(obj)
|
||||
defer check.pop()
|
||||
|
||||
d := check.objMap[obj]
|
||||
if d == nil {
|
||||
check.dump("%v: %s should have been declared", obj.Pos(), obj)
|
||||
panic("unreachable")
|
||||
}
|
||||
d, ok := check.objMap[obj]
|
||||
assert(ok)
|
||||
|
||||
// save/restore current environment and set up object environment
|
||||
defer func(env environment) {
|
||||
|
|
|
|||
|
|
@ -134,11 +134,8 @@ func (check *Checker) objDecl(obj Object, def *TypeName) {
|
|||
check.push(obj) // mark as grey
|
||||
defer check.pop()
|
||||
|
||||
d := check.objMap[obj]
|
||||
if d == nil {
|
||||
check.dump("%v: %s should have been declared", obj.Pos(), obj)
|
||||
panic("unreachable")
|
||||
}
|
||||
d, ok := check.objMap[obj]
|
||||
assert(ok)
|
||||
|
||||
// save/restore current environment and set up object environment
|
||||
defer func(env environment) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue