diff options
Diffstat (limited to 'src/compiler/scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/CompilerCommand.scala | 10 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 |
3 files changed, 10 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index 3879d7b425..24da6ba487 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -103,15 +103,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings) { val components = global.phaseNames // global.phaseDescriptors // one initializes s"Phase graph of ${components.size} components output to ${genPhaseGraph.value}*.dot." } - // would be nicer if we could ask all the options for their helpful messages - else { - val sb = new StringBuilder - allSettings foreach { - case s if s.isHelping => sb append s.help - case _ => - } - sb.toString - } + else allSettings.filter(_.isHelping).map(_.help).mkString("\n\n") } /** diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index e10fa3a114..d81d688267 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -38,11 +38,8 @@ trait ScalaSettings extends AbsScalaSettings /** If any of these settings is enabled, the compiler should print a message and exit. */ def infoSettings = List[Setting](version, help, Xhelp, Yhelp, showPlugins, showPhases, genPhaseGraph) - /** Any -option:help? */ - private def multihelp = allSettings exists { case s => s.isHelping case _ => false } - - /** Is an info setting set? */ - def isInfo = (infoSettings exists (_.isSetByUser)) || multihelp + /** Is an info setting set? Any -option:help? */ + def isInfo = infoSettings.exists(_.isSetByUser) || allSettings.exists(_.isHelping) /** Disable a setting */ def disable(s: Setting) = allSettings -= s 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") |