-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile quote patterns directly into QuotePattern AST
Fixes #18125
- Loading branch information
1 parent
8abb383
commit cb2bdff
Showing
7 changed files
with
141 additions
and
302 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
367 changes: 67 additions & 300 deletions
367
compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import scala.quoted.* | ||
|
||
final class Foo[T](ns: T) | ||
|
||
def foo(using Quotes)(x: Expr[Any]): Unit = | ||
x match | ||
case '{ new Foo($y: b) } => | ||
case '{ new Foo($y: List[b]) } => | ||
case '{ type b; new Foo($y: b) } => | ||
|
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,23 @@ | ||
package oolong.phobos | ||
|
||
import scala.quoted.* | ||
import scala.compiletime.* | ||
import scala.annotation.StaticAnnotation | ||
|
||
final class xmlns[T](ns: T) extends StaticAnnotation | ||
trait Namespace[T]{ | ||
val getNamespace: String | ||
} | ||
|
||
object common{ | ||
private def extractFeildNamespace(using Quotes)( | ||
fieldAnnotations: List[Expr[Any]], | ||
): Expr[Option[String]] = { | ||
import quotes.reflect.* | ||
|
||
fieldAnnotations.collect { case '{ xmlns($namespace: b) } => | ||
'{ Some(summonInline[Namespace[b]].getNamespace) } | ||
} | ||
??? | ||
} | ||
} |
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,11 @@ | ||
import scala.deriving._ | ||
import scala.quoted._ | ||
|
||
private def derivedExpr[T](mirrorExpr: Expr[Mirror.Of[T]])(using Quotes, Type[T]): Expr[Any] = { | ||
mirrorExpr match { | ||
case '{ $mirrorExpr : Mirror.Sum { type MirroredElemTypes = mirroredElemTypes } } => | ||
'{ liftableSum[mirroredElemTypes]($mirrorExpr) } | ||
} | ||
} | ||
|
||
def liftableSum[MElemTypes](mirror: Mirror.Sum { type MirroredElemTypes = MElemTypes }): Any = ??? |