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

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

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:).

Slava

···

On May 19, 2017, at 11:18 AM, Edward Connell via swift-users <swift-users@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Yes I did, that fixed the problem. Thank you

···

On Fri, May 19, 2017 at 12:38 PM, Slava Pestov <spestov@apple.com> wrote:

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:).

Slava

On May 19, 2017, at 11:18 AM, Edward Connell via swift-users < > swift-users@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

That's worrisome. type is such a common identifier that I worry its going to break a lot of code, create some confusion and force the un-esthetic qualifying.

···

On 19 May 2017, at 21:38, Slava Pestov via swift-users <swift-users@swift.org> wrote:

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:).

Slava

On May 19, 2017, at 11:18 AM, Edward Connell via swift-users <swift-users@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Well, I think it’s a step forward by making type(of:) *like* a stdlib function. Now we need to change .Type and .Protocol syntax to something like Type<T>, AnyType<T> and also fix the way it behaves in a generic context to finally open up Type for custom type names. This should also help removing .self.

=)

···

--
Adrian Zubarev
Sent with Airmail

Am 20. Mai 2017 um 00:42:27, David Hart via swift-users (swift-users@swift.org) schrieb:

That's worrisome. type is such a common identifier that I worry its going to break a lot of code, create some confusion and force the un-esthetic qualifying.

On 19 May 2017, at 21:38, Slava Pestov via swift-users <swift-users@swift.org> wrote:

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:).

Slava

On May 19, 2017, at 11:18 AM, Edward Connell via swift-users <swift-users@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users