Skip to content

Update reflect.Symbol position API #10656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion community-build/community-projects/utest
4 changes: 2 additions & 2 deletions compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2291,7 +2291,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler

def name: String = self.denot.name.toString
def fullName: String = self.denot.fullName.toString
def pos: Position = self.sourcePos
def pos: Option[Position] =
if self.exists then Some(self.sourcePos) else None

def documentation: Option[Documentation] =
import dotc.core.Comments.CommentsContext
Expand Down Expand Up @@ -2566,7 +2567,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
extension (self: Position):
def start: Int = self.start
def end: Int = self.end
def exists: Boolean = self.exists
def sourceFile: SourceFile = self.source
def startLine: Int = self.startLine
def endLine: Int = self.endLine
Expand Down
5 changes: 1 addition & 4 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3067,7 +3067,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
def fullName: String

/** The position of this symbol */
def pos: Position
def pos: Option[Position]

/** The documentation for this symbol, if any */
def documentation: Option[Documentation]
Expand Down Expand Up @@ -3640,9 +3640,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** The end offset in the source file */
def end: Int

/** Does this position exist */
def exists: Boolean

/** Source file in which this position is located */
def sourceFile: SourceFile

Expand Down
4 changes: 2 additions & 2 deletions scala3doc/src/dotty/dokka/tasty/BasicSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ trait BasicSupport:
Map.empty

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

def getAnnotations(): List[Annotation] =
sym.annotations.filterNot(_.symbol.packageName.startsWith("scala.annotation.internal")).map(parseAnnotation).reverse
Expand Down
2 changes: 1 addition & 1 deletion scala3doc/src/dotty/dokka/tasty/ClassLikeSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ trait ClassLikeSupport:
extSym.symbol.normalizedName,
extSym.tpt.dokkaType.asSignature,
extSym.tpt.symbol.dri,
extSym.symbol.pos.start
extSym.symbol.pos.get.start
)
parseMethod(dd.symbol, kind = Kind.Extension(target))
}
Expand Down
2 changes: 1 addition & 1 deletion scala3doc/src/dotty/dokka/tasty/SyntheticSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ trait SyntheticsSupport:
c.flags.is(Flags.CaseAccessor) || (c.flags.is(Flags.Module) && !c.flags.is(Flags.Given))

def isValidPos(pos: Position) =
pos.exists && pos.start != pos.end
pos.start != pos.end

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