Skip to content

Commit

Permalink
Use extension methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jan 30, 2020
1 parent 7764f97 commit e8206d7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions library/src/scala/tasty/Reflection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -419,32 +419,32 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
// QUOTES //
////////////////

implicit class QuotedExprAPI[T](expr: scala.quoted.Expr[T]) {
given QuotedExprOps: extension (expr: scala.quoted.Expr[?]) {
/** View this expression `quoted.Expr[T]` as a `Term` */
def unseal(given ctx: Context): Term =
internal.QuotedExpr_unseal(expr)

/** Checked cast to a `quoted.Expr[U]` */
def cast[U: scala.quoted.Type](given ctx: Context): scala.quoted.Expr[U] =
def cast[U](given tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U] =
internal.QuotedExpr_cast[U](expr)
}

implicit class QuotedTypeAPI[T <: AnyKind](tpe: scala.quoted.Type[T]) {
given QuotedTypeAPI: extension [T <: AnyKind](tpe: scala.quoted.Type[T]) {
/** View this expression `quoted.Type[T]` as a `TypeTree` */
def unseal(given ctx: Context): TypeTree =
internal.QuotedType_unseal(tpe)
}

implicit class TermToQuotedAPI(term: Term) {
given TermToQuotedOps: extension (term: Term) {
/** Convert `Term` to an `quoted.Expr[Any]` */
def seal(given ctx: Context): scala.quoted.Expr[Any] =
internal.QuotedExpr_seal(term)
}

implicit class TypeToQuotedAPI(tpe: Type) {
/** Convert `Type` to an `quoted.Type[_]` */
def seal(given ctx: Context): scala.quoted.Type[_] =
internal.QuotedType_seal(tpe)
given TypeToQuotedOps: extension (tpe: Type) {
/** Convert `Type` to an `quoted.Type[_]` */
def seal(given ctx: Context): scala.quoted.Type[_] =
internal.QuotedType_seal(tpe)
}

//////////////
Expand Down

0 comments on commit e8206d7

Please sign in to comment.