Skip to content

Commit 822f8f8

Browse files
committed
Set position of memo cache ValDefs
Maybe we should always set the positions of these generated definitions automatically from the symbol's span. It's an easy trap to fall into.
1 parent f571605 commit 822f8f8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ object Inliner {
199199
case _ => syms
200200
}
201201
}
202-
memoCacheSyms.map(ValDef(_, Literal(Constant(null))))
202+
memoCacheSyms.map(sym => ValDef(sym, Literal(Constant(null))).withSpan(sym.span))
203203
}
204204
}
205205

@@ -425,11 +425,12 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
425425
else Synthetic | Mutable | Private | Local,
426426
info = OrType(argType, defn.NullType),
427427
coord = call.span)
428+
val memoRef = ref(memoVar).withSpan(call.span)
428429
val cond = If(
429-
ref(memoVar).select(defn.Any_==).appliedTo(Literal(Constant(null))),
430-
ref(memoVar).becomes(callValueArgss.head.head),
430+
memoRef.select(defn.Any_==).appliedTo(Literal(Constant(null))),
431+
memoRef.becomes(callValueArgss.head.head),
431432
Literal(Constant(())))
432-
val expr = ref(memoVar).cast(argType)
433+
val expr = memoRef.cast(argType)
433434
Block(cond :: Nil, expr)
434435
}
435436
else errorTree(call, em"""memo(...) outside method""")

0 commit comments

Comments
 (0)