1
0
mirror of https://github.com/golang/go synced 2024-10-01 07:28:35 -06:00

go/tools/ssa/interp: make iface.eq robust against nil types

A future version of go/types.IsIdentical does not accept
nil types anymore.

R=adonovan
CC=golang-dev
https://golang.org/cl/16150043
This commit is contained in:
Robert Griesemer 2013-10-23 13:26:23 -07:00
parent 36c288d6d7
commit a1886cc6ef

View File

@ -169,9 +169,17 @@ func (x structure) hash(t types.Type) int {
return h
}
// nil-tolerant variant of types.IsIdentical.
func sameType(x, y types.Type) bool {
if x == nil {
return y == nil
}
return y != nil && types.IsIdentical(x, y)
}
func (x iface) eq(t types.Type, _y interface{}) bool {
y := _y.(iface)
return types.IsIdentical(x.t, y.t) && (x.t == nil || equals(x.t, x.v, y.v))
return sameType(x.t, y.t) && (x.t == nil || equals(x.t, x.v, y.v))
}
func (x iface) hash(_ types.Type) int {