Skip to content

Commit 1571384

Browse files
committed
Remove needsHealing
1 parent 7225a79 commit 1571384

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
4949
else tree match {
5050

5151
case _: TypeTree | _: RefTree if tree.isType =>
52-
if needsHealing(tree.tpe) then TypeTree(healType(tree.sourcePos)(tree.tpe)).withSpan(tree.span)
53-
else tree
52+
val healedType = healType(tree.sourcePos)(tree.tpe)
53+
if healedType == tree.tpe then tree
54+
else TypeTree(healedType).withSpan(tree.span)
5455

5556
case _: This =>
5657
if level != levelOf(tree.symbol) then
@@ -135,21 +136,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
135136

136137
/** Heal types in the info of the given tree */
137138
private def healInfo(tree: Tree, pos: SourcePosition)(using Context): Unit =
138-
if needsHealing(tree.symbol.info) then
139-
tree.symbol.info = healType(pos)(tree.symbol.info)
140-
141-
/** Does this type contain a phase inconsistent reference? */
142-
private def needsHealing(tp: Type)(using Context) = new ExistsAccumulator(
143-
_ match
144-
case tp @ TypeRef(NoPrefix, _) =>
145-
level > levelOf(tp.symbol)
146-
case tp @ TermRef(NoPrefix, _) =>
147-
level != levelOf(tp.symbol)
148-
case tp: ThisType =>
149-
level != levelOf(tp.cls)
150-
case tp =>
151-
tp.typeSymbol.isSplice && level > 0
152-
).apply(false, tp)
139+
tree.symbol.info = healType(pos)(tree.symbol.info)
153140

154141
private def healType(pos: SourcePosition)(using Context) = new TypeMap {
155142
def apply(tp: Type): Type =

0 commit comments

Comments
 (0)