File tree 2 files changed +20
-4
lines changed
main/scala/scala/async/internal
test/scala/scala/async/run/toughtype
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 {
331
331
(cls.info.decls.find(sym => sym.isMethod && sym.asTerm.isParamAccessor) getOrElse NoSymbol )
332
332
333
333
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.
337
338
338
339
// By explicitly attributing the types and symbols here, we subvert privacy.
339
340
// Otherwise, ticket86PrivateValueClass would fail.
@@ -342,7 +343,7 @@ private[async] trait TransformUtils {
342
343
// q"new ${valueClass}[$..targs](argZero)"
343
344
val target : Tree = gen.mkAttributedSelect(
344
345
c.typecheck(atMacroPos(
345
- New (TypeTree (baseType)))), tp.typeSymbol .asClass.primaryConstructor)
346
+ New (TypeTree (baseType)))), tpSym .asClass.primaryConstructor)
346
347
347
348
val zero = gen.mkMethodCall(target, argZero :: Nil )
348
349
Original file line number Diff line number Diff line change @@ -304,6 +304,21 @@ class ToughTypeSpec {
304
304
val result = Await .result(fut, 5 .seconds)
305
305
result mustBe None
306
306
}
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
+ }
307
322
}
308
323
309
324
class IntWrapper (val value : String ) extends AnyVal {
You can’t perform that action at this time.
0 commit comments