@@ -15,7 +15,7 @@ object LazyNil extends LazyList[Nothing]:
1515
1616extension [A ](xs : {* } LazyList [A ])
1717 def map [B ](f : {* } A => B ): {f} LazyList [B ] =
18- class Mapped extends LazyList [B ]: // error
18+ final class Mapped extends LazyList [B ]: // error
1919 this : ({xs, f} Mapped ) =>
2020
2121 def isEmpty = false
@@ -24,7 +24,7 @@ extension [A](xs: {*} LazyList[A])
2424 new Mapped
2525
2626 def map2 [B ](f : {* } A => B ): {xs} LazyList [B ] =
27- class Mapped extends LazyList [B ]: // error
27+ final class Mapped extends LazyList [B ]: // error
2828 this : ({xs, f} Mapped ) =>
2929
3030 def isEmpty = false
@@ -33,7 +33,7 @@ extension [A](xs: {*} LazyList[A])
3333 new Mapped
3434
3535 def map3 [B ](f : {* } A => B ): {xs} LazyList [B ] =
36- class Mapped extends LazyList [B ]:
36+ final class Mapped extends LazyList [B ]:
3737 this : ({xs} Mapped ) =>
3838
3939 def isEmpty = false
@@ -42,11 +42,23 @@ extension [A](xs: {*} LazyList[A])
4242 new Mapped
4343
4444 def map4 [B ](f : {* } A => B ): {xs} LazyList [B ] =
45- class Mapped extends LazyList [B ]:
45+ final class Mapped extends LazyList [B ]:
4646 this : ({xs, f} Mapped ) =>
4747
4848 def isEmpty = false
4949 def head : B = f(xs.head)
5050 def tail : {xs, f} LazyList [B ] = xs.tail.map(f) // error
5151 new Mapped
5252
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