title: Error using Self in generic function where clause
body: <p>I am running into an issue when I try to use <code>Self</code> as part of a <code>where</code> clause in a generic function which is part of a protocol.</p>
  
  <p>For example, say I have this protocol and this generic function defined:</p>
  
  <pre><code>protocol Animal {
      associatedtype FoodSource
      func eat(_ food:FoodSource)
  }
  
  // The where clause specifies that T2 must conform to
  // whatever type is T1's FoodSource associated type 
  func feed&lt;T1: Animal, T2&gt;(animal:T1, food:T2) where T2 == T1.FoodSource {
      animal.eat(food)
  }
  </code></pre>
  
  <p>The function Feed uses the bracketed statement to declare that the first parameter must conform to the <code>Animal</code> protocol.  It uses the <code>where</code> clause to declare that the second parameter's type must conform to the associated type of the first parameter.</p>
  
  <p>It's possible to create classes which conform to this generic function's requirements and everything works perfectly.  For example:</p>
  
  <pre><code>protocol Meat {}
  protocol Vegetable {}
  
  class Rabbit : Animal {
      typealias FoodSource = Vegetable
      func eat(_ food:FoodSource) {
          print("the Rabbit ate the \(type(of:food))")
      }
  }
  
  class Lion : Animal {
      typealias FoodSource = Meat
      func eat(_ food:FoodSource) {
          print("the Lion ate the \(type(of:food))")
      }
  }
  
  class Carrot : Vegetable {}
  class Steak : Meat {}
  class ChickenSalad : Meat, Vegetable {}
  
  // works because Carrot conforms to Vegetable
  // prints: "the Rabbit ate the Carrot"
  feed(animal: Rabbit(), food: Carrot())
  
  // works because Steak conforms to Meat
  // prints: "the Lion ate the Steak"
  feed(animal: Lion(), food: Steak())
  
  // works because ChickenSalad conforms to Meat
  // prints: "the Lion ate the ChickenSalad"
  feed(animal: Lion(), food: ChickenSalad())
  
  // works because ChickenSalad conforms to Vegetable
  // prints: "the Rabbit ate the ChickenSalad"
  feed(animal: Rabbit(), food: ChickenSalad())
  </code></pre>
  
  <p>So far so good.</p>
  
  <p>However, when I implement the same pattern of generics as part of a protocol, it no longer works:</p>
  
  <pre><code>protocol Food {
      func feed&lt;T:Animal&gt;(to:T) where Self == T.FoodSource
  }
  
  extension Food {
      func feed&lt;T:Animal&gt;(to animal:T) where Self == T.FoodSource {
          animal.eat(self)
      }
  }
  
  class SteakSalad : Food, Meat, Vegetable {}
  
  SteakSalad().feed(to: Lion())
  </code></pre>
  
  <p>When executed, this block throws the following error: </p>
  
  <pre><code>error: generic parameter 'T' could not be inferred
  SteakSalad().feed(to: Lion())
               ^
  </code></pre>
  
  <p>Is there some way to achieve the desired behavior?</p>