Swift 2b2: Protocol inheritance cannot specialize

Originator:rix.rob
Number:rdar://21645883 Date Originated:01-Jul-2015 10:15 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A121l)
Classification:Serious Bug Reproducible:Always
 
Summary:
I have two protocols with one inheriting from the other. I would like to have the child specialize the typealias of its parent, but this doesn’t work.


Steps to Reproduce:
1. This code:

protocol A {
	typealias B
	init(B)

	var b: B { get }
}

protocol C: A {
	typealias B = Int
}

struct S: C {
	let b: Int
	init(_ x: Int) { b = x }
}

func f<T: C>(x: T) -> Int {
	return x.b
}



Expected Results:
should compile


Actual Results:
but does not:

boom2.swift:18:11: error: cannot convert return expression of type 'T.B' to expected return type 'Int'


Regression:
N/A


Notes:
It appears that the T.B typealias is just silently dropped. You can’t refer to it or use it, since it’s shadowed by the protocol it inherits from (which is counterintuitive to say the least).

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!