mirror of
https://github.com/golang/go.git
synced 2026-02-02 09:02:05 +03: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:
committed by
Gopher Robot
parent
02d1f3a06b
commit
e704b0993b
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user