File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -1012,22 +1012,20 @@ object Parsers {
1012
1012
val tryOffset = in.offset
1013
1013
atPos(in.skipToken()) {
1014
1014
val body = expr()
1015
- val handler =
1015
+ val ( handler, handlerStart) =
1016
1016
if (in.token == CATCH ) {
1017
+ val pos = in.offset
1017
1018
in.nextToken()
1018
- expr()
1019
- } else EmptyTree
1020
-
1021
- // A block ends before RBRACE, if next token is RBRACE, simply add 1
1022
- def realEnd (pos : Position ) =
1023
- if (in.token == RBRACE ) pos.end + 1
1024
- else pos.end
1019
+ (expr(), pos)
1020
+ } else (EmptyTree , - 1 )
1025
1021
1026
1022
handler match {
1027
- case Block (Nil , EmptyTree ) => syntaxError(
1028
- new EmptyCatchBlock (body),
1029
- Position (tryOffset, realEnd(handler.pos))
1030
- )
1023
+ case Block (Nil , EmptyTree ) =>
1024
+ assert(handlerStart != - 1 )
1025
+ syntaxError(
1026
+ new EmptyCatchBlock (body),
1027
+ Position (handlerStart, handler.pos.end)
1028
+ )
1031
1029
case _ =>
1032
1030
}
1033
1031
@@ -1036,7 +1034,7 @@ object Parsers {
1036
1034
else {
1037
1035
if (handler.isEmpty) warning(
1038
1036
EmptyCatchAndFinallyBlock (body),
1039
- source atPos Position (tryOffset, realEnd( body.pos) )
1037
+ source atPos Position (tryOffset, body.pos.end )
1040
1038
)
1041
1039
EmptyTree
1042
1040
}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ extends interfaces.SourcePosition {
17
17
18
18
/** The lines of the position */
19
19
def lines : List [Int ] =
20
- List .range(source.offsetToLine(start), source.offsetToLine(end)) match {
20
+ List .range(source.offsetToLine(start), source.offsetToLine(end + 1 )) match {
21
21
case Nil => line :: Nil
22
22
case xs => xs
23
23
}
You can’t perform that action at this time.
0 commit comments