diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2017-02-08 12:20:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 12:20:08 -0800 |
commit | d6837aef059b6d2df1eac10284036ec1ed603a7b (patch) | |
tree | 5fb64cd1f4d78d22817aef46bace42c24d48a4af /src/compiler/scala/tools | |
parent | c5c391c7d698ed17e1b23c69025ed70f99f34f77 (diff) | |
parent | d55bad83108d030ef214d4a2477df66fffbbb8f5 (diff) | |
download | scala-d6837aef059b6d2df1eac10284036ec1ed603a7b.tar.gz scala-d6837aef059b6d2df1eac10284036ec1ed603a7b.tar.bz2 scala-d6837aef059b6d2df1eac10284036ec1ed603a7b.zip |
Merge pull request #5245 from dwijnand/trailing-commas
SI-4986 The glorious return of Comma McTraily
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index a8cc7f91c2..99713451ac 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -386,6 +386,17 @@ trait Scanners extends ScannersCommon { next copyFrom this this copyFrom prev } + } else if (token == COMMA) { + // SIP-27 Trailing Comma (multi-line only) support + // If a comma is followed by a new line & then a closing paren, bracket or brace + // then it is a trailing comma and is ignored + val saved = new ScannerData {} copyFrom this + fetchToken() + if (afterLineEnd() && (token == RPAREN || token == RBRACKET || token == RBRACE)) { + /* skip the trailing comma */ + } else if (token == EOF) { // e.g. when the REPL is parsing "val List(x, y, _*," + /* skip the trailing comma */ + } else this copyFrom saved } // print("["+this+"]") |