Is Go type parameter supports interface union? 

My case
type MessageSpec interface { MessageA | MessageB }
type MessageA interface { ID() uint64 }
type MessageB interface { Uid() uint64 }

but got compile error:
./prog.go:14:2: cannot use main.MessageA in union (main.MessageA contains 
methods) ./prog.go:14:13: cannot use main.MessageB in union (main.MessageB 
contains methods)

I tried to look for documentation and readed 
https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#interface-types-in-union-elements

There's example 
> type Stringish interface { string | fmt.Stringer }

but it also throwing error
> ./prog.go:19:11: cannot use fmt.Stringer in union (fmt.Stringer contains 
methods)

Is this a bug? i know my case is not the same thing as like the one i 
referenced from the proposal
but it is throwing the same error. 
Thanks 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4b0e90b7-ef7e-4b6f-a319-1392f3fc884cn%40googlegroups.com.

Reply via email to