interp: fix detection of binary types implementing interfaces

Fixes #1136.
This commit is contained in:
Marc Vertes
2021-06-11 17:58:11 +02:00
committed by GitHub
parent b19afbfe93
commit b1ef9251d4
2 changed files with 24 additions and 1 deletions

View File

@@ -1558,7 +1558,7 @@ func (t *itype) frameType() (r reflect.Type) {
}
func (t *itype) implements(it *itype) bool {
if t.cat == valueT {
if isBin(t) {
return t.TypeOf().Implements(it.TypeOf())
}
return t.methods().contains(it.methods())
@@ -1730,6 +1730,17 @@ func isInterface(t *itype) bool {
return isInterfaceSrc(t) || t.TypeOf() != nil && t.TypeOf().Kind() == reflect.Interface
}
func isBin(t *itype) bool {
switch t.cat {
case valueT:
return true
case aliasT, ptrT:
return isBin(t.val)
default:
return false
}
}
func isStruct(t *itype) bool {
// Test first for a struct category, because a recursive interpreter struct may be
// represented by an interface{} at reflect level.