Skip to content

Problem reproducing Post Condition example from doc #7059

Closed
@Master-Killer

Description

@Master-Killer

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions