From a1886cc6ef994d8cd6f03dbca0aeaf949c568b0e Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 23 Oct 2013 13:26:23 -0700 Subject: [PATCH] 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 --- ssa/interp/value.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ssa/interp/value.go b/ssa/interp/value.go index 18bf9d50..1630b764 100644 --- a/ssa/interp/value.go +++ b/ssa/interp/value.go @@ -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 {