Skip to content

Commit bdea1ff

Browse files
Merge pull request #9543 from dotty-staging/move-optimized-quoted-type-encodings-to-internal
Move optimized quoted Type encodings to internal
2 parents 0c92a87 + fb5a68a commit bdea1ff

File tree

7 files changed

+33
-33
lines changed

7 files changed

+33
-33
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ class ReifyQuotes extends MacroTransform {
177177
meth.appliedTo(pickledQuoteStrings, splicesList)
178178
}
179179

180+
def taggedType(sym: Symbol) = ref(defn.InternalQuotedTypeModule).select(sym.name.toTermName)
181+
180182
if (isType) {
181-
def tag(tagName: String) = ref(defn.QuotedTypeModule).select(tagName.toTermName)
182-
if (splices.isEmpty && body.symbol.isPrimitiveValueClass) tag(s"${body.symbol.name}Tag")
183+
if (splices.isEmpty && body.symbol.isPrimitiveValueClass) taggedType(body.symbol)
183184
else pickleAsTasty()
184185
}
185186
else getLiteral(body) match {
@@ -442,4 +443,3 @@ object ReifyQuotes {
442443
override def toString: String = s"Embedded($trees, $map)"
443444
}
444445
}
445-

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,4 @@ object Type {
2727
@compileTimeOnly("Reference to `scala.quoted.Type.apply` was not handled by ReifyQuotes")
2828
given apply[T <: AnyKind] as (QuoteContext ?=> Type[T]) = ???
2929

30-
def UnitTag: QuoteContext ?=> Type[Unit] =
31-
qctx.tasty.defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]]
32-
33-
def BooleanTag: QuoteContext ?=> Type[Boolean] =
34-
qctx.tasty.defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]]
35-
36-
def ByteTag: QuoteContext ?=> Type[Byte] =
37-
qctx.tasty.defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]]
38-
39-
def CharTag: QuoteContext ?=> Type[Char] =
40-
qctx.tasty.defn.CharType.seal.asInstanceOf[quoted.Type[Char]]
41-
42-
def ShortTag: QuoteContext ?=> Type[Short] =
43-
qctx.tasty.defn.ShortType.seal.asInstanceOf[quoted.Type[Short]]
44-
45-
def IntTag: QuoteContext ?=> Type[Int] =
46-
qctx.tasty.defn.IntType.seal.asInstanceOf[quoted.Type[Int]]
47-
48-
def LongTag: QuoteContext ?=> Type[Long] =
49-
qctx.tasty.defn.LongType.seal.asInstanceOf[quoted.Type[Long]]
50-
51-
def FloatTag: QuoteContext ?=> Type[Float] =
52-
qctx.tasty.defn.FloatType.seal.asInstanceOf[quoted.Type[Float]]
53-
54-
def DoubleTag: QuoteContext ?=> Type[Double] =
55-
qctx.tasty.defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]]
56-
5730
}

library/src/scala/internal/quoted/Type.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,31 @@ object Type {
4242
new Matcher.QuoteMatcher[qctx.type].typeTreeMatch(scrutineeType.unseal, patternType.unseal, hasTypeSplices).asInstanceOf[Option[Tup]]
4343
}
4444

45+
def Unit: QuoteContext ?=> quoted.Type[Unit] =
46+
qctx.tasty.defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]]
47+
48+
def Boolean: QuoteContext ?=> quoted.Type[Boolean] =
49+
qctx.tasty.defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]]
50+
51+
def Byte: QuoteContext ?=> quoted.Type[Byte] =
52+
qctx.tasty.defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]]
53+
54+
def Char: QuoteContext ?=> quoted.Type[Char] =
55+
qctx.tasty.defn.CharType.seal.asInstanceOf[quoted.Type[Char]]
56+
57+
def Short: QuoteContext ?=> quoted.Type[Short] =
58+
qctx.tasty.defn.ShortType.seal.asInstanceOf[quoted.Type[Short]]
59+
60+
def Int: QuoteContext ?=> quoted.Type[Int] =
61+
qctx.tasty.defn.IntType.seal.asInstanceOf[quoted.Type[Int]]
62+
63+
def Long: QuoteContext ?=> quoted.Type[Long] =
64+
qctx.tasty.defn.LongType.seal.asInstanceOf[quoted.Type[Long]]
65+
66+
def Float: QuoteContext ?=> quoted.Type[Float] =
67+
qctx.tasty.defn.FloatType.seal.asInstanceOf[quoted.Type[Float]]
68+
69+
def Double: QuoteContext ?=> quoted.Type[Double] =
70+
qctx.tasty.defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]]
71+
4572
}

tests/run-staging/i3823-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ object Test {
66
def f[T](x: Expr[T])(implicit t: Type[T]) = '{
77
val z: $t = $x
88
}
9-
println(f('{2})(Type.IntTag).show)
9+
println(f('{2})('[Int]).show)
1010
}
1111
}

tests/run-staging/i3823-c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ object Test {
66
def f[T](x: Expr[T])(implicit t: Type[T]) = '{
77
val z = $x
88
}
9-
println(f('{2})(Type.IntTag).show)
9+
println(f('{2})('[Int]).show)
1010
}
1111
}

tests/run-staging/quote-owners-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scala.quoted.staging._
55
object Test {
66
given Toolbox = Toolbox.make(getClass.getClassLoader)
77
def main(args: Array[String]): Unit = run {
8-
val q = f(g(Type.IntTag))
8+
val q = f(g('[Int]))
99
println(q.show)
1010
'{ println($q) }
1111
}

0 commit comments

Comments
 (0)