-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
minimized code
import scala.language.implicitConversions
trait Fixture[A] extends Conversion[0, A]
trait TestFramework[A] {
def (testName: String) in (test: given (Fixture[A]) => Unit): Unit = ???
}
trait Greeter {
def greet(name: String): String = s"Hello $name"
}
case class MyFixture(name: String, greeter: Greeter)
class MyTest extends TestFramework[MyFixture] {
"say hello" in {
assert(0.greeter.greet(0.name) == s"Hello ${0.name}")
}
}
expectation
Expected Fixture
Conversion to apply and attach names to 0
, but got error:
[error] example.scala:48:14: value greeter is not a member of Int
[error] assert(0.greeter.greet(0.name) == s"Hello ${0.name}")
[error] ^
Using an implicit def conversion instead of Conversion
works as expected:
implicit def fixture0[A](z: 0)(implicit f: Fixture[A]): A = f(z)