Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stanch opened this issue Mar 12, 2014 · 5 comments · Fixed by #64
Closed

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

stanch opened this issue Mar 12, 2014 · 5 comments · Fixed by #64
Assignees
Labels
Milestone

Comments

@stanch
Copy link

stanch commented Mar 12, 2014

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

@retronym
Copy link
Member

I've got a fair idea where the regression came from, but would really appreciate a standalone test case.

@stanch
Copy link
Author

stanch commented Mar 12, 2014

It’s here. Although now I realized that you need to have Android SDK installed. I’ll try to reduce it further.

@stanch
Copy link
Author

stanch commented Mar 12, 2014

Ok, take a look at this branch: https://github.com/macroid/macroid/blob/async-regression/src/main/scala/org/macroid/Bug.scala
I’ve removed everything except the failing bit. No dependencies besides scala-async.

retronym added a commit to retronym/async that referenced this issue Mar 12, 2014
Predicate the `asClass` cast with an `isClass` check.

Fixes scala#63
@retronym retronym added this to the 0.9.0-M6 milestone Mar 12, 2014
@retronym retronym added the bug label Mar 12, 2014
@retronym retronym self-assigned this Mar 12, 2014
@retronym
Copy link
Member

I just release 0.9.0-M6 with the fix for this bug. Thanks for the minimization!

@stanch
Copy link
Author

stanch commented Mar 12, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants