We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 151bf8a commit bf0095dCopy full SHA for bf0095d
tests/neg/i7060.scala
@@ -0,0 +1,19 @@
1
+object PostConditions1 {
2
+
3
+ import PostConditions.{ensure, res, Box}
4
5
+ val v = List(1, 2, 4).sum.ensure(Box(10) => res == 10) // error: not a legal formal parameter
6
+ println(v)
7
+}
8
9
+object PostConditions {
10
11
+ class Box[T](val t: T)
12
13
+ def res[T] given (b: Box[T]): T = b.t
14
15
+ def (e: T) ensure[T](cond: given Box[T] => Boolean): T = {
16
+ if (cond given Box(e)) e
17
+ else throw new AssertionError("condition not fulfilled")
18
+ }
19
0 commit comments