summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-03-12 15:25:14 -0700
committerJason Zaugg <jzaugg@gmail.com>2015-03-12 15:26:57 -0700
commitbf01acd6143552be8a173472a839dfcdee27697c (patch)
treeae36faebd5d3d73ac5f3926867b966332a39742c /src
parentfa33395a25c87115c910e8d4a4124aee6134062b (diff)
downloadscala-bf01acd6143552be8a173472a839dfcdee27697c.tar.gz
scala-bf01acd6143552be8a173472a839dfcdee27697c.tar.bz2
scala-bf01acd6143552be8a173472a839dfcdee27697c.zip
SI-9020 Avoid spurious value discarding warning post-typer
Typechecking during the specialization phase was emitting a bogus warning about value discarding. Such warnings in the typer should be guarded by `!isPastTyper` to restrict the analysis to the code the user originally wrote, rather than the results of later typechecking. I've made this change to the value discarding warning. I've also changed a numeric widening warning in the vicinity, although I do not have a test case for that.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 3a85d16f55..7ef739e711 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1039,11 +1039,11 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// to non-continuation types.
if (tree.tpe <:< AnyTpe) pt.dealias match {
case TypeRef(_, UnitClass, _) => // (12)
- if (settings.warnValueDiscard)
+ if (!isPastTyper && settings.warnValueDiscard)
context.warning(tree.pos, "discarded non-Unit value")
return typedPos(tree.pos, mode, pt)(Block(List(tree), Literal(Constant(()))))
case TypeRef(_, sym, _) if isNumericValueClass(sym) && isNumericSubType(tree.tpe, pt) =>
- if (settings.warnNumericWiden)
+ if (!isPastTyper && settings.warnNumericWiden)
context.warning(tree.pos, "implicit numeric widening")
return typedPos(tree.pos, mode, pt)(Select(tree, "to" + sym.name))
case _ =>