Skip to content

Commit 1c39c8a

Browse files
committed
Drop with + <indent> syntax
It's now `:` instead of the trailing `with`.
1 parent 9ea94d8 commit 1c39c8a

File tree

5 files changed

+6
-13
lines changed

5 files changed

+6
-13
lines changed
Submodule intent updated 34 files

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -646,15 +646,13 @@ object Parsers {
646646
else body()
647647
case _ => body()
648648

649-
/** If indentation is not significant, check that this is not the start of a
650-
* statement that's indented relative to the current region.
651-
* TODO: Drop if `with` is required before indented template definitions.
649+
/** Check that this is not the start of a statement that's indented relative to the current region.
652650
*/
653651
def checkNextNotIndented(): Unit = in.currentRegion match
654652
case r: IndentSignificantRegion if in.isNewLine =>
655653
val nextIndentWidth = in.indentWidth(in.next.offset)
656654
if r.indentWidth < nextIndentWidth then
657-
warning(i"Line is indented too far to the right, or a `{` is missing", in.next.offset)
655+
warning(i"Line is indented too far to the right, or a `{` or `:` is missing", in.next.offset)
658656
case _ =>
659657

660658
/* -------- REWRITES ----------------------------------------------------------- */
@@ -1292,10 +1290,6 @@ object Parsers {
12921290
in.nextToken()
12931291
if in.token != INDENT then
12941292
syntaxError(i"indented definitions expected")
1295-
else if in.token == WITH then
1296-
in.nextToken()
1297-
if in.token != LBRACE && in.token != INDENT then
1298-
syntaxError(i"indented definitions or `{` expected")
12991293
else
13001294
newLineOptWhenFollowedBy(LBRACE)
13011295

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ object Tokens extends TokensCommon {
257257
AT, CASE)
258258

259259
final val canEndStatTokens: TokenSet = atomicExprTokens | BitSet(
260-
TYPE, GIVEN, RPAREN, RBRACE, RBRACKET, OUTDENT) // TODO: remove GIVEN once old import syntax is dropped
260+
TYPE, RPAREN, RBRACE, RBRACKET, OUTDENT) // TODO: remove GIVEN once old import syntax is dropped
261261

262262
/** Tokens that stop a lookahead scan search for a `<-`, `then`, or `do`.
263263
* Used for disambiguating between old and new syntax.
@@ -272,7 +272,7 @@ object Tokens extends TokensCommon {
272272
final val closingRegionTokens = BitSet(RBRACE, CASE) | statCtdTokens
273273

274274
final val canStartIndentTokens: BitSet =
275-
statCtdTokens | BitSet(COLONEOL, EQUALS, ARROW, LARROW, WHILE, TRY, FOR, IF, WITH)
275+
statCtdTokens | BitSet(COLONEOL, EQUALS, ARROW, LARROW, WHILE, TRY, FOR, IF)
276276
// `if` is excluded because it often comes after `else` which makes for awkward indentation rules TODO: try to do without the exception
277277

278278
/** Faced with the choice between a type and a formal parameter, the following

compiler/test/dotty/tools/dotc/semanticdb/SemanticdbTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class SemanticdbTests:
121121

122122
end SemanticdbTests
123123

124-
object SemanticdbTests with
124+
object SemanticdbTests:
125125
/** Prettyprint a text document with symbol occurrences next to each resolved identifier.
126126
*
127127
* Useful for testing purposes to ensure that SymbolOccurrence values make sense and are correct.

tests/pos/new-with.scala

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)