File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
main/scala/scala/async/internal
test/scala/scala/async/run/toughtype Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -331,9 +331,10 @@ private[async] trait TransformUtils {
331331 (cls.info.decls.find(sym => sym.isMethod && sym.asTerm.isParamAccessor) getOrElse NoSymbol )
332332
333333 def mkZero (tp : Type ): Tree = {
334- if (tp.typeSymbol.asClass.isDerivedValueClass) {
335- val argZero = mkZero(derivedValueClassUnbox(tp.typeSymbol).infoIn(tp).resultType)
336- val baseType = tp.baseType(tp.typeSymbol) // use base type here to dealias / strip phantom "tagged types" etc.
334+ val tpSym = tp.typeSymbol
335+ if (tpSym.isClass && tpSym.asClass.isDerivedValueClass) {
336+ val argZero = mkZero(derivedValueClassUnbox(tpSym).infoIn(tp).resultType)
337+ val baseType = tp.baseType(tpSym) // use base type here to dealias / strip phantom "tagged types" etc.
337338
338339 // By explicitly attributing the types and symbols here, we subvert privacy.
339340 // Otherwise, ticket86PrivateValueClass would fail.
@@ -342,7 +343,7 @@ private[async] trait TransformUtils {
342343 // q"new ${valueClass}[$..targs](argZero)"
343344 val target : Tree = gen.mkAttributedSelect(
344345 c.typecheck(atMacroPos(
345- New (TypeTree (baseType)))), tp.typeSymbol .asClass.primaryConstructor)
346+ New (TypeTree (baseType)))), tpSym .asClass.primaryConstructor)
346347
347348 val zero = gen.mkMethodCall(target, argZero :: Nil )
348349
Original file line number Diff line number Diff line change @@ -304,6 +304,21 @@ class ToughTypeSpec {
304304 val result = Await .result(fut, 5 .seconds)
305305 result mustBe None
306306 }
307+
308+ @ Test def awaitOfAbstractType (): Unit = {
309+ import ExecutionContext .Implicits .global
310+
311+ def combine [A ](a1 : A , a2 : A ): A = a1
312+
313+ def combineAsync [A ](a1 : Future [A ], a2 : Future [A ]) = async {
314+ combine(await(a1), await(a2))
315+ }
316+
317+ val fut = combineAsync(Future (1 ), Future (2 ))
318+
319+ val result = Await .result(fut, 5 .seconds)
320+ result mustEqual 1
321+ }
307322}
308323
309324class IntWrapper (val value : String ) extends AnyVal {
You can’t perform that action at this time.
0 commit comments