-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[alpha.webkit.NoUnretainedMemberChecker] Only check @property when @implementation is seen #159947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e369e9c
ffa520f
6d70f15
c4bd06b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,7 +113,23 @@ @interface AnotherObject : NSObject { | |
| // expected-warning@-1{{Instance variable 'dispatch' in 'AnotherObject' is a retainable type 'dispatch_queue_t'}} | ||
| } | ||
| @property(nonatomic, strong) NSString *prop_string; | ||
| // expected-warning@-1{{Property 'prop_string' in 'AnotherObject' is a raw pointer to retainable type 'NSString'}} | ||
| // expected-warning@-1{{Property 'prop_string' in 'AnotherObject' is a raw pointer to retainable type 'NSString'; member variables must be a RetainPtr}} | ||
| @property(nonatomic, readonly) NSString *prop_safe; | ||
| @end | ||
|
|
||
| @implementation AnotherObject | ||
| - (NSString *)prop_safe { | ||
| return nil; | ||
| } | ||
| @end | ||
|
|
||
| // No warnings for @interface declaration itself. | ||
| @interface InterfaceOnlyObject : NSObject | ||
| @property(nonatomic, strong) NSString *prop_string1; | ||
| @property(nonatomic, assign) NSString *prop_string2; | ||
| @property(nonatomic, unsafe_unretained) NSString *prop_string3; | ||
| @property(nonatomic, readonly) NSString *prop_string4; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the expected behavior for inherited interfaces that have an implementation? For example:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They should behave no different from non-inherited interfaces. We'd check
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added some test cases for this. |
||
| @end | ||
|
|
||
| NS_REQUIRES_PROPERTY_DEFINITIONS | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, what if we have a derived interface (with an implementation) that derives from
InterfaceOnlyObject? Is the expectation then that the checker reports warnings on these properties (because the derived interface's implementation can access these properties viaself)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, we should be checking each property, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I think we have a bug there. We're not checking superclass's properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, that's not really a bug since we don't auto-synthesize a property on a superclass. I added one more test case to test this exact scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the explanation and the additional test cases.