File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,9 @@ object Parsers {
164164 def isDefIntro (allowedMods : BitSet ) =
165165 in.token == AT || (allowedMods contains in.token) || (defIntroTokens contains in.token)
166166
167+ def isCaseIntro =
168+ in.token == AT || (modifierTokensOrCase contains in.token)
169+
167170 def isStatSep : Boolean =
168171 in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
169172
@@ -2244,12 +2247,18 @@ object Parsers {
22442247 Thicket (clsDef :: modDef :: Nil )
22452248 }
22462249
2247- /** EnumCaseStats = EnumCaseStat {semi EnumCaseStat */
2250+ /** EnumCaseStats = EnumCaseStat {semi EnumCaseStat} */
22482251 def enumCaseStats (): List [DefTree ] = {
22492252 val cases = new ListBuffer [DefTree ] += enumCaseStat()
2250- while (in.token != RBRACE && in.token != EOF ) {
2253+ var exitOnError = false
2254+ while (! isStatSeqEnd && ! exitOnError) {
22512255 acceptStatSep()
2252- cases += enumCaseStat()
2256+ if (isCaseIntro)
2257+ cases += enumCaseStat()
2258+ else if (! isStatSep) {
2259+ exitOnError = mustStartStat
2260+ syntaxErrorOrIncomplete(" illegal start of case" )
2261+ }
22532262 }
22542263 cases.toList
22552264 }
Original file line number Diff line number Diff line change 1+ enum
2+ object // error // error
You can’t perform that action at this time.
0 commit comments