diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-12 18:53:53 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:12:28 +0200 |
commit | 4de907a313e9b85058cd9611116a1cbcf2bd3a4f (patch) | |
tree | 6992c2247f9a7e0b3b623e36da8ccfb1e2de461c /tests | |
parent | 7537cfcfa5ccf47d400e2841b9bc4ff2cac1eada (diff) | |
download | dotty-4de907a313e9b85058cd9611116a1cbcf2bd3a4f.tar.gz dotty-4de907a313e9b85058cd9611116a1cbcf2bd3a4f.tar.bz2 dotty-4de907a313e9b85058cd9611116a1cbcf2bd3a4f.zip |
Always use implicit context at the current period
An implicit method might be unpickled in one run and the implicit
body might be selected first in a subsequent run. In that case
the inlined code was read with the original context, but
that context needs to run at the current period. This resulted
in denotation out of date errors in bringForward.
Another problem with this design was space leaks: An context might
survive multiple runs as part of an ImplicitInfo of an unpickled
method.
The new design avoids both problems. Implicit contexts are always
up to date and leaks are avoided.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run/inlinedAssign.scala | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/tests/run/inlinedAssign.scala b/tests/run/inlinedAssign.scala index bb81aea26..f405f5073 100644 --- a/tests/run/inlinedAssign.scala +++ b/tests/run/inlinedAssign.scala @@ -1,7 +1,6 @@ object Test { - @`inline` - def swap[T](x: T, x_= : T => Unit, y: T, y_= : T => Unit) = { + inline def swap[T](x: T, x_= : T => Unit, y: T, y_= : T => Unit) = { val t = x x_=(y) y_=(t) @@ -10,9 +9,9 @@ object Test { def main(args: Array[String]) = { var x = 1 var y = 2 - @`inline` def setX(z: Int) = x = z - @`inline` def setY(z: Int) = y = z - swap[Int](x, setX, y, setY) + inline def setX(z: Int) = x = z + inline def setY(z: Int) = y = z + swap(x, setX, y, setY) assert(x == 2 && y == 1) } } |