@@ -15,7 +15,7 @@ object LazyNil extends LazyList[Nothing]:
15
15
16
16
extension [A ](xs : {* } LazyList [A ])
17
17
def map [B ](f : {* } A => B ): {f} LazyList [B ] =
18
- class Mapped extends LazyList [B ]: // error
18
+ final class Mapped extends LazyList [B ]: // error
19
19
this : ({xs, f} Mapped ) =>
20
20
21
21
def isEmpty = false
@@ -24,7 +24,7 @@ extension [A](xs: {*} LazyList[A])
24
24
new Mapped
25
25
26
26
def map2 [B ](f : {* } A => B ): {xs} LazyList [B ] =
27
- class Mapped extends LazyList [B ]: // error
27
+ final class Mapped extends LazyList [B ]: // error
28
28
this : ({xs, f} Mapped ) =>
29
29
30
30
def isEmpty = false
@@ -33,7 +33,7 @@ extension [A](xs: {*} LazyList[A])
33
33
new Mapped
34
34
35
35
def map3 [B ](f : {* } A => B ): {xs} LazyList [B ] =
36
- class Mapped extends LazyList [B ]:
36
+ final class Mapped extends LazyList [B ]:
37
37
this : ({xs} Mapped ) =>
38
38
39
39
def isEmpty = false
@@ -42,11 +42,23 @@ extension [A](xs: {*} LazyList[A])
42
42
new Mapped
43
43
44
44
def map4 [B ](f : {* } A => B ): {xs} LazyList [B ] =
45
- class Mapped extends LazyList [B ]:
45
+ final class Mapped extends LazyList [B ]:
46
46
this : ({xs, f} Mapped ) =>
47
47
48
48
def isEmpty = false
49
49
def head : B = f(xs.head)
50
50
def tail : {xs, f} LazyList [B ] = xs.tail.map(f) // error
51
51
new Mapped
52
52
53
+ def map5 [B ](f : {* } A => B ): LazyList [B ] =
54
+ class Mapped extends LazyList [B ]:
55
+ this : ({xs, f} Mapped ) =>
56
+
57
+ def isEmpty = false
58
+ def head : B = f(xs.head)
59
+ def tail : {this } LazyList [B ] = xs.tail.map(f) // error
60
+ class Mapped2 extends Mapped :
61
+ this : Mapped =>
62
+ new Mapped2
63
+
64
+
0 commit comments