Skip to content

“type [...] is not a class” on 2.11.0-RC1 #63

Closed
@stanch

Description

@stanch

Hi,

I have roughly the following things:

class Ui[+A](protected val v: ()  A) {
  /** Run the code on the UI thread */
  def run: Future[A] = ...
  /** Get the result of executing the code on the current thread */
  def get: A = ...
}

trait CanSnail[W, S, R] {
  def snail(w: W, s: S): Ui[Future[R]]
}

implicit def `List is snailable`[W, S, R](implicit canSnail: CanSnail[W, S, R]) =
  new CanSnail[List[W], S, List[W]] {
    def snail(l: List[W], s: S) = Ui(async {
      val it = l.iterator
      while (it.hasNext) {
        // we can call Ui.get, since we are already inside the UI thread
        await(canSnail.snail(it.next(), s).get)
      }
      l
    }(UiThreadExecutionContext))
  }

On Scala 2.11.0-RC1 (but not 2.10.3) it fails with

scala.ScalaReflectionException: type R is not a class
[error]     at scala.reflect.api.Symbols$SymbolApi$class.asClass(Symbols.scala:272)
[error]     at scala.reflect.internal.Symbols$SymbolContextApiImpl.asClass(Symbols.scala:82)
[error]     at scala.async.internal.LiveVariables$$anonfun$3.apply(LiveVariables.scala:58)
[error]     at scala.async.internal.LiveVariables$$anonfun$3.apply(LiveVariables.scala:57)
[error]     at scala.collection.TraversableLike$$anonfun$filterImpl$1.apply(TraversableLike.scala:259)
[error]     at scala.collection.immutable.Set$Set2.foreach(Set.scala:113)
[error]     at scala.collection.TraversableLike$class.filterImpl(TraversableLike.scala:258)
[error]     at scala.collection.TraversableLike$class.filter(TraversableLike.scala:270)
[error]     at scala.collection.AbstractTraversable.filter(Traversable.scala:104)
[error]     at scala.async.internal.LiveVariables$class.liveVars(LiveVariables.scala:57)
[error]     at scala.async.internal.AsyncMacro$$anon$1.liveVars(AsyncMacro.scala:6)
[error]     at scala.async.internal.LiveVariables$class.fieldsToNullOut(LiveVariables.scala:20)
[error]     at scala.async.internal.AsyncMacro$$anon$1.fieldsToNullOut(AsyncMacro.scala:6)
[error]     at scala.async.internal.AsyncTransform$class.asyncTransform(AsyncTransform.scala:76)
[error]     at scala.async.internal.AsyncMacro$$anon$1.asyncTransform(AsyncMacro.scala:6)
[error]     at scala.async.internal.AsyncBase.asyncImpl(AsyncBase.scala:48)
[error]     at scala.async.internal.ScalaConcurrentAsync$.asyncImpl(ScalaConcurrentAsync.scala:16)
[error]       }(UiThreadExecutionContext))
[error]        ^

I’m using async milestone M5 on both. Perhaps a regression somewhere?
I’ll be able to push the complete code tomorrow, if that’s necessary.

Nick

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions