Skip to content

Commit 5176b04

Browse files
committed
Add check to inlined method
1 parent 98c6a03 commit 5176b04

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,11 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
375375
case _ =>
376376
}
377377

378+
/** If the rhs has errors we should not inline it */
379+
private def canInline = rhs.hasType && !rhs.tpe.isError
380+
378381
/** The Inlined node representing the inlined call */
379-
def inlined(pt: Type) = {
382+
def inlined(pt: Type) = if (canInline) {
380383
// make sure prefix is executed if it is impure
381384
if (!isIdempotentExpr(prefix)) registerType(meth.owner.thisType)
382385

@@ -458,7 +461,7 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
458461

459462
tpd.Inlined(call, bindings, expansion1)
460463
}
461-
}
464+
} else rhs
462465

463466
/** An extractor for references to closure arguments that refer to `@inline` methods */
464467
private object InlineableClosure {

0 commit comments

Comments
 (0)