fmonniot / scala3mock

Mocking framework for Scala 3
https://francois.monniot.eu/scala3mock
Other
19 stars 1 forks source link

Support for by-name parameters #4

Open fmonniot opened 10 months ago

fmonniot commented 10 months ago

By name parameters have a different compiler representation than regular functions and need to be handled explicitely in the when macro.

Example:

trait Test:
  def byNameParam(x: => Int): String

val t = mock[Test]
when(t.byNameParam).expect(1).returns("ok")
fmonniot commented 10 months ago

There is still an issue with type inference. The example above works only if we explicitely give the types:

trait Test:
  def byNameParam(x: => Int): String

val t = mock[Test]
when[Int, String](t.byNameParam).expect(1).returns("ok")