File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
main/scala/scala/async/internal
test/scala/scala/async/run/live Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ trait LiveVariables {
5656
5757 // determine which fields should be live also at the end (will not be nulled out)
5858 val noNull : Set [Symbol ] = liftedSyms.filter { sym =>
59- sym.tpe.typeSymbol.isPrimitiveValueClass || liftables.exists { tree =>
59+ sym.tpe.typeSymbol.isPrimitiveValueClass || sym.tpe.typeSymbol == definitions. NothingClass || liftables.exists { tree =>
6060 ! liftedSyms.contains(tree.symbol) && tree.exists(_.symbol == sym)
6161 }
6262 }
Original file line number Diff line number Diff line change @@ -263,4 +263,30 @@ class LiveVariablesSpec {
263263 }
264264 baz()
265265 }
266+
267+ // https://github.com/scala/async/issues/104
268+ @ Test def dontNullOutVarsOfTypeNothing_t104 (): Unit = {
269+ implicit val ec : scala.concurrent.ExecutionContext = null
270+ import scala .async .Async ._
271+ import scala .concurrent .duration .Duration
272+ import scala .concurrent .{Await , Future }
273+ import scala .concurrent .ExecutionContext .Implicits .global
274+ def errorGenerator (randomNum : Double ) = {
275+ Future {
276+ if (randomNum < 0 ) {
277+ throw new IllegalStateException (" Random number was too low!" )
278+ } else {
279+ throw new IllegalStateException (" Random number was too high!" )
280+ }
281+ }
282+ }
283+ def randomTimesTwo = async {
284+ val num = _root_.scala.math.random
285+ if (num < 0 || num > 1 ) {
286+ await(errorGenerator(num))
287+ }
288+ num * 2
289+ }
290+ Await .result(randomTimesTwo, TestLatch .DefaultTimeout ) // was: NotImplementedError
291+ }
266292}
You can’t perform that action at this time.
0 commit comments