File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed
tests/pos-custom-args/captures Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ extension [A](xs: {*} LazyList[A])
2222 def head : B = f(xs.head)
2323 def tail : {this } LazyList [B ] = xs.tail.map(f) // OK
2424 def concat (other : {f} LazyList [A ]): {this , f} LazyList [A ] = ??? : ({xs, f} LazyList [A ]) // OK
25- new Mapped
25+ if xs.isEmpty then LazyNil
26+ else new Mapped
2627
2728def test (cap1 : Cap , cap2 : Cap ) =
2829 def f (x : String ): String = if cap1 == cap1 then " " else " a"
@@ -35,4 +36,7 @@ def test(cap1: Cap, cap2: Cap) =
3536 def isEmpty = false
3637 def head = f(" " )
3738 def tail = LazyNil
38- new Initial
39+ new Initial
40+ val xsc : {cap1} LazyList [String ] = xs
41+ val ys = xs.map(g)
42+ val ysc : {cap1, cap2} LazyList [String ] = ys
Original file line number Diff line number Diff line change 1+ class CC
2+ type Cap = {* } CC
3+
4+ trait LazyList [+ A ]:
5+ this : ({* } LazyList [A ]) =>
6+
7+ def isEmpty : Boolean
8+ def head : A
9+ def tail : {this } LazyList [A ]
10+
11+ object LazyNil extends LazyList [Nothing ]:
12+ def isEmpty : Boolean = true
13+ def head = ???
14+ def tail = ???
15+
16+ class LazyCons [+ T ](val x : T , val xs : {* } () => {* } LazyList [T ]) extends LazyList [T ]:
17+ this : ({* } LazyList [T ]) =>
18+
19+ def isEmpty = false
20+ def head = x
21+ def tail : {this } LazyList [T ] = xs()
22+
23+ extension [A ](xs : {* } LazyList [A ])
24+ def map [B ](f : {* } A => B ): {xs, f} LazyList [B ] =
25+ if xs.isEmpty then LazyNil
26+ else LazyCons (f(xs.head), () => xs.tail.map(f))
27+
28+ def test (cap1 : Cap , cap2 : Cap ) =
29+ def f (x : String ): String = if cap1 == cap1 then " " else " a"
30+ def g (x : String ): String = if cap2 == cap2 then " " else " a"
31+
32+ val xs = LazyCons (" " , () => if f(" " ) == f(" " ) then LazyNil else LazyNil )
33+ val xsc : {cap1} LazyList [String ] = xs
34+ val ys = xs.map(g)
35+ val ysc : {cap1, cap2} LazyList [String ] = ys
You can’t perform that action at this time.
0 commit comments