Skip to content

Commit cda3cf0

Browse files
committed
wip
1 parent 42da4cb commit cda3cf0

File tree

7 files changed

+36
-53
lines changed

7 files changed

+36
-53
lines changed

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,11 @@ class ReifyQuotes extends MacroTransform {
175175
}
176176

177177
if (isType) {
178-
// FIXME: suppot tag
179-
// def tag(tagName: String) = ref(defn.QuotedTypeModule).select(tagName.toTermName)
180-
// if (splices.isEmpty && body.symbol.isPrimitiveValueClass) tag(s"${body.symbol.name}Tag")
181-
// else
182-
183-
quote match
184-
case TypeApply(Select(Select(scope, _), _), _) => pickleAsTasty().select(nme.apply).appliedTo(scope)
185-
case _ => pickleAsTasty() // FIXME remove this case
178+
val TypeApply(Select(Select(scope, _), _), _) = quote
179+
if splices.isEmpty && body.symbol.isPrimitiveValueClass then
180+
scope.select("Type".toTermName).select(s"${body.symbol.name}Tag".toTermName)
181+
else
182+
pickleAsTasty().select(nme.apply).appliedTo(scope)
186183
}
187184
else getLiteral(body) match {
188185
// FIXME: support pickleAsLiteral

library/src-bootstrapped/scala/internal/quoted/Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.internal.quoted
22

3-
import scala.quoted.{Expr, Scope, Type}
3+
import scala.quoted.{Expr, Scope}
44

55
/** Provides methods to unpickle `Expr` and `Type` trees. */
66
object Unpickler {

library/src-bootstrapped/scala/quoted/Scope.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,33 @@ trait Scope extends Liftables, Unliftables { self =>
125125
object Type:
126126
given apply[T <: AnyKind] as Type[T] = ???
127127

128+
def UnitTag: Type[Unit] =
129+
tasty.defn.UnitType.seal.get.asInstanceOf[Type[Unit]]
130+
131+
def BooleanTag: Type[Boolean] =
132+
tasty.defn.BooleanType.seal.get.asInstanceOf[Type[Boolean]]
133+
134+
def ByteTag: Type[Byte] =
135+
tasty.defn.ByteType.seal.get.asInstanceOf[Type[Byte]]
136+
137+
def CharTag: Type[Char] =
138+
tasty.defn.CharType.seal.get.asInstanceOf[Type[Char]]
139+
140+
def ShortTag: Type[Short] =
141+
tasty.defn.ShortType.seal.get.asInstanceOf[Type[Short]]
142+
143+
def IntTag: Type[Int] =
144+
tasty.defn.IntType.seal.get.asInstanceOf[Type[Int]]
145+
146+
def LongTag: Type[Long] =
147+
tasty.defn.LongType.seal.get.asInstanceOf[Type[Long]]
148+
149+
def FloatTag: Type[Float] =
150+
tasty.defn.FloatType.seal.get.asInstanceOf[Type[Float]]
151+
152+
def DoubleTag: Type[Double] =
153+
tasty.defn.DoubleType.seal.get.asInstanceOf[Type[Double]]
154+
128155
/** Low-level Typed AST API `tasty` meta-programming API.
129156
* This API does not have the static type guarantiees that `Expr` and `Type` provide.
130157
*/

library/src-bootstrapped/scala/quoted/Type.scala

Lines changed: 0 additions & 41 deletions
This file was deleted.

staging/src/scala/quoted/staging/QuoteCompiler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import dotty.tools.io.{Path, VirtualFile}
2424

2525
import scala.annotation.tailrec
2626
import scala.concurrent.Promise
27-
import scala.quoted.{Expr, Type}
27+
import scala.quoted.Expr
2828

2929
/** Compiler that takes the contents of a quoted expression `expr` and produces
3030
* a class file with `class ' { def apply: Object = expr }`.

tests/pos-macros/i7322/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.quoted.{ Scope, Expr, Type }
1+
import scala.quoted._
22

33
trait M[T] {
44
def f: Any

tests/pos-macros/toexproftuple.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import scala.quoted._, scala.deriving._
22

33
inline def mcr: Any = ${mcrImpl}
44
def mcrImpl(using s: Scope): s.Expr[Any] = {
5-
val tpl: (Expr[1], Expr[2], Expr[3]) = ('{1}, '{2}, '{3}).asInstanceOf // FIXME remove the .asInstanceOf
5+
val tpl: (s.Expr[1], s.Expr[2], s.Expr[3]) = ('{1}, '{2}, '{3}).asInstanceOf // FIXME remove the .asInstanceOf
66
'{val res: (1, 2, 3) = ${Expr.ofTuple(tpl)}; res}
77
}

0 commit comments

Comments
 (0)