[swift-evolution] specialize a generic type in a method

Vladimir.S svabox at gmail.com
Mon Jun 20 11:57:00 CDT 2016

Should we be able to specialize a generic type in a method, if that generic 
type declared in type's definition like here? :

struct Foo<I> {
     func bar(i: I) where I: Equatable { } // should this work?

As I understand, for concrete instance of foo: Foo<X>, if X is not 
Equatable, then compiler should prevent us from calling foo.bar(x)

Or, probably, the better way to express this could be :

     func bar(i: I & Equatable) { }
     func bar(i: Any<I, Equatable>) { }

Can't check if it possible now because my compiler crashes because of 
'where I:Equatable' text (submitted to bugs.swift.org)

More information about the swift-evolution mailing list