File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -503,7 +503,8 @@ object ProtoTypes {
503
503
}
504
504
505
505
/** Same as `constrained(tl, EmptyTree)`, but returns just the created type lambda */
506
- def constrained (tl : TypeLambda )(implicit ctx : Context ): TypeLambda = constrained(tl, EmptyTree )._1
506
+ def constrained (tl : TypeLambda )(implicit ctx : Context ): TypeLambda =
507
+ constrained(tl, EmptyTree , alwaysAddTypeVars = ctx.typerState.isCommittable)._1
507
508
508
509
def newTypeVar (bounds : TypeBounds )(implicit ctx : Context ): TypeVar = {
509
510
val poly = PolyType (DepParamName .fresh().toTypeName :: Nil )(
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments