I’ve stumbled upon an odd situation where Swift gives a compiler error if I
do things directly, but works properly with no error if I first create a
typealias. Here is a stripped-down example:
The “return” line gives the error “Cannot call value of non-function type
'[Self.C.Iterator.Element.Type]'” in Xcode 8.3.2. However, if we replace
that function with a seemingly-equivalent version that uses a typealias,
there is no error:
extension P {
func emptyArray() -> [C.Iterator.Element] {
typealias E = C.Iterator.Element
return [E]() // Works
}
}
On 29. Apr 2017, at 22:38, Nevin Brackett-Rozinsky via swift-users <swift-users@swift.org> wrote:
I’ve stumbled upon an odd situation where Swift gives a compiler error if I do things directly, but works properly with no error if I first create a typealias. Here is a stripped-down example:
The “return” line gives the error “Cannot call value of non-function type '[Self.C.Iterator.Element.Type]'” in Xcode 8.3.2. However, if we replace that function with a seemingly-equivalent version that uses a typealias, there is no error:
extension P {
func emptyArray() -> [C.Iterator.Element] {
typealias E = C.Iterator.Element
return [E]() // Works
}
}