Skip to content

Commit d5a7131

Browse files
committed
Disable rewrites in OutlineParser
1 parent 28915c4 commit d5a7131

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ object Parsers {
169169
}
170170
}
171171

172-
class Parser(source: SourceFile)(using Context) extends ParserCommon(source) {
172+
class Parser(source: SourceFile, allowRewrite: Boolean = true)(using Context) extends ParserCommon(source) {
173173

174-
val in: Scanner = new Scanner(source, profile = Profile.current)
174+
val in: Scanner = new Scanner(source, profile = Profile.current, allowRewrite = allowRewrite)
175175
// in.debugTokenStream = true // uncomment to see the token stream of the standard scanner, but not syntax highlighting
176176

177177
/** This is the general parse entry point.
@@ -4361,7 +4361,7 @@ object Parsers {
43614361
/** OutlineParser parses top-level declarations in `source` to find declared classes, ignoring their bodies (which
43624362
* must only have balanced braces). This is used to map class names to defining sources.
43634363
*/
4364-
class OutlineParser(source: SourceFile)(using Context) extends Parser(source) with OutlineParserCommon {
4364+
class OutlineParser(source: SourceFile)(using Context) extends Parser(source, allowRewrite = false) with OutlineParserCommon {
43654365

43664366
def skipBracesHook(): Option[Tree] =
43674367
if (in.token == XMLSTART) Some(xmlLiteral()) else None

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ object Scanners {
170170
errorButContinue(em"trailing separator is not allowed", offset + litBuf.length - 1)
171171
}
172172

173-
class Scanner(source: SourceFile, override val startFrom: Offset = 0, profile: Profile = NoProfile, allowIndent: Boolean = true)(using Context) extends ScannerCommon(source) {
173+
class Scanner(source: SourceFile, override val startFrom: Offset = 0, profile: Profile = NoProfile, allowRewrite: Boolean = true, allowIndent: Boolean = true)(using Context) extends ScannerCommon(source) {
174174
val keepComments = !ctx.settings.YdropComments.value
175175

176176
/** A switch whether operators at the start of lines can be infix operators */
@@ -179,7 +179,7 @@ object Scanners {
179179
var debugTokenStream = false
180180
val showLookAheadOnDebug = false
181181

182-
val rewrite = ctx.settings.rewrite.value.isDefined
182+
val rewrite = allowRewrite && ctx.settings.rewrite.value.isDefined
183183
val oldSyntax = ctx.settings.oldSyntax.value
184184
val newSyntax = ctx.settings.newSyntax.value
185185

0 commit comments

Comments
 (0)