File tree 2 files changed +27
-1
lines changed
main/scala/scala/async/internal
test/scala/scala/async/run/live
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ trait LiveVariables {
56
56
// determine which fields should be live also at the end (will not be nulled out)
57
57
val noNull : Set [Symbol ] = liftedSyms.filter { sym =>
58
58
val typeSym = tpe(sym).typeSymbol
59
- (typeSym.isClass && typeSym.asClass.isPrimitive) || liftables.exists { tree =>
59
+ (typeSym.isClass && ( typeSym.asClass.isPrimitive || typeSym == definitions. NothingClass ) ) || liftables.exists { tree =>
60
60
! liftedSyms.contains(tree.symbol) && tree.exists(_.symbol == sym)
61
61
}
62
62
}
Original file line number Diff line number Diff line change @@ -263,4 +263,30 @@ class LiveVariablesSpec {
263
263
}
264
264
baz()
265
265
}
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
+ }
266
292
}
You can’t perform that action at this time.
0 commit comments