Skip to content

Commit 3132ab0

Browse files
committed
Merge pull request #64 from retronym/ticket/63
Fix "not a class" crasher in live variable analysis
2 parents 6ced55d + 6f6546e commit 3132ab0

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/main/scala/scala/async/internal/LiveVariables.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ trait LiveVariables {
5555

5656
// determine which fields should be live also at the end (will not be nulled out)
5757
val noNull: Set[Symbol] = liftedSyms.filter { sym =>
58-
tpe(sym).typeSymbol.asClass.isPrimitive || liftables.exists { tree =>
58+
val typeSym = tpe(sym).typeSymbol
59+
(typeSym.isClass && typeSym.asClass.isPrimitive) || liftables.exists { tree =>
5960
!liftedSyms.contains(tree.symbol) && tree.exists(_.symbol == sym)
6061
}
6162
}

src/test/scala/scala/async/run/toughtype/ToughType.scala

+28
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,34 @@ class ToughTypeSpec {
184184
}
185185
Bippy
186186
}
187+
188+
@Test
189+
def ticket63(): Unit = {
190+
import scala.async.Async._
191+
import scala.concurrent.{ ExecutionContext, Future }
192+
193+
object SomeExecutionContext extends ExecutionContext {
194+
def reportFailure(t: Throwable): Unit = ???
195+
def execute(runnable: Runnable): Unit = ???
196+
}
197+
198+
trait FunDep[W, S, R] {
199+
def method(w: W, s: S): Future[R]
200+
}
201+
202+
object FunDep {
203+
implicit def `Something to do with List`[W, S, R](implicit funDep: FunDep[W, S, R]) =
204+
new FunDep[W, List[S], W] {
205+
def method(w: W, l: List[S]) = async {
206+
val it = l.iterator
207+
while (it.hasNext) {
208+
await(funDep.method(w, it.next()))
209+
}
210+
w
211+
}(SomeExecutionContext)
212+
}
213+
}
214+
}
187215
}
188216

189217
trait A

0 commit comments

Comments
 (0)