[swift-evolution] [Review #2] SE-0160: Limiting @objc inference

Douglas Gregor dgregor at apple.com
Wed Apr 5 10:56:38 CDT 2017



Sent from my iPhone

> On Apr 5, 2017, at 1:19 AM, Víctor Pimentel <vpimentel at tuenti.com> wrote:
> 
> 
> 
> Enviado desde mi iPhone
> El 4 abr 2017, a las 22:04, Douglas Gregor <dgregor at apple.com> escribió:
> 
>> 
>>> On Apr 4, 2017, at 12:31 PM, Víctor Pimentel Rodríguez via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> Sorry to be late :/
>>> 
>>>> On Fri, Mar 31, 2017 at 5:29 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>>>> * What is your evaluation of the proposal?
>>> 
>>> More positive than the first one, but still some rough edges.
>>> 
>>> One concern that I still have is that if we use @objcMembers, @nonobjc methods/properties are going to be even trickier to find.
>>> 
>>> If such modifier existed, I would like the compiler to warn me of public methods/properties that cannot be bridged to ObjC, because I have explicitly told the compiler that I want this object to live in the ObjC runtime. Of course, with a fixit recommending something like explicitly using @nonobjc.
>> 
>> @objc on extensions behaves this way; the compiler will produce an error if the entity cannot be exposed to Objective-C.
>> 
>> 	- Doug
> 
> Yeah, I think you explained the behavior of extensions very well in the proposal:
> 
> > If some member within that extension cannot be exposed to Objective-C, such as SwiftClass.bar(), the compiler will produce an error.
> 
> My specific question was about implicitly @nonobjc members in a @objcMembers class. That is, would the compiler allow such member with no @nonobjc annotation?

Yes. 

> And would extensions of such classes allow those members?

Yes. Also true for subclasses and their extensions. 

> Do I need to put @objc in every extension of a @objcMembers class to get that compiler error?

Yes. 

> 
> By the way, I very much appreciate the level of care that you put into this proposal and its implementation. Thank you very much!

I'm looking forward to getting feedback on how it works out in practice. I've had pretty good luck with my our migrations. 

  - Doug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170405/18023b98/attachment.html>


More information about the swift-evolution mailing list