Skip to content

Commit 21bc7e3

Browse files
committed
Fix binary compat issues
1 parent cd56314 commit 21bc7e3

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
4545
def matches(that: scala.quoted.Expr[Any]): Boolean =
4646
treeMatch(reflect.asTerm(self), reflect.asTerm(that)).nonEmpty
4747

48-
override def value(using fromExpr: FromExpr[T]): Option[T] =
49-
fromExpr.unapply(self)(using QuotesImpl.this)
50-
51-
override def valueOrError(using FromExpr[T]): T = self.valueOrAbort
52-
5348
def valueOrAbort(using fromExpr: FromExpr[T]): T =
5449
def reportError =
5550
val tree = reflect.asTerm(self)

library/src/scala/quoted/Quotes.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
4545
* Returns `None` if the expression does not represent a value or possibly contains side effects.
4646
* Otherwise returns the `Some` of the value.
4747
*/
48-
def value(using FromExpr[T]): Option[T]
48+
def value(using FromExpr[T]): Option[T] =
49+
given Quotes = Quotes.this
50+
summon[FromExpr[T]].unapply(self)
4951

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

5967
/** Return the value of this expression.
6068
*

project/MiMaFilters.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import com.typesafe.tools.mima.core.ProblemFilters._
55
object MiMaFilters {
66
val Library: Seq[ProblemFilter] = Seq(
77
// New APIs marked @experimental in 3.0.1
8-
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes.value"),
98
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes.valueOrAbort"),
10-
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes.valueOrError"),
119
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#reportModule.errorAndAbort"),
1210
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#reportModule.errorAndAbort"),
1311
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#reportModule.errorAndAbort"),

0 commit comments

Comments
 (0)