Skip to content

Commit 845b981

Browse files
committed
Merge pull request #1297 from felixmulder/topic/add-position-switch
Fix #1292: give position when failing to emit switch on annotated match
2 parents a42377d + 07c5a0a commit 845b981

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,8 @@ object Scanners {
922922
getFraction()
923923
}
924924
} else (ch: @switch) match {
925-
case 'e' | 'E' | 'f' | 'F' | 'd' | 'D' if base == 10 =>
926-
getFraction()
925+
case 'e' | 'E' | 'f' | 'F' | 'd' | 'D' =>
926+
if (base == 10) getFraction()
927927
case 'l' | 'L' =>
928928
nextChar()
929929
token = LONGLIT

src/dotty/tools/dotc/printing/SyntaxHighlighting.scala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ object SyntaxHighlighting {
8989
append('<', { x => x == "<-" || x == "<:" || x == "<%" }, keyword)
9090
case '>' =>
9191
append('>', { x => x == ">:" }, keyword)
92-
case '#' if prev != ' ' && prev != '.' =>
93-
newBuf append keyword("#")
92+
case '#' =>
93+
if (prev != ' ' && prev != '.') newBuf append keyword("#")
94+
else newBuf += n
9495
prev = '#'
9596
case '@' =>
9697
appendWhile('@', _ != ' ', annotation)
@@ -100,12 +101,14 @@ object SyntaxHighlighting {
100101
appendLiteral('\'')
101102
case '`' =>
102103
appendTo('`', _ == '`', none)
103-
case c if c.isUpper && keywordStart =>
104-
appendWhile(c, !typeEnders.contains(_), typeDef)
105-
case c if numberStart(c) =>
106-
appendWhile(c, { x => x.isDigit || x == '.' || x == '\u0000'}, literal)
107-
case c =>
108-
newBuf += c; prev = c
104+
case _ => {
105+
if (n.isUpper && keywordStart)
106+
appendWhile(n, !typeEnders.contains(_), typeDef)
107+
else if (numberStart(n))
108+
appendWhile(n, { x => x.isDigit || x == '.' || x == '\u0000'}, literal)
109+
else
110+
newBuf += n; prev = n
111+
}
109112
}
110113
}
111114
}

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
434434
}
435435
} else {
436436
if (dealiased hasAnnotation defn.SwitchAnnot)
437-
ctx.warning("failed to emit switch for `@switch` annotated match")
437+
ctx.warning("failed to emit switch for `@switch` annotated match", scrut.pos)
438438
None
439439
}
440440
}

0 commit comments

Comments
 (0)