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 =>
167
167
throw ex
168
168
}
169
169
}
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
+ }
170
186
}
171
187
172
188
/**
Original file line number Diff line number Diff line change @@ -190,10 +190,7 @@ object Inliner {
190
190
val inlineCtx = ctx
191
191
sym.updateAnnotation(LazyBodyAnnotation { _ =>
192
192
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)
197
194
})
198
195
}
199
196
}
You can’t perform that action at this time.
0 commit comments