File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff 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/**
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments