Add lightweight generics to NSCompoundPredicate's subpredicates property

Originator:KevinRLundberg
Number:rdar://23894694 Date Originated:14-Dec-2015
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:Always
 
Summary:
According to the headers, and to apple's documentation, the subpredicates property in NSCompoundPredicate is an untyped NSArray. Since it is only ever the case that this property can be assigned from the initializers of this class, this property should also change to be of type NSArray<NSPredicate *> *.

There is a swift compiler bug exposed by this choice of type for this property: https://bugs.swift.org/browse/SR-204?jql= which causes the compiler to crash when trying to build this pull request submitted against swift-corelibs-foundation: https://github.com/apple/swift-corelibs-foundation/pull/127. Changing the property there from [AnyObject] to [NSPredicate] will avoid the compiler crash (which should be fixed regardless), but this is another reason to make this change in Foundation on Apple's platforms in order to keep the APIs in sync.

Steps to Reproduce:
open a playground using Xcode 7.2

View the NSCompoundPredicate header

Also: Open a playground

paste this line into it:
let pred = NSCompoundPredicate(andPredicateWithSubpredicates:[]).subpredicates

option-click on pred to see it's typed as [AnyObject], not [NSPredicate]

Expected Results:
NSCompoundPredicate.subpredicates should be NSArray<NSPredicate *> *

Actual Results:
NSCompoundPredicate.subpredicates is NSArray * with no generic info

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!