[swift-users] typealias for Generic in Generic
Adrian Zubarev
adrian.zubarev at devandartist.com
Tue Apr 4 12:28:54 CDT 2017
R is a non generic type, because the generic part is set to T, that’s why R() works.
Otherwise you could create typealias Q<NameThatIsNot_T> = Сarriage<NameThatIsNot_T> and use it like this Q<String>()
--
Adrian Zubarev
Sent with Airmail
Am 4. April 2017 um 19:25:45, Седых Александр via swift-users (swift-users at swift.org) schrieb:
Hello.
I stumbled on ambiguous behaviour of compiler. Is not allowed explicitly indicate type in Generic typealias.
struct Сarriage<T> {
let g = [T]()
}
struct Coma<T> {
typealias R = Сarriage<T>
let m = R()
let d = R<String>() \\ error: cannot specialize non-generic type 'Сarriage<T>'
var b = Сarriage<String>()
mutatingfunc work() {
m.g.append(<#T##newElement: T##T#>) \\ what I can write here?
b.g.append("Z")
}
}
--
Седых Александр _______________________________________________
swift-users mailing list
swift-users at swift.org
https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170404/e8b3f960/attachment.html>
More information about the swift-users
mailing list