Skip to content

Commit 40e1697

Browse files
committed
Avoid crash on member not found in inlined code
1 parent ec30014 commit 40e1697

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
413413
/** Register type of leaf node */
414414
private def registerLeaf(tree: Tree): Unit = tree match {
415415
case _: This | _: Ident | _: TypeTree =>
416-
tree.tpe.foreachPart(registerType, stopAtStatic = true)
416+
tree.typeOpt.foreachPart(registerType, stopAtStatic = true)
417417
case _ =>
418418
}
419419

@@ -433,11 +433,12 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
433433
/** The Inlined node representing the inlined call */
434434
def inlined(sourcePos: SourcePosition): Tree = {
435435

436+
// Special handling of `constValue[T]` and `constValueOpt[T]`
436437
if (callTypeArgs.length == 1)
437438
if (inlinedMethod == defn.Compiletime_constValue) {
438439
val constVal = tryConstValue
439440
if (!constVal.isEmpty) return constVal
440-
ctx.error(i"not a constant type: ${callTypeArgs.head}; cannot take constValue", call.sourcePos)
441+
ctx.error(em"not a constant type: ${callTypeArgs.head}; cannot take constValue", call.sourcePos)
441442
}
442443
else if (inlinedMethod == defn.Compiletime_constValueOpt) {
443444
val constVal = tryConstValue

0 commit comments

Comments
 (0)