@@ -70,6 +70,9 @@ private[async] trait AnfTransform {
7070 val stats :+ expr = anf.transformToList(tree)
7171 def statsExprUnit =
7272 stats :+ expr :+ localTyper.typedPos(expr.pos)(Literal (Constant (())))
73+ def statsExprThrow =
74+ stats :+ expr :+ localTyper.typedPos(expr.pos)(Throw (Apply (Select (New (gen.mkAttributedRef(defn.IllegalStateExceptionClass )), nme.CONSTRUCTOR ), Nil )))
75+
7376 expr match {
7477 case Apply (fun, args) if isAwait(fun) =>
7578 val valDef = defineVal(name.await, expr, tree.pos)
@@ -81,7 +84,7 @@ private[async] trait AnfTransform {
8184 // TODO avoid creating a ValDef for the result of this await to avoid this tree shape altogether.
8285 // This will require some deeper changes to the later parts of the macro which currently assume regular
8386 // tree structure around `await` calls.
84- gen.mkCast(ref, definitions.UnitTpe )
87+ localTyper.typedPos(tree.pos)( gen.mkCast(ref, definitions.UnitTpe ) )
8588 else ref
8689 stats :+ valDef :+ atPos(tree.pos)(ref1)
8790
@@ -90,6 +93,8 @@ private[async] trait AnfTransform {
9093 // but add Unit value to bring it into form expected by async transform
9194 if (expr.tpe =:= definitions.UnitTpe ) {
9295 statsExprUnit
96+ } else if (expr.tpe =:= definitions.NothingTpe ) {
97+ statsExprThrow
9398 } else {
9499 val varDef = defineVar(name.ifRes, expr.tpe, tree.pos)
95100 def branchWithAssign (orig : Tree ) = localTyper.typedPos(orig.pos) {
@@ -110,8 +115,9 @@ private[async] trait AnfTransform {
110115 // but add Unit value to bring it into form expected by async transform
111116 if (expr.tpe =:= definitions.UnitTpe ) {
112117 statsExprUnit
113- }
114- else {
118+ } else if (expr.tpe =:= definitions.NothingTpe ) {
119+ statsExprThrow
120+ } else {
115121 val varDef = defineVar(name.matchRes, expr.tpe, tree.pos)
116122 def typedAssign (lhs : Tree ) =
117123 localTyper.typedPos(lhs.pos)(Assign (Ident (varDef.symbol), mkAttributedCastPreservingAnnotations(lhs, varDef.symbol.tpe)))
0 commit comments