Skip to content

Commit c11a3fd

Browse files
committed
Example from latest Cochis paper
Shows how the behavior has changed in dotty.
1 parent 44c1ec1 commit c11a3fd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/run/cochis-example.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
import Predef.{$conforms => _}
3+
trait A {
4+
implied id[X] for (X => X) = x => x
5+
def trans[X](x: X) given (f: X => X) = f(x) // (2)
6+
}
7+
object Test extends A with App{
8+
implied succ for (Int => Int) = x => x + 1 // (3)
9+
def bad[X](x: X): X = trans[X](x) // (4) unstable definition !
10+
val v1 = bad [Int] (3) // (5) evaluates to 3
11+
assert(v1 == 3)
12+
val v2 = trans [Int] (3)
13+
assert(v2 == 4)
14+
}

0 commit comments

Comments
 (0)