From ee9a60a0fd4cf6d7b87004bc4288390fc6272f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Zyba=C5=82a?= Date: Thu, 26 Aug 2021 16:27:14 +0200 Subject: [PATCH 1/3] Add Position.exists to reflection API --- compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala | 2 ++ library/src/scala/quoted/Quotes.scala | 3 +++ 2 files changed, 5 insertions(+) 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 } From dec5796f78afcc2f41ed2c9c09a35ec33efa2e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Zyba=C5=82a?= Date: Thu, 26 Aug 2021 16:27:25 +0200 Subject: [PATCH 2/3] Update MiMa filters --- project/MiMaFilters.scala | 1 + 1 file changed, 1 insertion(+) 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"), ) } From e8493483f3276f50d95c877c7c9deb984f790e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Zyba=C5=82a?= Date: Thu, 26 Aug 2021 16:27:39 +0200 Subject: [PATCH 3/3] Use Position.exists in Scaladoc --- scaladoc/src/dotty/tools/scaladoc/tasty/SyntheticSupport.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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._