Wrong error message is displayed for managedObjectContext.fetch()

Originator:danny
Number:rdar://28565083 Date Originated:30-Sep-2016
Status:Open Resolved:
Product:Developer Tools Product Version:8
Classification: Reproducible:Always
 
Summary:
The error "Cannot invoke 'fetch' with an argument list of type '(NSFetchRequest<NSFetchRequestResult>)' Expected an argument list of type '(NSFetchRequest<NSFetchRequestResult>)'" is displayed for the following code:

func objects(entityName name:String)->[NSManagedObject]? {   
  let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName:name)
  var objects: [NSManagedObject]?
  do {
    objects = try managedObjectContext.fetch(fetchRequest)
  } catch { ... }
}


This is the incorrect error for line 5

Steps to Reproduce:
1. Write the above Swift 3 code.
2. Attempt to compile
3. Receive the error

Expected Results:
The correct error should state that managedObjectContext.fetch() returns [Any], which needs a downcast to be assigned to [NSManagedObject]?

The correct code is objects = try managedObjectContext.fetch(fetchRequest) as? [NSManagedObject]

Actual Results:
XCode displays the following error:
Cannot invoke 'fetch' with an argument list of type '(NSFetchRequest<NSFetchRequestResult>)' Expected an argument list of type '(NSFetchRequest<NSFetchRequestResult>)'

Version:
XCode Version 8.0 (8A218a)
OS X 10.11.6 (15G1004)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!