title: Extending Protocols conforming to NSFetchRequestResult
body: <p>I am migrating my code to Swift 3 and I ran into an issue that I am not 100% sure about. </p>
  
  <p>As of WWDC 2016 the Core Data team updated their framework to be friendlier to generics and the new beefed up <code>NSFetchRequest</code> now returns objects that conform to the <code>NSFetchRequestResult</code>. </p>
  
  <p>So in the code below I have my base protocol that conforms to the said <code>NSFetchRequestResult</code> protocol, and in an extension of its child protocol <code>ManagedObjectFetchable</code> I want to return fetch objects of conforming types:</p>
  
  <pre><code>import CoreData
  
  @objc protocol ManagedObjectType: class, NSFetchRequestResult { }
  
  protocol ManagedObjectFetchable: ManagedObjectType { }
  
  extension ManagedObjectFetchable {
    static func preFetch(for predicate: Predicate, sortedBy sortDescriptors: [SortDescriptor]) throws -&gt; [Self] {
      let fetchRequest = NSFetchRequest&lt;Self&gt;(entityName: Self.entityName)
      fetchRequest.predicate = predicate
      fetchRequest.sortDescriptors = sortDescriptors
  
      let dummyContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
      return try dummyContext.fetch(fetchRequest)
    }
  }
  </code></pre>
  
  <p>The problem here is this line:</p>
  
  <pre><code>// Error: Binary operator '&lt;' cannot be applied to operands of type 'NSFetchRequest&lt;_&gt;.Type' and 'Self.Type'
  let fetchRequest = NSFetchRequest&lt;Self&gt;(entityName: Self.entityName)
  </code></pre>
  
  <p>It is a little confusing because I don't think this has anything to do with binary operators... Before I jump to the all too easy conclusion that it is a Swift bug I was wondering if anyone ran into similar issues.</p>
  
  <hr>
  
  <p>I am able to get around this using generics:</p>
  
  <pre><code>extension ManagedObjectFetchable {
    static func preFetch&lt;T: ManagedObjectFetchable&gt;(for predicate: Predicate, sortedBy sortDescriptors: [SortDescriptor]) throws -&gt; [T] {
      let fetchRequest = NSFetchRequest&lt;T&gt;(entityName: Self.entityName)
      fetchRequest.predicate = predicate
      fetchRequest.sortDescriptors = sortDescriptors
  
      let dummyContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
      return try dummyContext.fetch(fetchRequest)
    }
  }
  </code></pre>
  
  <p>This is what I am going with for now but I don't like not understanding why this would not work. If anyone could help enlighten this problem that would be awesome!</p>