You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for all your effort on mockito-scala! We've been adopting it with great success... until running into this issue today.
We use value classes like case class Something[T](value: String) extends AnyVal, and it's been extremely hard to make them work so far - I either get an NPE, or an "invalid use of matchers" error, or even a MatchErrorexception during compilation!
Hope this is an easy pattern fix in the macro?
importorg.mockito.scalatest.IdiomaticMockitoimportorg.scalatest.FlatSpecimportorg.scalatest.MatchersclassGenericAnyValStubbingTestextendsFlatSpecwithMatcherswithIdiomaticMockito {
valsvc= mock[AnyValsService]
it should "stub generic AnyVals" in {
svc.printTaggedValue(any[TaggedValue[String]]) returns "hello"
svc.printTaggedValue(TaggedValue[String](1)) shouldBe "hello"
}
}
traitAnyValsService {
defprintTaggedValue(value: TaggedValue[String]):String
}
caseclassTaggedValue[T](v: Int) extendsAnyVal
And here's what I'm getting from the compiler:
[error] scala.MatchError: apply (of class scala.reflect.internal.Trees$Ident)
[error] at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer.isClassTypeAccessible$1(RefChecks.scala:1504)
[error] at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer.isSimpleCaseApply(RefChecks.scala:1520)
[error] at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer.transform(RefChecks.scala:1784)
[error] at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer.transform(RefChecks.scala:107)
[error] at scala.reflect.internal.Trees.itransform(Trees.scala:1373)
[error] at scala.reflect.internal.Trees.itransform$(Trees.scala:1362)
... and many more lines
The text was updated successfully, but these errors were encountered:
...because if I try wrapping any into TaggedValue I get "invalid use of argument matchers" because the returns macro only supports a predefined set of matchers
Hi Bruno!
Thank you for all your effort on mockito-scala! We've been adopting it with great success... until running into this issue today.
We use value classes like
case class Something[T](value: String) extends AnyVal
, and it's been extremely hard to make them work so far - I either get an NPE, or an "invalid use of matchers" error, or even aMatchError
exception during compilation!Hope this is an easy pattern fix in the macro?
And here's what I'm getting from the compiler:
The text was updated successfully, but these errors were encountered: