From 1e565d879360709758950332c19a77fffee073d1 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Tue, 15 Mar 2016 13:24:55 -0700 Subject: SI-8044 Allow any id in explicit pattern binding Allows arbitrary identifier in `X @ pat`, including non-varids. This goes to regularity. Users of this syntax are not likely to be confused by the "backquoted var id is stable" rule. Also for sequence pattern, `X @ _*`. --- test/files/pos/t8044.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/files') diff --git a/test/files/pos/t8044.scala b/test/files/pos/t8044.scala index 8259f06a8a..2519a8306b 100644 --- a/test/files/pos/t8044.scala +++ b/test/files/pos/t8044.scala @@ -4,4 +4,12 @@ trait T { def g = 42 match { case `type` @ _ => `type` } def h = 42 match { case `type` : Int => `type` } def i = (null: Any) match { case _: Int | _: String => 17 } + + // arbitrary idents allowed in @ syntax + def j = "Fred" match { case Name @ (_: String) => Name } + def k = "Fred" match { case * @ (_: String) => * } + + // also in sequence pattern + def m = List(1,2,3,4,5) match { case List(1, `Rest of them` @ _*) => `Rest of them` } + } -- cgit v1.2.3