-
Notifications
You must be signed in to change notification settings - Fork 6k
Add strong qualifier to backgroundColor. #37761
Conversation
This is causing issue when -Wobjc-property-no-attribute is turned on. Since LLVM 3.1, strong has been the default value so this change is effectively a no-op, but improves readability. Similar to flutter#36929
Re #36929 generally properties with mutable variants, like
@cbracken is this the right spot? Line 68 in 965f87d
|
@@ -115,6 +115,6 @@ FLUTTER_DARWIN_EXPORT | |||
* } | |||
* ``` | |||
*/ | |||
@property(readwrite, nonatomic, nullable) NSColor* backgroundColor; | |||
@property(readwrite, nonatomic, nullable, strong) NSColor* backgroundColor; |
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.
Use copy
here rather than strong
.
@property(readwrite, nonatomic, nullable, strong) NSColor* backgroundColor; | |
@property(readwrite, nonatomic, nullable, copy) NSColor* backgroundColor; |
NSColor is immutable but there's no guarantee someone hasn't subclassed it. IIRC NSColor is actually a tagged pointer these days so yeah, this is probably inconsequential, but really copy is the right semantics to express.
@jmagman that is indeed the right spot (just above with the other warnings in Actually let me check -- normally we do warnings in buildroot. But can't remember if we have separate objc bits in there. One sec and I'll check. Checked; thinking about it we only want to apply to flutter not any third_party/ bits etc. Yes chuck it in there. There are a couple "-Werror=..." lines right above you can toss it in with. |
Did some playing around with this and this diagnostic is enabled by default in clang. We don't disable it in our build, and therefore it should already be enabled. You can see that it was enabled internally in cl/257817073 by removing the "-Wno-error=objc-property-no-attribute" option rather than by adding anything. I experimented with turning it on (and making it an error) but it had no effect. A bit of digging suggests that warning is disabled when ARC is enabled (the macOS embedder uses ARC): engine/shell/platform/darwin/macos/BUILD.gn Line 136 in f81ac3b
I'm assuming we're compiling with ARC enabled internally? I'd imagine we must be since otherwise |
I've sent out #37768 which adds explicit annotations to all the cases of I'm happy to enable the warning explicitly in that patch, but as I say, it should be enabled by default. We don't disable it externally, but enabling ARC via |
Thanks for taking on this Chris! I'll close this PR in favor of #37768 Regarding the flag, internally the warning behaves weird too, it only appeared when I was working on b/254864882. Once b/254864882 is completed, it would be great if we can catch the same warning here as well. |
This is causing issue when
-Wobjc-property-no-attribute
is turned on.Since LLVM 3.1, strong has been the default value so this change is effectively a no-op, but improves readability.
Similar to #36929, this is needed internally.
Also, can we consider enabling
-Wobjc-property-no-attribute
in the engine tree? I can do that if someone points me to where this is specified. ThanksPre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.