<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Sep 8, 2010, at 12:08 PM, Marcin Świderski wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">2010/9/8 Fariborz Jahanian <span dir="ltr"><<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <div><div></div><div class="h5"><br> On Sep 8, 2010, at 11:05 AM, Ted Kremenek wrote:<br> <br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> On Sep 8, 2010, at 2:01 AM, Marcin Świderski wrote:<br> <br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Hi All<br> <br> Is there a check implemented in Clang Checker (maybe not released for XCode yet) that would find errors like in example:<br> <br> @interface SomeClass : NSObject {<br>  NSMutableDictionary *_someObjects;<br> }<br> @end<br> <br> @implementation SomeClass<br> - (id)init {<br>  if ((self = [super init])) {<br>   _someObject = [NSMutableArray new];<br>  }<br>  return self;<br> }<br> @end<br> <br> Methods 'new' or 'init' return object of type 'id' by convention, but as I experienced it myself it can be unsafe.<br> <br> Cheers<br> Marcin<br> </blockquote> <br> This isn't implemented, but it would be a great check and would be really easy to do.<br> </blockquote></div></div> Problem with this is that this is very common form of assignments in objc and checker will get very noisy.<br> <br> - Fariborz<br> <br></blockquote><div>Maybe you missed the point: there's NSMutableArray object assigned to attribute of NSMutableDictionary type, and those types have completly different interfaces. If the programmer would realy want this, he could use attribute of type 'id' and live with possibility of runtime errors.</div></div></blockquote><div><br></div><div>So, this is more than just warn on assigning an 'id' expression to a static type. Checker should treat  [NSMutableArray new] specially and see how it gets used.</div><div>Thanks for the explanation.</div><div><br class="webkit-block-placeholder"></div><div>- Fariborz</div><div><br class="webkit-block-placeholder"></div><blockquote type="cite"><div class="gmail_quote"> <div><br></div></div></blockquote></div></body></html>