[Swift] Ability to make protocol extensions conform to another protocol

Originator:info
Number:rdar://23616744 Date Originated:19-Nov-2015 12:18 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Swift 2.1
Classification:Feature (New) Reproducible:Always
 
Summary:
Having a protocol P and a protocol T, it would be useful to express that any type P also conforms to T by providing an extension.

Steps to Reproduce:
- Compile the following code:

protocol T {}
protocol S {}

extension T: S {}

Expected Results:
- It compiles.

Actual Results:
- error: extension of protocol 'T' cannot have an inheritance clause

Notes:
- This would be extra useful in addition to rdar://23616223.
- A more useful example could be:

protocol SwiftProtocol {
	var swiftValue: SwiftOnlyType { get }
}

public protocol ObjectiveCProtocol {
	var objectiveCValue: ObjectiveCType { get }
}

extension ObjectiveCProtocol: SwiftProtocol {
	var swiftValue: SwiftOnlyType { 
		return self.objectiveCValue.bridgedToSwift()
	}
}

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!