Skip to content

Commit 69c2824

Browse files
committed
Fix handling of end markers for nested packages
1 parent 1f377c1 commit 69c2824

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3716,23 +3716,23 @@ object Parsers {
37163716
ts ++= topStatSeq()
37173717
}
37183718
}
3719-
else {
3719+
else
37203720
val pkg = qualId()
3721+
var continue = false
37213722
indentRegion(pkg) {
37223723
possibleTemplateStart()
3723-
if (in.token == EOF)
3724+
if in.token == EOF then
37243725
ts += makePackaging(start, pkg, List())
3725-
else if (in.isNestedStart) {
3726+
else if in.isNestedStart then
37263727
ts += inDefScopeBraces(makePackaging(start, pkg, topStatSeq()))
3727-
acceptStatSepUnlessAtEnd()
3728-
ts ++= topStatSeq()
3729-
}
3730-
else {
3728+
continue = true
3729+
else
37313730
acceptStatSep()
37323731
ts += makePackaging(start, pkg, topstats())
3733-
}
37343732
}
3735-
}
3733+
if continue then
3734+
acceptStatSepUnlessAtEnd()
3735+
ts ++= topStatSeq()
37363736
}
37373737
else
37383738
ts ++= topStatSeq()

tests/pos/packagings.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package foo with
2+
package bar with
3+
object A with
4+
def foo = 1
5+
end bar
6+
end foo
7+
package baz with
8+
object B with
9+
def f = foo.bar.A.foo
10+
end baz

0 commit comments

Comments
 (0)