Skip to content

Commit 1fec582

Browse files
committed
Inline iff reporter has no new errors post typing rhs
1 parent 98c6a03 commit 1fec582

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,22 @@ trait Reporting { this: Context =>
167167
throw ex
168168
}
169169
}
170+
171+
/** Implements a fold that applies the function `f` to the result of `op` if
172+
* there are no new errors in the reporter
173+
*
174+
* @param op operation checked for errors
175+
* @param f function applied to result of op
176+
* @return either the result of `op` if it had errors or the result of `f`
177+
* applied to it
178+
*/
179+
def withNoError[A, B >: A](op: => A)(f: A => B): B = {
180+
val before = reporter.errorCount
181+
val op0 = op
182+
183+
if (reporter.errorCount > before) op0
184+
else f(op0)
185+
}
170186
}
171187

172188
/**

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ object Inliner {
190190
val inlineCtx = ctx
191191
sym.updateAnnotation(LazyBodyAnnotation { _ =>
192192
implicit val ctx: Context = inlineCtx
193-
val tree1 = treeExpr(ctx)
194-
if (tree1.hasType && !tree1.tpe.isError)
195-
makeInlineable(tree1)
196-
else tree1
193+
ctx.withNoError(treeExpr(ctx))(makeInlineable)
197194
})
198195
}
199196
}

0 commit comments

Comments
 (0)