mirror of
https://github.com/traefik/yaegi.git
synced 2026-06-01 18:37:56 +00:00
This patch brings the following modifications: - consider that an interface is assignable to another if the former implements the latter - call TypeOf() method instead of rtype field when resolving methods, to handle first met types - unwrap error interface inplace rather than embedding it in an interface definition, as lower case named embbeded interface may not be handled by reflect when lookup for a method. Fixes #1063. Partially improves #1058.
24 lines
320 B
Go
24 lines
320 B
Go
package main
|
|
|
|
type Error interface {
|
|
error
|
|
Message() string
|
|
}
|
|
|
|
type T struct {
|
|
Msg string
|
|
}
|
|
|
|
func (t *T) Error() string { return t.Msg }
|
|
func (t *T) Message() string { return "message:" + t.Msg }
|
|
|
|
func newError() Error { return &T{"test"} }
|
|
|
|
func main() {
|
|
e := newError()
|
|
println(e.Error())
|
|
}
|
|
|
|
// Output:
|
|
// test
|