Skip to content

Commit 57a6867

Browse files
committed
Simplify tryHeal signature
1 parent cbbae64 commit 57a6867

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ class CrossStageSafety extends TreeMapWithStages {
206206
* The tag is generated by an instance of `QuoteTypeTags` directly if the splice is explicit
207207
* or indirectly by `tryHeal`.
208208
*/
209-
protected def healType(pos: SrcPos)(using Context) =
210-
new HealType(pos)
209+
protected def healType(pos: SrcPos)(tpe: Type)(using Context) =
210+
new HealType(pos).apply(tpe)
211211

212212
/** Check level consistency of terms references */
213213
private def checkLevelConsistency(tree: Ident | This)(using Context): Unit =

compiler/src/dotty/tools/dotc/staging/HealType.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
5151
if level == 0 then tp else getQuoteTypeTags.getTagRef(prefix)
5252
case _: NamedType | _: ThisType | NoPrefix =>
5353
if levelInconsistentRootOfPath(tp).exists then
54-
tryHeal(tp.symbol, tp, pos)
54+
tryHeal(tp)
5555
else
5656
tp
5757
case _ =>
@@ -82,7 +82,7 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
8282
* reference to a type alias containing the equivalent of `${summon[quoted.Type[T]]}`.
8383
* Emits an error if `T` cannot be healed and returns `T`.
8484
*/
85-
protected def tryHeal(sym: Symbol, tp: TypeRef, pos: SrcPos): Type = {
85+
protected def tryHeal(tp: TypeRef): Type = {
8686
val reqType = defn.QuotedTypeClass.typeRef.appliedTo(tp)
8787
val tag = ctx.typer.inferImplicitArg(reqType, pos.span)
8888
tag.tpe match

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ class Staging extends MacroTransform {
3636
tree match {
3737
case PackageDef(pid, _) if tree.symbol.owner == defn.RootClass =>
3838
val checker = new CrossStageSafety {
39-
override protected def healType(pos: SrcPos)(using Context) = new HealType(pos) {
40-
override protected def tryHeal(sym: Symbol, tp: TypeRef, pos: SrcPos): TypeRef = {
39+
override protected def healType(pos: SrcPos)(tpe: Type)(using Context) = new HealType(pos) {
40+
override protected def tryHeal(tp: TypeRef): TypeRef = {
41+
val sym = tp.symbol
4142
def symStr =
4243
if (sym.is(ModuleClass)) sym.sourceModule.show
4344
else i"${sym.name}.this"
@@ -51,7 +52,7 @@ class Staging extends MacroTransform {
5152

5253
tp
5354
}
54-
}
55+
}.apply(tpe)
5556
}
5657
checker.transform(tree)
5758
case _ =>

0 commit comments

Comments
 (0)