Skip to content

Commit 36c1314

Browse files
committed
Avoid special cases in Positioned#envelope
1 parent 4e11577 commit 36c1314

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

compiler/src/dotty/tools/dotc/ast/Positioned.scala

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,18 @@ abstract class Positioned(implicit @transientParam src: SourceFile) extends Prod
6868
* node have their span set to the end position of the envelope of all children to
6969
* the left, or, if that one does not exist, to the start position of the envelope
7070
* of all children to the right.
71-
*
72-
* @param ignoreTypeTrees If true, don't count type trees in the union.
73-
* This is used to decide whether we need to pickle a position for a tree.
74-
* TypeTreesare pickled as types and therefore contribute nothing to the span union.
7571
*/
76-
def envelope(src: SourceFile, startSpan: Span = NoSpan, ignoreTypeTrees: Boolean = false): Span = this match {
72+
def envelope(src: SourceFile, startSpan: Span = NoSpan): Span = this match {
7773
case Trees.Inlined(call, _, _) =>
78-
//println(s"envelope of $this # $uniqueId = ${call.span}")
7974
call.span
8075
case _ =>
8176
def include(span: Span, x: Any): Span = x match {
82-
case p: Trees.TypeTree[_] if ignoreTypeTrees =>
83-
span
84-
case core.tasty.TreePickler.Hole if ignoreTypeTrees =>
85-
span
8677
case p: Positioned =>
8778
if (p.source `ne` src) span
8879
else if (p.span.exists) span.union(p.span)
8980
else if (span.exists) {
9081
if (span.end != MaxOffset)
91-
p.span = p.envelope(src, span.endPos, ignoreTypeTrees)
82+
p.span = p.envelope(src, span.endPos)
9283
span
9384
}
9485
else // No span available to assign yet, signal this by returning a span with MaxOffset end

compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: untpd.Tree => Option[Ad
7373
case x: untpd.Tree =>
7474
if (x.span.exists) {
7575
val sourceChange = x.source `ne` current
76-
val needsPos =
77-
x.span.toSynthetic != x.envelope(x.source, ignoreTypeTrees = true) ||
78-
alwaysNeedsPos(x)
76+
val needsPos = x.span.toSynthetic != x.envelope(x.source) || alwaysNeedsPos(x)
7977
addrOfTree(x) match {
8078
case Some(addr)
8179
if needsPos && !pickledIndices.contains(addr.index) || sourceChange =>

0 commit comments

Comments
 (0)