diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-08-04 17:25:45 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-08-04 17:50:42 +0200 |
commit | ca9f64dfa20fb8d5a4c022f6b9fd2f18a8ea1028 (patch) | |
tree | 509b4d2595a6ada57935912fab4dac5f77ed94f7 /src/compiler | |
parent | e21096f5ccbb27587bedbf238b18661d158995e1 (diff) | |
download | scala-ca9f64dfa20fb8d5a4c022f6b9fd2f18a8ea1028.tar.gz scala-ca9f64dfa20fb8d5a4c022f6b9fd2f18a8ea1028.tar.bz2 scala-ca9f64dfa20fb8d5a4c022f6b9fd2f18a8ea1028.zip |
Encapsulate creating SilentResultValue/SilentTypeError.
Do it consistently...
Diffstat (limited to 'src/compiler')
-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 { |