mirror of
https://github.com/hanzoai/yaegi.git
synced 2026-10-01 00:49:47 +00:00
Wrap non empty interface value in struct field, to allow method lookup. Fixes #1208.
24 lines
309 B
Go
24 lines
309 B
Go
package main
|
|
|
|
type Enabler interface {
|
|
Enabled() bool
|
|
}
|
|
|
|
type Logger struct {
|
|
core Enabler
|
|
}
|
|
|
|
func (log *Logger) GetCore() Enabler { return log.core }
|
|
|
|
type T struct{}
|
|
|
|
func (t *T) Enabled() bool { return true }
|
|
|
|
func main() {
|
|
base := &Logger{&T{}}
|
|
println(base.GetCore().Enabled())
|
|
}
|
|
|
|
// Output:
|
|
// true
|