diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-03-24 15:55:31 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-03-24 15:55:31 +1000 |
commit | 2dc40cc7d7d956a510a9278ab236014f3fb564bc (patch) | |
tree | 26849309912c536f39cc538e21e4093b4ea0004d | |
parent | 4f05b1938c6343ea3f36dceada9f26a0b2b69a45 (diff) | |
parent | bf01acd6143552be8a173472a839dfcdee27697c (diff) | |
download | scala-2dc40cc7d7d956a510a9278ab236014f3fb564bc.tar.gz scala-2dc40cc7d7d956a510a9278ab236014f3fb564bc.tar.bz2 scala-2dc40cc7d7d956a510a9278ab236014f3fb564bc.zip |
Merge pull request #4380 from retronym/ticket/9020
SI-9020 Avoid spurious value discarding warning post-typer
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t9020.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t9020.scala | 10 |
3 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index c8970727d4..d01e4f84ba 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 _ => diff --git a/test/files/pos/t9020.flags b/test/files/pos/t9020.flags new file mode 100644 index 0000000000..efb2dd3e6f --- /dev/null +++ b/test/files/pos/t9020.flags @@ -0,0 +1 @@ +-Ywarn-value-discard -Xfatal-warnings diff --git a/test/files/pos/t9020.scala b/test/files/pos/t9020.scala new file mode 100644 index 0000000000..16e31e2572 --- /dev/null +++ b/test/files/pos/t9020.scala @@ -0,0 +1,10 @@ +trait ValueDiscard[@specialized U] { + def u: U +} +/* Was: +scalac-hash v2.11.5 -Ywarn-value-discard test/files/pos/t9020.scala +test/files/pos/t9020.scala:2: warning: discarded non-Unit value + def u: U + ^ +one warning found +*/ |