Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/scala/scala/async/internal/LiveVariables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ trait LiveVariables {
// determine which fields should be live also at the end (will not be nulled out)
val noNull: Set[Symbol] = liftedSyms.filter { sym =>
val typeSym = tpe(sym).typeSymbol
(typeSym.isClass && typeSym.asClass.isPrimitive) || liftables.exists { tree =>
(typeSym.isClass && (typeSym.asClass.isPrimitive || typeSym == definitions.NothingClass)) || liftables.exists { tree =>
!liftedSyms.contains(tree.symbol) && tree.exists(_.symbol == sym)
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/test/scala/scala/async/run/live/LiveVariablesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,30 @@ class LiveVariablesSpec {
}
baz()
}

// https://github.com/scala/async/issues/104
@Test def dontNullOutVarsOfTypeNothing_t104(): Unit = {
implicit val ec: scala.concurrent.ExecutionContext = null
import scala.async.Async._
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global
def errorGenerator(randomNum: Double) = {
Future {
if (randomNum < 0) {
throw new IllegalStateException("Random number was too low!")
} else {
throw new IllegalStateException("Random number was too high!")
}
}
}
def randomTimesTwo = async {
val num = _root_.scala.math.random
if (num < 0 || num > 1) {
await(errorGenerator(num))
}
num * 2
}
Await.result(randomTimesTwo, TestLatch.DefaultTimeout) // was: NotImplementedError
}
}