diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index 2d3f5490563c..de2839ea19f0 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -2777,6 +2777,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler def sourceCode: Option[String] = // TODO detect when we do not have a source and return None Some(new String(self.source.content(), self.start, self.end - self.start)) + def exists: Boolean = + self.exists end extension end PositionMethods diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index e6f229676d34..171197df7bef 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -4179,6 +4179,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Source code within the position */ def sourceCode: Option[String] + /** Does the position exist? */ + def exists: Boolean + end extension } diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala index 697f0bca662b..bf43dead7299 100644 --- a/project/MiMaFilters.scala +++ b/project/MiMaFilters.scala @@ -18,5 +18,6 @@ object MiMaFilters { exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule.TypedOrTestTypeTest"), exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule.TypedOrTest"), exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule.TypedOrTestMethods"), + exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#PositionMethods.exists"), ) } diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/SyntheticSupport.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/SyntheticSupport.scala index 689c66a200ee..e79c07fb416c 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/SyntheticSupport.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/SyntheticSupport.scala @@ -43,7 +43,7 @@ object SyntheticsSupport: end extension def isValidPos(using Quotes)(pos: reflect.Position) = - if hackExists(pos) then pos.start != pos.end else false + if pos.exists then pos.start != pos.end else false def isSyntheticField(using Quotes)(c: reflect.Symbol) = import reflect._