Files
moxa/_test/issue-1166.go
Marc Vertes fc970799a1 interp: add support of interface wrappers to type assertions
Store the interpreter value of the interface object to wrap as
a field called IValue, at offset 0 in wrapper structures.

Update extract to include IValue field.

In typeAssert, detect interface wrapper, and dereference the
interpreter value from IValue wrapper field.

Fixes #1166.
2021-07-12 17:10:13 +02:00

25 lines
290 B
Go

package main
import (
"fmt"
"io"
)
type T []byte
func (t *T) Write(p []byte) (n int, err error) { *t = append(*t, p...); return len(p), nil }
func foo(w io.Writer) {
a := w.(*T)
fmt.Fprint(a, "test")
fmt.Printf("%s\n", *a)
}
func main() {
x := T{}
foo(&x)
}
// Output:
// test