diff --git a/src/runtime/iface.go b/src/runtime/iface.go index 243e51fc480..05de282aa75 100644 --- a/src/runtime/iface.go +++ b/src/runtime/iface.go @@ -66,6 +66,12 @@ func getitab(inter *interfacetype, typ *_type, canfail bool) *itab { m = (*itab)(persistentalloc(unsafe.Sizeof(itab{})+uintptr(len(inter.mhdr)-1)*sys.PtrSize, 0, &memstats.other_sys)) m.inter = inter m._type = typ + // The hash is used in type switches. However, compiler statically generates itab's + // for all interface/type pairs used in switches (which are added to itabTable + // in itabsinit). The dynamically-generated itab's never participate in type switches, + // and thus the hash is irrelevant. + // Note: m.hash is _not_ the hash used for the runtime itabTable hash table. + m.hash = 0 m.init() itabAdd(m) unlock(&itabLock) @@ -233,7 +239,6 @@ imethods: return iname } m.fun[0] = uintptr(fun0) - m.hash = typ.hash return "" }