I have a class that specifies a initialiser taking any class that
implements the protocol "ChatDatastore"
I can use this fine in the functions for my test cases.
However if I try to initialise it in a member either statically, lazily or
even via a computed variable it shows an error stating "Instance member
'chatDatastore' cannot be used on type 'ChatSessionRowViewModelTests'
Not only is this confusing its plain wrong. I am passing in a Mock which
implements this protocol for the purposes of testing.
This should work yet it seems to think that the initializer takes a totally
different type than specified in the code. It should accept my Mock class
since it implements this protocol yet it complains that I need to give it
an instance of my testing class. Which makes no sense :S
This list is for language design discussion. If you have a bug, please file it at bugs.swift.org, or discuss it on swift-users.
-Joe
···
On Mar 18, 2016, at 10:11 AM, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:
I have a class that specifies a initialiser taking any class that implements the protocol "ChatDatastore"
I can use this fine in the functions for my test cases.
However if I try to initialise it in a member either statically, lazily or even via a computed variable it shows an error stating "Instance member 'chatDatastore' cannot be used on type 'ChatSessionRowViewModelTests'
Not only is this confusing its plain wrong. I am passing in a Mock which implements this protocol for the purposes of testing.
This should work yet it seems to think that the initializer takes a totally different type than specified in the code. It should accept my Mock class since it implements this protocol yet it complains that I need to give it an instance of my testing class. Which makes no sense :S