File tree 2 files changed +14
-3
lines changed
compiler/src/dotty/tools/dotc/parsing
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,9 @@ object Parsers {
164
164
def isDefIntro (allowedMods : BitSet ) =
165
165
in.token == AT || (allowedMods contains in.token) || (defIntroTokens contains in.token)
166
166
167
+ def isCaseIntro =
168
+ in.token == AT || (modifierTokensOrCase contains in.token)
169
+
167
170
def isStatSep : Boolean =
168
171
in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
169
172
@@ -2244,12 +2247,18 @@ object Parsers {
2244
2247
Thicket (clsDef :: modDef :: Nil )
2245
2248
}
2246
2249
2247
- /** EnumCaseStats = EnumCaseStat {semi EnumCaseStat */
2250
+ /** EnumCaseStats = EnumCaseStat {semi EnumCaseStat} */
2248
2251
def enumCaseStats (): List [DefTree ] = {
2249
2252
val cases = new ListBuffer [DefTree ] += enumCaseStat()
2250
- while (in.token != RBRACE && in.token != EOF ) {
2253
+ var exitOnError = false
2254
+ while (! isStatSeqEnd && ! exitOnError) {
2251
2255
acceptStatSep()
2252
- cases += enumCaseStat()
2256
+ if (isCaseIntro)
2257
+ cases += enumCaseStat()
2258
+ else if (! isStatSep) {
2259
+ exitOnError = mustStartStat
2260
+ syntaxErrorOrIncomplete(" illegal start of case" )
2261
+ }
2253
2262
}
2254
2263
cases.toList
2255
2264
}
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