Skip to content

Commit d80ea7e

Browse files
committed
Add tests with dependencies from second type parameter clause
Add tests with dependencies from second type parameter clause to first type parameter and extension parameter clauses.
1 parent b3bafdb commit d80ea7e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/pos/extmethods.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ object CollectionStrawMan {
2424
extension [A](xs: List[A])
2525
inline def foldl[B](z: B)(op: (B, A) => B): B =
2626
(xs: List[A]).foldLeft(z)(op)
27+
inline def concat[B <: A](ys: List[B]): List[A] = xs ++ ys
2728

2829
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
2934

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

Comments
 (0)