Skip to content

Commit a293d7d

Browse files
authored
Merge pull request #15200 from dotty-staging/scaladoc/position-existence
Temporary reintroduce position check in Scaladoc
2 parents 7015143 + 8dc7b6e commit a293d7d

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

scaladoc/src/dotty/tools/scaladoc/tasty/SyntheticSupport.scala

+17-6
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,28 @@ object SyntheticsSupport:
2222

2323
end extension
2424

25+
private def hackExists(using Quotes)(rpos: reflect.Position) = {
26+
import reflect._
27+
import dotty.tools.dotc
28+
import dotty.tools.dotc.util.Spans._
29+
given dotc.core.Contexts.Context = quotes.asInstanceOf[scala.quoted.runtime.impl.QuotesImpl].ctx
30+
val pos = rpos.asInstanceOf[dotc.util.SourcePosition]
31+
pos.exists
32+
}
33+
2534
def isSyntheticField(using Quotes)(c: reflect.Symbol) =
2635
import reflect._
2736
c.flags.is(Flags.CaseAccessor) || (c.flags.is(Flags.Module) && !c.flags.is(Flags.Given))
2837

2938
def constructorWithoutParamLists(using Quotes)(c: reflect.ClassDef): Boolean =
30-
c.constructor.pos.start == c.constructor.pos.end || {
31-
val end = c.constructor.pos.end
32-
val typesEnd = c.constructor.leadingTypeParams.lastOption.fold(end - 1)(_.pos.end)
33-
val classDefTree = c.constructor.show
34-
c.constructor.leadingTypeParams.nonEmpty && end <= typesEnd + 1
35-
}
39+
if hackExists(c.constructor.pos) then {
40+
c.constructor.pos.start == c.constructor.pos.end || {
41+
val end = c.constructor.pos.end
42+
val typesEnd = c.constructor.leadingTypeParams.lastOption.fold(end - 1)(_.pos.end)
43+
val classDefTree = c.constructor.show
44+
c.constructor.leadingTypeParams.nonEmpty && end <= typesEnd + 1
45+
}
46+
} else false
3647

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

0 commit comments

Comments
 (0)