-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use Labeled
blocks in TailRec
, instead of label-defs.
#5115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -452,6 +452,11 @@ class TreeChecker extends Phase with SymTransformer { | |
tree1 | ||
} | ||
|
||
override def typedWhileDo(tree: untpd.WhileDo)(implicit ctx: Context): Tree = { | ||
assert((tree.cond ne EmptyTree) || ctx.phase.refChecked, i"invalid empty condition in while at $tree") | ||
super.typedWhileDo(tree) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here is the addition of an explicit |
||
|
||
override def ensureNoLocalRefs(tree: Tree, pt: Type, localSyms: => List[Symbol])(implicit ctx: Context): Tree = | ||
tree | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -486,7 +486,7 @@ trait TypeAssigner { | |
tree.withType(defn.NothingType) | ||
|
||
def assignType(tree: untpd.WhileDo)(implicit ctx: Context): WhileDo = | ||
tree.withType(defn.UnitType) | ||
tree.withType(if (tree.cond eq EmptyTree) defn.NothingType else defn.UnitType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this occur ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we want a way to represent an infinite |
||
|
||
def assignType(tree: untpd.Try, expr: Tree, cases: List[CaseDef])(implicit ctx: Context): Try = | ||
if (cases.isEmpty) tree.withType(expr.tpe) | ||
|
+4 −6 | src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
ctx.phase.refChecked
? Why not an equivalent method forTailRec
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it existed, and the only requirement is that an infinite loop must not be pickled. It doesn't have anything to do with tailrec per se.