Skip to content

Commit 4b78761

Browse files
committed
Drop as in patterns
1 parent 31751b9 commit 4b78761

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+70
-74
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,10 +2608,7 @@ object Parsers {
26082608
/** Pattern2 ::= [id `as'] InfixPattern
26092609
*/
26102610
val pattern2: () => Tree = () => infixPattern() match {
2611-
case p @ Ident(name) if in.token == AT || in.isIdent(nme.as) =>
2612-
if in.token == AT && sourceVersion.isAtLeast(`3.1`) then
2613-
deprecationWarning(s"`@` bindings have been deprecated; use `as` instead", in.offset)
2614-
2611+
case p @ Ident(name) if in.token == AT =>
26152612
val offset = in.skipToken()
26162613
infixPattern() match {
26172614
case pt @ Ident(tpnme.WILDCARD_STAR) => // compatibility for Scala2 `x @ _*` syntax
@@ -2638,8 +2635,7 @@ object Parsers {
26382635
/** InfixPattern ::= SimplePattern {id [nl] SimplePattern}
26392636
*/
26402637
def infixPattern(): Tree =
2641-
infixOps(simplePattern(), in.canStartExprTokens, simplePattern,
2642-
isOperator = in.name != nme.raw.BAR && in.name != nme.as)
2638+
infixOps(simplePattern(), in.canStartExprTokens, simplePattern, isOperator = in.name != nme.raw.BAR)
26432639

26442640
/** SimplePattern ::= PatVar
26452641
* | Literal

docs/docs/internals/syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [nl]
269269
270270
Pattern ::= Pattern1 { ‘|’ Pattern1 } Alternative(pats)
271271
Pattern1 ::= Pattern2 [‘:’ RefinedType] Bind(name, Typed(Ident(wildcard), tpe))
272-
Pattern2 ::= [id ‘as’] InfixPattern Bind(name, pat)
272+
Pattern2 ::= [id ‘@’] InfixPattern Bind(name, pat)
273273
InfixPattern ::= SimplePattern { id [nl] SimplePattern } InfixOp(pat, op, pat)
274274
SimplePattern ::= PatVar Ident(wildcard)
275275
| Literal Bind(name, Ident(wildcard))

library/src/scala/quoted/ExprMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ trait ExprMap:
4747
tree
4848
case Super(qual, mix) =>
4949
tree
50-
case tree as Apply(fun, args) =>
50+
case tree @ Apply(fun, args) =>
5151
val MethodType(_, tpes, _) = fun.tpe.widen
5252
Apply.copy(tree)(transformTerm(fun, TypeRepr.of[Any])(owner), transformTerms(args, tpes)(owner))
5353
case TypeApply(fun, args) =>

tests/init/crash/fors.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object Test extends App {
2626
var n = 0
2727
for (_ <- xs) n += 1; println(n)
2828
for ((x, y) <- xs zip ys) print(x + " "); println()
29-
for (p as (x, y) <- xs zip ys) print(p._1 + " "); println()
29+
for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println()
3030

3131
// iterators
3232
for (x <- it) print(x + " "); println()
@@ -53,7 +53,7 @@ object Test extends App {
5353
var n = 0
5454
for (_ <- xs) n += 1; println(n)
5555
for ((x, y) <- xs zip ys) print(x + " "); println()
56-
for (p as (x, y) <- xs zip ys) print(p._1 + " "); println()
56+
for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println()
5757

5858
// iterators
5959
for (x <- it) print(x + " "); println()

tests/neg/Iter3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ object Iter2 {
147147
flatten(map(f(_).buildIterator))
148148

149149
override def ++[B >: A](that: IterableOnce[B]): ArrayIterator[B] = {
150-
val thatIterator as ArrayIterator(elems2, len2) = fromIterator(that.iterator)
150+
val thatIterator @ ArrayIterator(elems2, len2) = fromIterator(that.iterator)
151151
if (len == 0) thatIterator
152152
else if (len2 == 0) this.asInstanceOf[ArrayIterator[B]]
153153
else {

tests/neg/ensureReported.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object AnonymousF {
22
val f = {
3-
case l as List(1) => // error: missing parameter type
3+
case l @ List(1) => // error: missing parameter type
44
Some(l)
55
}
66
}

tests/neg/i1716.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Fail {
22
def f(m: Option[Int]): Unit = {
33
m match {
4-
case x as Some[_] => // error: unbound wildcard type
4+
case x @ Some[_] => // error: unbound wildcard type
55
case _ =>
66
}
77
}

tests/neg/i3200.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object Test {
22
case object Bob { override def equals(other: Any) = true }
33
def main(args: Array[String]): Unit = {
4-
val m : Bob.type = (5: Any) match { case x as Bob => x } // error
4+
val m : Bob.type = (5: Any) match { case x @ Bob => x } // error
55
}
66
}

tests/neg/i3200b.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
object Test {
22
def main(args: Array[String]): Unit = {
3-
val a: Nil.type = (Vector(): Any) match { case n as Nil => n } // error
4-
val b: Nil.type = (Vector(): Any) match { case n as (m as Nil) => n } // error
5-
val c: Int = (1.0: Any) match { case n as 1 => n } // error
6-
val d: Int = (1.0: Any) match { case n as (m as 1) => n } // error
3+
val a: Nil.type = (Vector(): Any) match { case n @ Nil => n } // error
4+
val b: Nil.type = (Vector(): Any) match { case n @ (m @ Nil) => n } // error
5+
val c: Int = (1.0: Any) match { case n @ 1 => n } // error
6+
val d: Int = (1.0: Any) match { case n @ (m @ 1) => n } // error
77
}
88
}

tests/neg/i3332.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ object Test {
1616
case _ => println("nope")
1717
}
1818
def test(x: Any) = x match {
19-
case _: String | _ as A() => 1
19+
case _: String | _ @ A() => 1
2020
}
2121
}

0 commit comments

Comments
 (0)