Skip to content

Commit 121ced4

Browse files
Merge pull request #10656 from dotty-staging/update-reflect-symbol-api
Update reflect.Symbol position API
2 parents d8cb977 + bde343c commit 121ced4

File tree

7 files changed

+9
-12
lines changed

7 files changed

+9
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
22912291

22922292
def name: String = self.denot.name.toString
22932293
def fullName: String = self.denot.fullName.toString
2294-
def pos: Position = self.sourcePos
2294+
def pos: Option[Position] =
2295+
if self.exists then Some(self.sourcePos) else None
22952296

22962297
def documentation: Option[Documentation] =
22972298
import dotc.core.Comments.CommentsContext
@@ -2569,7 +2570,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
25692570
extension (self: Position):
25702571
def start: Int = self.start
25712572
def end: Int = self.end
2572-
def exists: Boolean = self.exists
25732573
def sourceFile: SourceFile = self.source
25742574
def startLine: Int = self.startLine
25752575
def endLine: Int = self.endLine

library/src/scala/quoted/Quotes.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,7 +3067,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
30673067
def fullName: String
30683068

30693069
/** The position of this symbol */
3070-
def pos: Position
3070+
def pos: Option[Position]
30713071

30723072
/** The documentation for this symbol, if any */
30733073
def documentation: Option[Documentation]
@@ -3646,9 +3646,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
36463646
/** The end offset in the source file */
36473647
def end: Int
36483648

3649-
/** Does this position exist */
3650-
def exists: Boolean
3651-
36523649
/** Source file in which this position is located */
36533650
def sourceFile: SourceFile
36543651

scala3doc/src/dotty/dokka/tasty/BasicSupport.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ trait BasicSupport:
4141
Map.empty
4242

4343
def source =
44-
val path = Some(sym.pos.sourceFile.jpath).filter(_ != null).map(_.toAbsolutePath).map(_.toString)
45-
path.map(TastyDocumentableSource(_, sym.pos.startLine))
44+
val path = Some(sym.pos.get.sourceFile.jpath).filter(_ != null).map(_.toAbsolutePath).map(_.toString)
45+
path.map(TastyDocumentableSource(_, sym.pos.get.startLine))
4646

4747
def getAnnotations(): List[Annotation] =
4848
sym.annotations.filterNot(_.symbol.packageName.startsWith("scala.annotation.internal")).map(parseAnnotation).reverse

scala3doc/src/dotty/dokka/tasty/ClassLikeSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ trait ClassLikeSupport:
114114
extSym.symbol.normalizedName,
115115
extSym.tpt.dokkaType.asSignature,
116116
extSym.tpt.symbol.dri,
117-
extSym.symbol.pos.start
117+
extSym.symbol.pos.get.start
118118
)
119119
parseMethod(dd.symbol, kind = Kind.Extension(target))
120120
}

scala3doc/src/dotty/dokka/tasty/SyntheticSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ trait SyntheticsSupport:
4141
c.flags.is(Flags.CaseAccessor) || (c.flags.is(Flags.Module) && !c.flags.is(Flags.Given))
4242

4343
def isValidPos(pos: Position) =
44-
pos.exists && pos.start != pos.end
44+
pos.start != pos.end
4545

4646
def constructorWithoutParamLists(c: ClassDef): Boolean =
4747
!isValidPos(c.constructor.pos) || {

0 commit comments

Comments
 (0)