title: Protocol 'xxx' can only be used as a generic constraint because it has Self or associated type requirements
body: <p>I want to create a custom <code>UITableView</code>, with custom delegate/dataSource methods. I would also like to pass the type of the data source when doing so. Here is what I tried:</p>
  
  <pre><code>struct TestModel {
      var name: String
  }
  
  protocol TestTableViewDelegate: UITableViewDelegate {    
      associatedtype CellModel        
      func cell(model: CellModel, path: IndexPath) -&gt; UITableViewCell        
  }
  
  class TestTableView: UITableView {        
      var testDelegate: TestTableViewDelegate?        
  }
  
  class VCTest: UIViewController, TestTableViewDelegate {       
  
      typealias CellModel = TestModel    
      var t: TestTableView!
  
      override func viewDidLoad() {
          t.testDelegate = self
      }
  
      func cell(model: TestModel, path: IndexPath) -&gt; UITableViewCell {
          return UITableViewCell()
      }
  
  }
  </code></pre>
  
  <p>I'm getting an error at the <code>testDelegate</code> declaration line:</p>
  
  <blockquote>
    <p>Protocol 'TestTableViewDelegate' can only be used as a generic constraint because it has Self or associated type requirements</p>
  </blockquote>
  
  <p>I don't really understand what's going on here. What does this mean and how could I solve it?</p>
  
  <p>Thank your for your help.</p>