[cfe-dev] [PATCH]es: Objective-C lightweight generics

Douglas Gregor dgregor at apple.com
Wed Jul 8 09:05:18 PDT 2015


> On Jul 8, 2015, at 12:29 AM, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:
> 
> On 7 Jul 2015, at 17:28, Douglas Gregor <dgregor at apple.com> wrote:
>> 
>>> Would there be interest in a compilation mode that inserted run-time checks for these cases?  We discussed previously doing it on every down cast and cast-from-id in Objective-C, but came to the conclusion that the false positive rate would be too high.  For generics, I suspect that people either want to not break the rules, or will just use the non-generic version.
>> 
>> My general impression here is that people will still want to break the rules, e.g., by continuing to use proxies that don't properly implement -isKindOfClass:, so I’ve not pursued this.
> 
> My thought was that it would behave in the same way as some of the other non-fatal errors in Objective-C, printing a message along the lines of “*** Cast from Foo to Bar disallowed by generics.  Put breakpoint on objc_generics_whatever() to debug”.  You’d turn this off in production, but when debugging (-fsanitize=objc-generics?) you’d be able to catch it early.

Yes, I absolutely agree that this could be useful for finding such problems. And perhaps my concerns about the prevalence of proxies not overriding -isKindOfClass: properly are overblown… only an experimental implementation can tell :)

	- Doug






More information about the cfe-dev mailing list