Properties in Protocols do not support covariance

Originator:iankeen82
Number:rdar://23404912 Date Originated:4-Nov-2015
Status:Open Resolved:No
Product:Sample Code Product Version:Swift 2.1
Classification: Reproducible:Yes
 
Steps to Reproduce:
protocol Proto {
    var vc: UIViewController { get }
}
class Test: UIViewController { }

class Class: Proto {
    let vc = Test()
}

This does not work, it says that Class doesn't satisfy Proto, however when I change it to this...

class Class: Proto {
    let vc: UIViewController = Test()
}

This satisfies the compiler

Expected Results:
In the example 'Class' is covariant with 'UIViewController' so I would expect the UIViewController subclass Test to satisfy the protocol contract

Configuration:
% xcrun swift -version
Apple Swift version 2.1 (swiftlang-700.1.101.6 clang-700.1.76)
Target: x86_64-apple-darwin14.5.0

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!