Skip to content

Commit f167a3d

Browse files
committed
Move internal quoted.Type implementations to internal package
1 parent 2ce342b commit f167a3d

File tree

7 files changed

+89
-82
lines changed

7 files changed

+89
-82
lines changed

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import dotty.tools.dotc.core.tasty.TreePickler.Hole
1515
import dotty.tools.dotc.core.tasty.{PositionPickler, TastyPickler, TastyPrinter, TastyString}
1616
import dotty.tools.dotc.core.tasty.TreeUnpickler.UnpickleMode
1717

18-
import scala.quoted.Types._
1918
import scala.internal.quoted._
2019
import scala.reflect.ClassTag
2120

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ import config.Printers.pickling
3333
import core.quoted.PickledQuotes
3434

3535
import scala.quoted
36-
import scala.quoted.Types.TreeType
37-
import scala.internal.quoted.TastyTreeExpr
36+
import scala.internal.quoted.{TastyTreeExpr, TreeType}
3837
import scala.annotation.constructorOnly
3938
import scala.annotation.internal.sharable
4039

compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
17681768
/** Convert `Type` to an `quoted.Type[_]` */
17691769
def QuotedType_seal(self: Type)(implicit ctx: Context): scala.quoted.Type[_] = {
17701770
val dummySpan = ctx.owner.span // FIXME
1771-
new scala.quoted.Types.TreeType(tpd.TypeTree(self).withSpan(dummySpan))
1771+
new scala.internal.quoted.TreeType(tpd.TypeTree(self).withSpan(dummySpan))
17721772
}
17731773

17741774
//

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ object Splicer {
105105
new scala.internal.quoted.TastyTreeExpr(Inlined(EmptyTree, Nil, tree).withSpan(tree.span))
106106

107107
protected def interpretTypeQuote(tree: Tree)(implicit env: Env): Object =
108-
new scala.quoted.Types.TreeType(tree)
108+
new scala.internal.quoted.TreeType(tree)
109109

110110
protected def interpretLiteral(value: Any)(implicit env: Env): Object =
111111
value.asInstanceOf[Object]
Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,53 @@
1-
package scala.quoted
1+
package scala
22

3-
import scala.quoted.Types.TaggedType
4-
import scala.reflect.ClassTag
5-
import scala.runtime.quoted.Unpickler.Pickled
3+
package quoted {
4+
import scala.internal.quoted.TaggedType
65

7-
sealed abstract class Type[T] {
8-
type `$splice` = T
9-
}
10-
11-
/** Some basic type tags, currently incomplete */
12-
object Type {
6+
sealed abstract class Type[T] {
7+
type `$splice` = T
8+
}
139

14-
implicit class TypeOps[T](tpe: Type[T]) {
15-
/** Show a source code like representation of this type */
16-
def show(implicit toolbox: Toolbox): String = toolbox.show(tpe.asInstanceOf[Type[Any]])
10+
/** Some basic type tags, currently incomplete */
11+
object Type {
12+
13+
implicit class TypeOps[T](tpe: Type[T]) {
14+
/** Show a source code like representation of this type */
15+
def show(implicit toolbox: Toolbox): String = toolbox.show(tpe.asInstanceOf[Type[Any]])
16+
}
17+
18+
implicit def UnitTag: Type[Unit] = new TaggedType[Unit]
19+
implicit def BooleanTag: Type[Boolean] = new TaggedType[Boolean]
20+
implicit def ByteTag: Type[Byte] = new TaggedType[Byte]
21+
implicit def CharTag: Type[Char] = new TaggedType[Char]
22+
implicit def ShortTag: Type[Short] = new TaggedType[Short]
23+
implicit def IntTag: Type[Int] = new TaggedType[Int]
24+
implicit def LongTag: Type[Long] = new TaggedType[Long]
25+
implicit def FloatTag: Type[Float] = new TaggedType[Float]
26+
implicit def DoubleTag: Type[Double] = new TaggedType[Double]
1727
}
1828

19-
implicit def UnitTag: Type[Unit] = new TaggedType[Unit]
20-
implicit def BooleanTag: Type[Boolean] = new TaggedType[Boolean]
21-
implicit def ByteTag: Type[Byte] = new TaggedType[Byte]
22-
implicit def CharTag: Type[Char] = new TaggedType[Char]
23-
implicit def ShortTag: Type[Short] = new TaggedType[Short]
24-
implicit def IntTag: Type[Int] = new TaggedType[Int]
25-
implicit def LongTag: Type[Long] = new TaggedType[Long]
26-
implicit def FloatTag: Type[Float] = new TaggedType[Float]
27-
implicit def DoubleTag: Type[Double] = new TaggedType[Double]
2829
}
2930

30-
/** All implementations of Type[T].
31-
* These should never be used directly.
32-
*/
33-
object Types {
34-
/** A Type backed by a pickled TASTY tree */
35-
final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] {
36-
override def toString(): String = s"Type(<pickled tasty>)"
37-
}
31+
package internal {
32+
package quoted {
33+
import scala.quote.Type
34+
import scala.reflect.ClassTag
35+
import scala.runtime.quoted.Unpickler.Pickled
3836

39-
/** An Type backed by a value */
40-
final class TaggedType[T](implicit val ct: ClassTag[T]) extends Type[T] {
41-
override def toString: String = s"Type($ct)"
42-
}
37+
/** A Type backed by a pickled TASTY tree */
38+
final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] {
39+
override def toString(): String = s"Type(<pickled tasty>)"
40+
}
41+
42+
/** An Type backed by a value */
43+
final class TaggedType[T](implicit val ct: ClassTag[T]) extends Type[T] {
44+
override def toString: String = s"Type($ct)"
45+
}
46+
47+
/** An Type backed by a tree */
48+
final class TreeType[Tree](val typeTree: Tree) extends quoted.Type[Any] {
49+
override def toString: String = s"Type(<tasty tree>)"
50+
}
4351

44-
/** An Type backed by a tree */
45-
final class TreeType[Tree](val typeTree: Tree) extends quoted.Type[Any] {
46-
override def toString: String = s"Type(<tasty tree>)"
4752
}
4853
}
Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,53 @@
1-
package scala.quoted
1+
package scala
22

3-
import scala.quoted.Types.TaggedType
4-
import scala.reflect.ClassTag
5-
import scala.runtime.quoted.Unpickler.Pickled
3+
package quoted {
4+
import scala.internal.quoted.TaggedType
65

7-
sealed abstract class Type[T <: AnyKind] {
8-
type `$splice` = T
9-
}
10-
11-
/** Some basic type tags, currently incomplete */
12-
object Type {
6+
sealed abstract class Type[T <: AnyKind] {
7+
type `$splice` = T
8+
}
139

14-
implicit object TypeOps {
15-
/** Show a source code like representation of this type */
16-
def (tpe: Type[T]) show[T] given Toolbox: String = the[Toolbox].show(tpe.asInstanceOf[Type[Any]])
10+
/** Some basic type tags, currently incomplete */
11+
object Type {
12+
13+
implicit object TypeOps {
14+
/** Show a source code like representation of this type */
15+
def (tpe: Type[T]) show[T] given Toolbox: String = the[Toolbox].show(tpe.asInstanceOf[Type[Any]])
16+
}
17+
18+
implied UnitTag for Type[Unit] = new TaggedType[Unit]
19+
implied BooleanTag for Type[Boolean] = new TaggedType[Boolean]
20+
implied ByteTag for Type[Byte] = new TaggedType[Byte]
21+
implied CharTag for Type[Char] = new TaggedType[Char]
22+
implied ShortTag for Type[Short] = new TaggedType[Short]
23+
implied IntTag for Type[Int] = new TaggedType[Int]
24+
implied LongTag for Type[Long] = new TaggedType[Long]
25+
implied FloatTag for Type[Float] = new TaggedType[Float]
26+
implied DoubleTag for Type[Double] = new TaggedType[Double]
1727
}
1828

19-
implied UnitTag for Type[Unit] = new TaggedType[Unit]
20-
implied BooleanTag for Type[Boolean] = new TaggedType[Boolean]
21-
implied ByteTag for Type[Byte] = new TaggedType[Byte]
22-
implied CharTag for Type[Char] = new TaggedType[Char]
23-
implied ShortTag for Type[Short] = new TaggedType[Short]
24-
implied IntTag for Type[Int] = new TaggedType[Int]
25-
implied LongTag for Type[Long] = new TaggedType[Long]
26-
implied FloatTag for Type[Float] = new TaggedType[Float]
27-
implied DoubleTag for Type[Double] = new TaggedType[Double]
2829
}
2930

30-
/** All implementations of Type[T].
31-
* These should never be used directly.
32-
*/
33-
object Types {
34-
/** A Type backed by a pickled TASTY tree */
35-
final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] {
36-
override def toString(): String = s"Type(<pickled tasty>)"
37-
}
31+
package internal {
32+
package quoted {
33+
import scala.quoted.Type
34+
import scala.reflect.ClassTag
35+
import scala.runtime.quoted.Unpickler.Pickled
3836

39-
/** An Type backed by a value */
40-
final class TaggedType[T](implicit val ct: ClassTag[T]) extends Type[T] {
41-
override def toString: String = s"Type($ct)"
42-
}
37+
/** A Type backed by a pickled TASTY tree */
38+
final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] {
39+
override def toString(): String = s"Type(<pickled tasty>)"
40+
}
41+
42+
/** An Type backed by a value */
43+
final class TaggedType[T](implicit val ct: ClassTag[T]) extends Type[T] {
44+
override def toString: String = s"Type($ct)"
45+
}
46+
47+
/** An Type backed by a tree */
48+
final class TreeType[Tree](val typeTree: Tree) extends Type[Any] {
49+
override def toString: String = s"Type(<tasty tree>)"
50+
}
4351

44-
/** An Type backed by a tree */
45-
final class TreeType[Tree](val typeTree: Tree) extends quoted.Type[Any] {
46-
override def toString: String = s"Type(<tasty tree>)"
4752
}
4853
}

library/src/scala/runtime/quoted/Unpickler.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package scala.runtime.quoted
22

3-
import scala.quoted.Types.TastyType
4-
import scala.internal.quoted.{LiftedExpr, TastyExpr}
3+
import scala.internal.quoted.{LiftedExpr, TastyExpr, TastyType}
54
import scala.quoted.{Expr, Type}
65

76
/** Provides methods to unpickle `Expr` and `Type` trees. */
@@ -20,7 +19,7 @@ object Unpickler {
2019
/** Lift the `value` to an `Expr` tree.
2120
* Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String, Null or Class.
2221
*/
23-
def liftedExpr[T](value: T): LiftedExpr[T] = new LiftedExpr[T](value)
22+
def liftedExpr[T](value: T): Expr[T] = new LiftedExpr[T](value)
2423

2524
/** Unpickle `repr` which represents a pickled `Type` tree,
2625
* replacing splice nodes with `args`

0 commit comments

Comments
 (0)