Skip to content

Commit c148301

Browse files
committed
Add examples to test partial eta-expansion
1 parent 3fb9d9a commit c148301

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

tests/neg/i2146.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Test {
2+
case class A()
3+
case class B()
4+
5+
def foo[A, B]: implicit A => implicit B => Int = { implicit b: B =>
6+
42 // error: found Int, required: implicit A => implicit B => Int
7+
}
8+
}

tests/pos/i2146.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
A()
55
(A(),B())
66
(A(),B())
7+
(A(),B())
8+
(A(),B())
9+
(A(),B())

tests/pos/i2146.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ object Test {
77
def foo[A, B]: implicit A => implicit B => (A, B) =
88
(implicitly[A], implicitly[B])
99

10+
def bar[A, B]: implicit A => implicit B => (A, B) = { implicit a: A =>
11+
(implicitly[A], implicitly[B])
12+
}
13+
1014
implicit val a: A = A()
1115
implicit val b: B = B()
1216

@@ -20,5 +24,9 @@ object Test {
2024
println(x0)
2125
val x1: implicit B => (A, B) = foo[A, B]
2226
println(x1)
27+
28+
println(bar[A, B])
29+
println(bar[A, B](a))
30+
println(bar(a)(b))
2331
}
2432
}

0 commit comments

Comments
 (0)