Skip to content

Commit 474b2ae

Browse files
committed
Added a test for by name functions
1 parent 46eb5ea commit 474b2ae

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/dotty/tools/dotc/transform/ElimByName.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ object ElimByName {
4040
* This makes the argument compatible with a parameter type of () => T, which will be the
4141
* formal parameter type at erasure. But to be -Ycheckable until then, any argument
4242
* ARG rewritten by the rules above is again wrapped in an application ARG.apply(),
43-
* labelled with an `ByNameParam` attachment.
44-
*
45-
* Erasure will later strip wrapped `.apply()` calls with ByNameParam attachments.
46-
*
43+
* labelled with a `ByNameParam` attachment. Erasure will later strip wrapped
44+
* `.apply()` calls with ByNameParam attachments.
4745
*/
4846
class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransformer =>
4947
import ast.tpd._

tests/pos/bynamefuns.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
object Test {
2+
3+
type LF = (=> Int) => Int
4+
5+
def f(x: => Int) = x * x
6+
7+
val x: LF = f
8+
9+
def g = 3
10+
11+
f(11)
12+
x(g)
13+
x(11)
14+
15+
}

0 commit comments

Comments
 (0)