Skip to content

Commit 6238938

Browse files
Merge pull request #6479 from dotty-staging/use-dotty-features-in-quoted
Use Dotty features in scala.quoted
2 parents 143444e + e8afd6f commit 6238938

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

library/src-3.x/scala/quoted/Type.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ sealed abstract class Type[T <: AnyKind] {
1111
/** Some basic type tags, currently incomplete */
1212
object Type {
1313

14-
implicit class TypeOps[T](tpe: Type[T]) {
14+
implicit object TypeOps {
1515
/** Show a source code like representation of this type */
16-
def show(implicit toolbox: Toolbox): String = toolbox.show(tpe.asInstanceOf[Type[Any]])
16+
def (tpe: Type[T]) show[T] given Toolbox: String = the[Toolbox].show(tpe.asInstanceOf[Type[Any]])
1717
}
1818

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]
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]
2828
}
2929

3030
/** All implementations of Type[T].

library/src-3.x/scala/quoted/package.scala

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ package object quoted {
66
implicit def autoToExpr[T: Liftable](x: T): Expr[T] = x.toExpr
77
}
88

9-
implicit class LiftExprOps[T](val x: T) extends AnyVal {
10-
def toExpr(implicit ev: Liftable[T]): Expr[T] = ev.toExpr(x)
11-
}
9+
implicit object ExprOps {
10+
def (x: T) toExpr[T] given Liftable[T]: Expr[T] = the[Liftable[T]].toExpr(x)
1211

13-
implicit class ListOfExprOps[T](val list: List[Expr[T]]) extends AnyVal {
14-
def toExprOfList(implicit ev: Type[T]): Expr[List[T]] = {
15-
def rec(list: List[Expr[T]]): Expr[List[T]] = list match {
16-
case x :: xs => '{ ($x) :: ${rec(xs)} }
17-
case Nil => '{Nil}
18-
}
19-
rec(list)
12+
def (list: List[Expr[T]]) toExprOfList[T] given Type[T]: Expr[List[T]] = list match {
13+
case x :: xs => '{ $x :: ${xs.toExprOfList} }
14+
case Nil => '{ Nil }
2015
}
2116
}
17+
2218
}

0 commit comments

Comments
 (0)