interp: fix type check of methods with a receiver of interface kind

Fixes #1280.
This commit is contained in:
Marc Vertes
2021-10-08 17:44:09 +02:00
committed by GitHub
parent e56db3b82e
commit 5bf4daef2d
2 changed files with 31 additions and 1 deletions

30
_test/issue-1280.go Normal file
View File

@@ -0,0 +1,30 @@
package main
import (
"io"
"log"
"os"
)
type DBReader interface {
io.ReadCloser
io.ReaderAt
}
type DB struct {
f DBReader
}
func main() {
f, err := os.Open("/dev/null")
if err != nil {
log.Fatal(err)
}
d := &DB{f}
data := make([]byte, 1)
_, _ = d.f.ReadAt(data, 0)
println("bye")
}
// Output:
// bye

View File

@@ -1071,7 +1071,7 @@ func (t *itype) in(i int) *itype {
return t.arg[i]
case valueT:
if t.rtype.Kind() == reflect.Func {
if t.recv != nil {
if t.recv != nil && !isInterface(t.recv) {
i++
}
if t.rtype.IsVariadic() && i == t.rtype.NumIn()-1 {