Skip to content

Compilation error 'A is not class' when using generic parameters in async/await fututures. #94

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
wants to merge 2 commits into from
Closed
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/TransformUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private[async] trait TransformUtils {
(cls.info.decls.find(sym => sym.isMethod && sym.asTerm.isParamAccessor) getOrElse NoSymbol)

def mkZero(tp: Type): Tree = {
if (tp.typeSymbol.asClass.isDerivedValueClass) {
if (tp.typeSymbol.isClass && tp.typeSymbol.asClass.isDerivedValueClass) {
val argZero = mkZero(derivedValueClassUnbox(tp.typeSymbol).infoIn(tp).resultType)
val baseType = tp.baseType(tp.typeSymbol) // use base type here to dealias / strip phantom "tagged types" etc.

Expand Down
46 changes: 46 additions & 0 deletions src/test/scala/scala/async/run/gen0/AsyncSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package scala.async
package run
package gen0

import language.{reflectiveCalls, postfixOps}
import scala.concurrent.{Future, ExecutionContext, future, Await}
import scala.concurrent.duration._
import scala.async.Async.{async, await}
import org.junit.Test

class TestS[A](a:A)
{

def awrite(v:A): Future[A] =
Future successful v

def aread: Future[A] =
Future successful a

}

class Test1GenAsyncOp[A] {

import ExecutionContext.Implicits.global

def testfun[A](a1:A,a2:A): Future[Boolean] = async {
val ts = new TestS(a1)
val s1 = await(ts.awrite(a2))
val s2 = await(ts.aread)
s1 == s2
}

}


class AsyncSpec {

@Test
def `operation with futures generic`() {
val op = new Test1GenAsyncOp[Int]
val f = op.testfun(1,2)
val res = Await.result(f, 2 seconds)
res mustBe (false)
}

}