On Thu, Jul 11, 2013 at 9:48 AM, Fariborz Jahanian <[email protected]> wrote:
>  @interface Fail @end
>  @protocol X @end
>  @implementation Fail
> -- (id<X>) initWithX
> +- (id<X>) initWithX // expected-note {{compiler has implicitly changed 
> method 'initWithX' return type}}
>  {
> -  return (id)self; // expected-warning {{casting 'Fail *' to incompatible 
> type 'id<X>'}}
> +  return (id)self; // expected-warning {{returning 'Fail *' from a function 
> with incompatible result type 'id<X>'}}
>  }
>  @end

FWIW, I don't understand these new diagnostics at all. I understand
that with ARC the return type of initWithX must be (Fail*), not
(id<X>); but if the compiler has indeed "implicitly changed [the]
return type" to (Fail*), then why is it complaining so loudly about
the correct "return" statement? [Under ARC, it's always valid to
return "self" from an init method.] Or, if the compiler did NOT change
initWithX's return type, then why is it saying it did?

> +@implementation UIViewController
> ++ (UIViewController<PMFilterManager> *)newFilterViewControllerForType // 
> expected-note {{compiler has implicitly changed method 
> 'newFilterViewControllerForType' return type}}
> +{
> +        UIViewController<PMFilterManager> *filterVC;
> +        return filterVC; // expected-warning {{incompatible pointer types 
> returning 'UIViewController *' from a function with result type 
> 'UIViewController<PMFilterManager> *'}}
> +}
> +@end

These diagnostics just look wrong. UIViewController's
newFilterViewControllerForType method is expected by ARC to return
(UIViewController*), and in fact that's how it's prototyped (with the
addition of an extra protocol, which doesn't hurt anything). And in
fact its return statement returns an expression of type
(UIViewController<PMFilterManager>*), which is implicitly convertible
to (UIViewController*). So these diagnostics are just confusing and
useless; there's no error here to diagnose.

Thoughts?
-Arthur
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to