forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quoted pattern type variables without backticks
With this change we can support references to quote pattern type variables without backticks. ```scala case '{ type t; ... : F[t] } ``` SIP: https://github.com/scala/improvement-proposals/blob/main/content/quote-pattern-type-variable-syntax.md?plain=1#L66-L70 ```scala case '{ ... : F[t, t] } ``` SIP: https://github.com/scala/improvement-proposals/blob/main/content/quote-pattern-type-variable-syntax.md?plain=1#L72-L78
- Loading branch information
1 parent
fe08f5f
commit 3958ee7
Showing
6 changed files
with
125 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/neg-custom-args/no-experimental/sip-53-exprimental-a.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import scala.quoted.* | ||
|
||
def foo(using Quotes): Unit = | ||
(??? : Type[?]) match | ||
case '[ (t, t, t) ] => // error // error | ||
'{ ??? : Any } match | ||
case '{ type u; $x: u } => // error | ||
case '{ type u; ($ls: List[u]).map($f: u => Int) } => // error // error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/pos-macros/quote-pattern-type-variable-no-escape.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import scala.quoted.* | ||
|
||
def foo[T: Type](expr: Expr[Any])(using Quotes): Any = | ||
expr match | ||
case '{ $x: Map[t, t] } => | ||
case '{ type t; $x: Any } => | ||
case '{ type t; $x: Map[t, t] } => | ||
case '{ ($x: Set[t]).toSet[t] } => | ||
|
||
Type.of[T] match | ||
case '[Map[t, t]] => | ||
case '[(t, t, t, t, t, t, t)] => |