Attempting to use a Type List in an Interface 
<https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#type-lists-in-interface-types>
 
to restrict the types allowed to instantiate a generic function (example in 
go2go <https://go2goplay.golang.org/p/BuJZv_-VQXh>).  The Type List within 
the Constraint Interface (Santa) contains only one struct type 
<https://golang.org/ref/spec#Struct_types> (SantaSad).  This struct type 
and a second, independent struct type (SantaHappy) both implement the 
Constraint Interface (Santa) specified as a type parameter for the generic 
function.  Given this situation, I expected the instantiation of the 
generic function with a type argument of the type (SantaSad), that appears 
in the Constraint's Interface Type List to succeed, which it does, and 
instantiating the generic function with the struct type, absent from the 
Type List (SantaHappy), to fail.  However, instead of failing, this second 
case succeeds.  Is this the intended behavior?


-- 
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/44b6cb78-d143-437f-b4e0-f1cf8d642989n%40googlegroups.com.

Reply via email to