Skip to content

Commit b79c9ad

Browse files
committed
Don't set the body of If to the original type.
Tweak the way we set tpe = Unit in matches.
1 parent 021e7c4 commit b79c9ad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/scala/scala/async/internal/AnfTransform.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private[async] trait AnfTransform {
8686
case Block(thenStats, thenExpr) => Block(thenStats, Assign(Ident(varDef.symbol), cast(thenExpr)))
8787
case _ => Assign(Ident(varDef.symbol), cast(orig))
8888
}
89-
}.setType(orig.tpe)
89+
}
9090
val ifWithAssign = treeCopy.If(tree, cond, branchWithAssign(thenp), branchWithAssign(elsep)).setType(definitions.UnitTpe)
9191
stats :+ varDef :+ ifWithAssign :+ gen.mkAttributedStableRef(varDef.symbol).setType(tree.tpe).setPos(tree.pos)
9292
}
@@ -104,10 +104,10 @@ private[async] trait AnfTransform {
104104
val casesWithAssign = cases map {
105105
case cd@CaseDef(pat, guard, body) =>
106106
val newBody = body match {
107-
case b@Block(caseStats, caseExpr) => treeCopy.Block(b, caseStats, typedAssign(caseExpr))
107+
case b@Block(caseStats, caseExpr) => treeCopy.Block(b, caseStats, typedAssign(caseExpr)).setType(definitions.UnitTpe)
108108
case _ => typedAssign(body)
109109
}
110-
treeCopy.CaseDef(cd, pat, guard, newBody.setType(definitions.UnitTpe)).setType(definitions.UnitTpe)
110+
treeCopy.CaseDef(cd, pat, guard, newBody).setType(definitions.UnitTpe)
111111
}
112112
val matchWithAssign = treeCopy.Match(tree, scrut, casesWithAssign).setType(definitions.UnitTpe)
113113
require(matchWithAssign.tpe != null, matchWithAssign)

0 commit comments

Comments
 (0)