[swift-users] Non-objc protocol inheritance from objc protocol
Jordan Rose
jordan_rose at apple.com
Mon Feb 6 17:22:02 CST 2017
Hi, Pavel. This is definitely supported, and it is indeed a bug that these are not both producing 'true'. We're tracking this as rdar://problem/24453316 <rdar://problem/24453316>.
Jordan
> On Feb 5, 2017, at 03:14, Pavel Ivashkov via swift-users <swift-users at swift.org> wrote:
>
> Hello,
>
> What is the current view on inheriting non-objc protocol from objc protocol? Is it supported? Is it a valid construct?
>
>
> import Foundation
>
> @objc protocol Base {}
>
> protocol Some : Base {}
>
> class Nada : NSObject, Some {}
>
> let x: NSObject = Nada()
>
> print("Nada is Some? \(x is Some)")
> print("Nada is Base? \(x is Base)")
>
>
> There are two statements in the docs on @objc attribute:
> a) The compiler also implicitly adds the objc attribute to a class that inherits from another class marked with the objc attribute or a class defined in Objective-C.
> b) Protocols marked with the objc attribute can’t inherit from protocols that aren’t.
>
> But they don't spec the other way round about protocols.
>
>
> Currently the output is
>
> swift main.swift
> Nada is Some? true
> Nada is Base? false
>
> Which is not what I would expect.
>
> Here is extended example: http://stackoverflow.com/q/42023977 <http://stackoverflow.com/q/42023977>
>
> swift --version
> Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
> Target: x86_64-apple-macosx10.9
>
> (same on 3.1-dev)
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170206/b2097ec9/attachment.html>
More information about the swift-users
mailing list