[swift-users] swift 4.0 "swift-version 4" errors with "type(of:"

Slava Pestov spestov at apple.com
Fri May 19 14:38:49 CDT 2017

Do you have a member named ‘type’ in the current scope?

We changed the behavior of type(of:) so that it behaves like a normal declaration in the Swift module instead of a special keyword. Unfortunately this means if you have a ‘type’ already visible in scope, you have to fully qualify Swift.type(of:).


> On May 19, 2017, at 11:18 AM, Edward Connell via swift-users <swift-users at swift.org> wrote:
> When running the compiler using the "-swift-version 4" flag, the compiler complains about creating a dynamic type. Errors are flagged from within concrete base classes and also within protocol extensions.
> error: cannot invoke 'type' with an argument list of type '(of: Self)'
>                 let newObject = type(of: self).init()
> Has this changed?? Are we supposed to create dynamic types a different way now?
> Thanks, Ed
> _______________________________________________
> 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/20170519/0eb6e161/attachment.html>

More information about the swift-users mailing list