Skip to content

Commit

Permalink
Fix binary compat issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed May 17, 2021
1 parent 53dd32e commit 43fec8f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 0 additions & 5 deletions compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
def matches(that: scala.quoted.Expr[Any]): Boolean =
treeMatch(reflect.asTerm(self), reflect.asTerm(that)).nonEmpty

override def value(using fromExpr: FromExpr[T]): Option[T] =
fromExpr.unapply(self)(using QuotesImpl.this)

override def valueOrError(using FromExpr[T]): T = self.valueOrAbort

def valueOrAbort(using fromExpr: FromExpr[T]): T =
def reportError =
val tree = reflect.asTerm(self)
Expand Down
12 changes: 10 additions & 2 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
* Returns `None` if the expression does not represent a value or possibly contains side effects.
* Otherwise returns the `Some` of the value.
*/
def value(using FromExpr[T]): Option[T]
def value(using FromExpr[T]): Option[T] =
given Quotes = Quotes.this
summon[FromExpr[T]].unapply(self)

/** Return the value of this expression.
*
Expand All @@ -54,7 +56,13 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
*/
// TODO: deprecate in 3.1.0 and remove @experimental from valueOrAbort
// @deprecated("Use valueOrThrow", "3.1.0")
def valueOrError(using FromExpr[T]): T
def valueOrError(using FromExpr[T]): T =
val fromExpr = summon[FromExpr[T]]
def reportError =
val msg = s"Expected a known value. \n\nThe value of: ${self.show}\ncould not be extracted using $fromExpr"
reflect.report.throwError(msg, self)
given Quotes = Quotes.this
fromExpr.unapply(self).getOrElse(reportError)

/** Return the value of this expression.
*
Expand Down
2 changes: 0 additions & 2 deletions project/MiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import com.typesafe.tools.mima.core.ProblemFilters._
object MiMaFilters {
val Library: Seq[ProblemFilter] = Seq(
// New APIs marked @experimental in 3.0.1
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes.value"),
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes.valueOrAbort"),
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes.valueOrError"),
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#reportModule.errorAndAbort"),
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.fieldMember"),
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.fieldMembers"),
Expand Down

0 comments on commit 43fec8f

Please sign in to comment.