diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 8549d3dbbc..0621fbefe4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -658,6 +658,12 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if (Statistics.canEnable) Statistics.stopCounter(subtypeFailed, subtypeStart) if (Statistics.canEnable) Statistics.stopTimer(failedSilentNanos, failedSilentStart) } + @inline def wrapResult(reporter: ContextReporter, result: T) = + if (reporter.hasErrors) { + stopStats() + SilentTypeError(reporter.errors: _*) + } else SilentResultValue(result) + try { if (context.reportErrors || reportAmbiguousErrors != context.ambiguousErrors || @@ -671,21 +677,17 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper context.undetparams = context1.undetparams context.savedTypeBounds = context1.savedTypeBounds context.namedApplyBlockInfo = context1.namedApplyBlockInfo - if (context1.reporter.hasErrors) { - stopStats() - SilentTypeError(context1.reporter.errors: _*) - } else { - // If we have a successful result, emit any warnings it created. + + // If we have a successful result, emit any warnings it created. + if (!context1.reporter.hasErrors) context1.reporter.emitWarnings() - SilentResultValue(result) - } + + wrapResult(context1.reporter, result) } else { assert(context.bufferErrors || isPastTyper, "silent mode is not available past typer") context.reporter.withFreshErrorBuffer { - val res = op(this) - if (!context.reporter.hasErrors) SilentResultValue(res) - else SilentTypeError(context.reporter.firstError.get) + wrapResult(context.reporter, op(this)) } } } catch { |