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

Cannot mock overloaded methods if types of their arguments are parametrised with wildcard type #413

Open
eshlykov opened this issue Oct 6, 2021 · 0 comments

Comments

@eshlykov
Copy link

eshlykov commented Oct 6, 2021

There is a compilation error when I try to mock a class with overloaded methods that have arguments of a generic type parametrised with a wildcard type.

Example:

class P[T]

class A[F[_]]
class B[F[_]]

trait Fooer[F[_]] {
  def foo(x: A[F]): Unit
  def foo(x: B[F]): Unit
}

val mockFooer: Fooer[P] = mock[Fooer[P]]

(mockFooer.foo(_: A[P])).expects(new A[P])
(mockFooer.foo(_: B[P])).expects(new B[P])

Errors:

value expects is not a member of this.A[this.P] => Unit
    (mockFooer.foo(_: A[P])).expects(new A[P])
value expects is not a member of this.B[this.P] => Unit
    (mockFooer.foo(_: B[P])).expects(new B[P])

However, I expect successful compilation.

Versions:

sbt       1.5.5
jdk       AdoptOpenJDK Java 11.0.11
scala     2.13.6
scalamock 5.1.0
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