Closed
Description
I have tried the example given here:
http://dotty.epfl.ch/docs/reference/contextual/implicit-function-types.html#example-postconditions
minimized code
object PostConditions2 {
import PostConditions.{ensuring, result}
val s = List(1, 2, 3).sum.ensuring(result == 6)
println(s)
}
object PostConditions {
opaque type WrappedResult[T] = T
def result[T] given (r: WrappedResult[T]): T = r
def (x: T) ensuring[T](condition: given WrappedResult[T] => Boolean): T =
assert(condition) given x
}
expectation
Compile correctly
result
assert(condition) given x
^
no implicit argument of type PostConditions.WrappedResult[T] was found for parameter of given PostConditions.WrappedResult[T] => Boolean