Skip to content

Commit b65b70b

Browse files
committed
Test case for closure inlining
This test works, but closures are not currently inlined. That's a still to do.
1 parent 7bfd48d commit b65b70b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/run/inlinedAssign.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object Test {
2+
3+
@dotty.annotation.inline
4+
def swap[T](x: T, x_= : T => Unit, y: T, y_= : T => Unit) = {
5+
val t = x
6+
x_=(y)
7+
y_=(t)
8+
}
9+
10+
def main(args: Array[String]) = {
11+
var x = 1
12+
var y = 2
13+
@dotty.annotation.inline def setX(z: Int) = x = z
14+
@dotty.annotation.inline def setY(z: Int) = y = z
15+
swap[Int](x, setX, y, setY)
16+
assert(x == 2 && y == 1)
17+
}
18+
}

0 commit comments

Comments
 (0)