We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b3bafdb commit d80ea7eCopy full SHA for d80ea7e
tests/pos/extmethods.scala
@@ -24,6 +24,24 @@ object CollectionStrawMan {
24
extension [A](xs: List[A])
25
inline def foldl[B](z: B)(op: (B, A) => B): B =
26
(xs: List[A]).foldLeft(z)(op)
27
+ inline def concat[B <: A](ys: List[B]): List[A] = xs ++ ys
28
29
val x = List("a", "b").foldl[Int](0)((x, y) => x + y.length)
30
+val y = Nil.concat(1 :: Nil)
31
+val y1: List[Int] = y
32
+val z = (1 :: Nil).concat(Nil)
33
+val z1: List[Int] = z
34
35
+trait TT:
36
+ type A
37
+ val m: A
38
+ def f[B <: A](x: B): A = if ??? then m else x
39
+
40
+extension (x: TT)
41
+ def foo[B <: x.A](y: B) = x.f(y)
42
43
+object CC extends TT:
44
+ type A = Seq[Int]
45
+ val m = Nil
46
47
+val xx = CC.foo(List(1, 2, 3))
0 commit comments