Skip to content

Commit ae05ac1

Browse files
committed
chore: add support for *unqualified selectors* in patterns
1 parent 3dad816 commit ae05ac1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3291,7 +3291,7 @@ object Parsers {
32913291
* | SimplePattern1 [TypeArgs] [ArgumentPatterns]
32923292
* | ‘given’ RefinedType
32933293
* SimplePattern1 ::= SimpleRef
3294-
* | SimplePattern1 `.' id
3294+
* | [SimplePattern1] `.' id
32953295
* PatVar ::= id
32963296
* | `_'
32973297
*/
@@ -3308,6 +3308,9 @@ object Parsers {
33083308
simpleExpr(Location.InPattern)
33093309
case XMLSTART =>
33103310
xmlLiteralPattern()
3311+
case DOT =>
3312+
accept(DOT)
3313+
simplePatternRest(selector(EmptyTree))
33113314
case GIVEN =>
33123315
atSpan(in.offset) {
33133316
val givenMod = atSpan(in.skipToken())(Mod.Given())

tests/pos/unqualified-selector-enum.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ enum Opt[+T]:
22
case none extends Opt[Nothing]
33
case some[T](value: T) extends Opt[T]
44

5+
def map[U](f: T => U): Opt[U] = this match
6+
case .none => .none
7+
case Opt.some(v) => .some(f(v)) // TODO: This should be `case .some(v) => .some(f(v))`
8+
end map
9+
510
object Proxy:
611
def opt(o: Opt[Int]): Opt[Int] = o
712

0 commit comments

Comments
 (0)