So to be more specific, I think you're asking why this code works:
https://gotipplay.golang.org/p/kuYzzx4EJY1

Sorry, I made a mistake in interpreting the spec.  It also says:

"The type set of the empty interface is the set of all types."

Therefore, the type set of the intersection { int; any } is int - and hence 
f[int] is allowed.

But the set of specific types 
<https://tip.golang.org/ref/spec#Structure_of_interfaces> is empty:

"An interface specification which contains type elements 
<https://tip.golang.org/ref/spec#Interface_types> defines a (possibly 
empty) set of *specific types*. Loosely speaking, these are the 
types T that appear in the interface definition in terms of the form T, ~T, 
or in unions of such terms."

The type set and the set of specific types can be different. Examples are 
given where one is empty and the other is non-empty:

interface{ int; m() } // *[specific type]* int (but type set is empty 
because int has no method m)
interface{ int; any } // no specific types (intersection is empty) *[even 
though the type set is not empty]*

*Items in [italics/brackets] are my additions*

-- 
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/9409fd01-632f-484e-a31e-e19dca080c47n%40googlegroups.com.

Reply via email to