summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index d8183ea8df..7d48c548a1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1060,8 +1060,13 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
@inline def tpdPos(transformed: Tree) = typedPos(tree.pos, mode, pt)(transformed)
@inline def tpd(transformed: Tree) = typed(transformed, mode, pt)
- @inline def warnValueDiscard(): Unit =
- if (!isPastTyper && settings.warnValueDiscard) context.warning(tree.pos, "discarded non-Unit value")
+ @inline def warnValueDiscard(): Unit = if (!isPastTyper && settings.warnValueDiscard) {
+ def isThisTypeResult = (tree, tree.tpe) match {
+ case (Apply(Select(receiver, _), _), SingleType(_, sym)) => sym == receiver.symbol
+ case _ => false
+ }
+ if (!isThisTypeResult) context.warning(tree.pos, "discarded non-Unit value")
+ }
@inline def warnNumericWiden(): Unit =
if (!isPastTyper && settings.warnNumericWiden) context.warning(tree.pos, "implicit numeric widening")