Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambiguous implicit values when matching on Future[Set[T]] #289

Closed
swar30 opened this issue Aug 18, 2014 · 5 comments
Closed

ambiguous implicit values when matching on Future[Set[T]] #289

swar30 opened this issue Aug 18, 2014 · 5 comments

Comments

@swar30
Copy link

swar30 commented Aug 18, 2014

Hi, i'm using org.specs2:specs2_2.10:2.3.12 in Scala and I have this expression

(someList:Future[Seq[_]]) must haveSize(1).await

Which results in compilation error

Error:(64, 52) ambiguous implicit values:
both method scalaTraversableIsSized in trait TraversableBaseMatchers of type [I <: scala.collection.GenTraversableOnce[_]]=> org.specs2.data.Sized[I]
and method scalaArrayIsSized in trait TraversableBaseMatchers of type [T]=> org.specs2.data.Sized[Array[T]]
match expected type org.specs2.data.SizedT must haveSize(1).await
^

I'm new to Scala, but this seems like a bug in implicit definitions

@etorreborre
Copy link
Owner

That's an unfortunate interaction between several implicits + type inference. I'm going to see if I can fix this.

@swar30
Copy link
Author

swar30 commented Aug 18, 2014

Thanks, if it's hard to resolve, may be it makes sense to add docs that
explain the work around (explicit casting), I'm new to Scala so for me it
was really hard to work around this easily.
I ended up with

someListFuture must haveSizeList[_].await;

@etorreborre
Copy link
Owner

In the meantime you can use an annotation:

(someList:Future[Seq[_]]) must haveSize[Seq[_]](1).await

@etorreborre
Copy link
Owner

I tried to fix this but the way type inference works and given the existing constraints on haveSize, I couldn't find a solution that was not involving annotating the type on haveSize. So I added this information to the User Guide.

@swar30
Copy link
Author

swar30 commented Aug 19, 2014

Thanks

On Tue, Aug 19, 2014 at 2:55 AM, Eric Torreborre notifications@github.com
wrote:

I tried to fix this but the way type inference works and given the
existing constraints on haveSize, I couldn't find a solution that was not
involving annotating the type on haveSize. So I added this information to
the User Guide.


Reply to this email directly or view it on GitHub
#289 (comment).

Thanks,
Alex Shnayder
Wix Cloud, Wix.com

etorreborre added a commit that referenced this issue Aug 19, 2014
…Size matcher. fixes #289

Conflicts:
	guide/src/test/scala/org/specs2/guide/MatcherCards.scala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants