From a4b39de883fe643779e3fcf4f86c822abb0e167a Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 7 Dec 2020 15:12:17 +0100 Subject: [PATCH] Help scala.quoted migration from 3.0.0-M2 to 3.0.0-M3 Add back deprecated `Unlifted`, `unlift` and `unliftOrError` --- .../src-bootstrapped/scala/quoted/Unlifted.scala | 14 ++++++++++++++ library/src/scala/quoted/Quotes.scala | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 library/src-bootstrapped/scala/quoted/Unlifted.scala diff --git a/library/src-bootstrapped/scala/quoted/Unlifted.scala b/library/src-bootstrapped/scala/quoted/Unlifted.scala new file mode 100644 index 000000000000..09568d58fa54 --- /dev/null +++ b/library/src-bootstrapped/scala/quoted/Unlifted.scala @@ -0,0 +1,14 @@ +package scala.quoted + +@deprecated("Use `scala.quoted.Expr` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3") +object Unlifted: + + @deprecated("Use `scala.quoted.Expr.unapply` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3") + def apply[T](expr: Expr[T])(using FromExpr[T])(using Quotes): Option[T] = + Expr.unapply(expr) + + @deprecated("Use `scala.quoted.Exprs.unapply` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3") + def unapply[T](exprs: Seq[Expr[T]])(using FromExpr[T])(using Quotes): Option[Seq[T]] = + Exprs.unapply(exprs) + +end Unlifted diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index 1766821f589e..c6521a917b1b 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -33,6 +33,12 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => */ def matches(that: Expr[Any]): Boolean + @deprecated("Use `.value` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3") + def unlift(using FromExpr[T]): Option[T] = self.value + + @deprecated("Use `.unliftOrError` instead. This will be removed in 3.0.0-RC1", "3.0.0-M3") + def unliftOrError(using FromExpr[T]): T = self.valueOrError + /** Return the value of this expression. * * Returns `None` if the expression does not represent a value or possibly contains side effects.