@@ -70,6 +70,9 @@ private[async] trait AnfTransform {
70
70
val stats :+ expr = anf.transformToList(tree)
71
71
def statsExprUnit =
72
72
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
+
73
76
expr match {
74
77
case Apply (fun, args) if isAwait(fun) =>
75
78
val valDef = defineVal(name.await, expr, tree.pos)
@@ -81,7 +84,7 @@ private[async] trait AnfTransform {
81
84
// TODO avoid creating a ValDef for the result of this await to avoid this tree shape altogether.
82
85
// This will require some deeper changes to the later parts of the macro which currently assume regular
83
86
// tree structure around `await` calls.
84
- gen.mkCast(ref, definitions.UnitTpe )
87
+ localTyper.typedPos(tree.pos)( gen.mkCast(ref, definitions.UnitTpe ) )
85
88
else ref
86
89
stats :+ valDef :+ atPos(tree.pos)(ref1)
87
90
@@ -90,6 +93,8 @@ private[async] trait AnfTransform {
90
93
// but add Unit value to bring it into form expected by async transform
91
94
if (expr.tpe =:= definitions.UnitTpe ) {
92
95
statsExprUnit
96
+ } else if (expr.tpe =:= definitions.NothingTpe ) {
97
+ statsExprThrow
93
98
} else {
94
99
val varDef = defineVar(name.ifRes, expr.tpe, tree.pos)
95
100
def branchWithAssign (orig : Tree ) = localTyper.typedPos(orig.pos) {
@@ -110,8 +115,9 @@ private[async] trait AnfTransform {
110
115
// but add Unit value to bring it into form expected by async transform
111
116
if (expr.tpe =:= definitions.UnitTpe ) {
112
117
statsExprUnit
113
- }
114
- else {
118
+ } else if (expr.tpe =:= definitions.NothingTpe ) {
119
+ statsExprThrow
120
+ } else {
115
121
val varDef = defineVar(name.matchRes, expr.tpe, tree.pos)
116
122
def typedAssign (lhs : Tree ) =
117
123
localTyper.typedPos(lhs.pos)(Assign (Ident (varDef.symbol), mkAttributedCastPreservingAnnotations(lhs, varDef.symbol.tpe)))
0 commit comments