summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorBrian McKenna <brian@precog.com>2013-01-07 18:17:05 +1000
committerBrian McKenna <brian@precog.com>2013-01-07 19:22:04 +1000
commit66fe64f8f72ba7d574e07d3308d72cd3766a5763 (patch)
treeaca5503608b9265e24d73ded3c144cd34ad7e8a0 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent766bb97114b5932b75340a9169558de61899997e (diff)
downloadscala-66fe64f8f72ba7d574e07d3308d72cd3766a5763.tar.gz
scala-66fe64f8f72ba7d574e07d3308d72cd3766a5763.tar.bz2
scala-66fe64f8f72ba7d574e07d3308d72cd3766a5763.zip
SI-6923 Context now buffers warnings as well as errors
Code that was silently typed would not report warnings, even if it returned a successful result. This appeared in the following code which didn't show warnings even with -Ywarn-adapted-args: def foo(a: Any) = a; foo(1, 2) While the following would show the expected warning: def foo[A](a: Any) = a; foo(1, 2)
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 9d390476db..8722aa3666 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -728,7 +728,15 @@ trait Typers extends Modes with Adaptations with Tags {
if (context1.hasErrors) {
stopStats()
SilentTypeError(context1.errBuffer.head)
- } else SilentResultValue(result)
+ } else {
+ // If we have a successful result, emit any warnings it created.
+ if (context1.hasWarnings) {
+ context1.flushAndReturnWarningsBuffer() foreach {
+ case (pos, msg) => unit.warning(pos, msg)
+ }
+ }
+ SilentResultValue(result)
+ }
} else {
assert(context.bufferErrors || isPastTyper, "silent mode is not available past typer")
withSavedContext(context){