-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make type of type hole available in quoted patterns #10045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+6 −6 | scalatest.dotty/src/main/scala/org/scalatest/diagrams/DiagramsMacro.scala |
+1 −1 | modules/deriving/src/main/scala/shapeless3/deriving/annotation.scala |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ inline def mcr(x: => Any): Any = ${mcrImpl('x)} | |
|
||
def mcrImpl(body: Expr[Any])(using ctx: QuoteContext): Expr[Any] = | ||
body match | ||
case '{$x: $t} => | ||
case '{$x: $T} => | ||
'{ | ||
val tmp: $t = $x | ||
val tmp: T = $x | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not as symmetric as before. I think meta-programmers will be at a loss about whether to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not symmetric because it is not intended to be as quoted types do not follow the same level symmetry that expression do. The syntax |
||
println(tmp) | ||
tmp | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import scala.quoted._ | ||
class Foo { | ||
def f[T2](t: Type[T2])(using QuoteContext) = t match { | ||
case '[ *:[Int, $t] ] => | ||
'[ *:[Int, $t] ] | ||
case '[ *:[Int, $T] ] => | ||
'[ *:[Int, T] ] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import scala.quoted._ | ||
class Foo { | ||
def f[T2: Type](e: Expr[T2])(using QuoteContext) = e match { | ||
case '{ $x: $t0 } => | ||
t0 match | ||
case '[ *:[Int, $t] ] => | ||
'[ *:[Int, $t] ] | ||
case '{ $x: $T0 } => | ||
Type[T0] match | ||
case '[ *:[Int, $T] ] => | ||
'[ *:[Int, T] ] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The renaming makes everything much more clear 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. The scalability concern made me realize that it was just a misnomer.