Potential Bug with Compiler in 2.1.1 and UnitTests


(James Campbell) #1

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

···

*___________________________________*

*James⎥Head Of CEO*

*james@supmenow.com <james@supmenow.com>⎥supmenow.com <http://supmenow.com>*

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *


(Joe Groff) #2

(bcc'ing swift-evolution, adding swift-users)

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

___________________________________

James⎥Head Of CEO

james@supmenow.com <mailto:james@supmenow.com>⎥supmenow.com <http://supmenow.com/>
Sup

Runway East >

10 Finsbury Square

London

> EC2A 1AF

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