Skip to content

Commit 4ae76f2

Browse files
committed
Make phasesStack more robust
Got a "next on empty iterator" exception before.
1 parent 36f9133 commit 4ae76f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ trait Phases {
2626

2727
def phasesStack: List[Phase] =
2828
if ((this eq NoContext) || !phase.exists) Nil
29-
else phase :: outersIterator.dropWhile(_.phase == phase).next.phasesStack
29+
else {
30+
val rest = outersIterator.dropWhile(_.phase == phase)
31+
phase :: (if (rest.hasNext) rest.next.phasesStack else Nil)
32+
}
3033

3134
/** Execute `op` at given phase */
3235
def atPhase[T](phase: Phase)(op: Context => T): T =

0 commit comments

Comments
 (0)