Skip to content

Temporary reintroduce position check in Scaladoc #15200

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 1 commit into from
May 18, 2022
Merged
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
23 changes: 17 additions & 6 deletions scaladoc/src/dotty/tools/scaladoc/tasty/SyntheticSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,28 @@ object SyntheticsSupport:

end extension

private def hackExists(using Quotes)(rpos: reflect.Position) = {
import reflect._
import dotty.tools.dotc
import dotty.tools.dotc.util.Spans._
given dotc.core.Contexts.Context = quotes.asInstanceOf[scala.quoted.runtime.impl.QuotesImpl].ctx
val pos = rpos.asInstanceOf[dotc.util.SourcePosition]
pos.exists
}

def isSyntheticField(using Quotes)(c: reflect.Symbol) =
import reflect._
c.flags.is(Flags.CaseAccessor) || (c.flags.is(Flags.Module) && !c.flags.is(Flags.Given))

def constructorWithoutParamLists(using Quotes)(c: reflect.ClassDef): Boolean =
c.constructor.pos.start == c.constructor.pos.end || {
val end = c.constructor.pos.end
val typesEnd = c.constructor.leadingTypeParams.lastOption.fold(end - 1)(_.pos.end)
val classDefTree = c.constructor.show
c.constructor.leadingTypeParams.nonEmpty && end <= typesEnd + 1
}
if hackExists(c.constructor.pos) then {
c.constructor.pos.start == c.constructor.pos.end || {
val end = c.constructor.pos.end
val typesEnd = c.constructor.leadingTypeParams.lastOption.fold(end - 1)(_.pos.end)
val classDefTree = c.constructor.show
c.constructor.leadingTypeParams.nonEmpty && end <= typesEnd + 1
}
} else false

def getSupertypes(using Quotes)(c: reflect.ClassDef) =
c.symbol.typeRef.baseClasses.map(b => b -> c.symbol.typeRef.baseType(b)).tail
Expand Down