You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
type Sub struct {}
type ISub interface {}
type Base struct {
sub *Sub
}
type IBase interface {
Sub() ISub
}
func (b *Base) Sub() *Sub {
return b.sub
}
func main() {
var s *Sub
s = &Sub{}
var si ISub
si = s
var b IBase
b = &Base{sub:s}
}
./prog.go:25:4: cannot use &Base literal (type *Base) as type IBase in assignment:
*Base does not implement IBase (wrong type for Sub method)
have Sub() *Sub
want Sub() ISub
The text was updated successfully, but these errors were encountered:
It is inconvenient.
The text was updated successfully, but these errors were encountered: