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

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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to