summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/settings/Warnings.scala
Commit message (Collapse)AuthorAgeFilesLines
* SI-8040 Defer deprecation of -Ywarn-unused-importsSom Snytt2017-04-061-1/+1
| | | | So as not to complicate established builds in the wild.
* SI-8040 Retreat on paramsSom Snytt2017-04-061-2/+5
| | | | | | Don't warn unused params when `-Xlint`. Don't disable under lint, so `-Ywarn-unused -Xlint` works.
* SI-8040 Xlint enables unused warningsSom Snytt2017-03-111-6/+4
| | | | | | | | | | | | `-Ywarn-unused-import` is deprecated in favor of `-Ywarn-unused:imports`. `-Xlint` does not yet enable `-Ywarn-unused:patvars`. But the default for `-Ywarn-unused` is everything, including `patvars`. So `-Xlint:unused` is the populist option, `-Ywarn-unused` more exclusive. Tests are fixed by narrowing scope of `-Xlint` when specified.
* SI-8040 Warn unused parametersSom Snytt2017-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | One can `-Ywarn-unused:params` or more narrowly warn only for unused implicit parameters with `-Ywarn-unused:implicits`. Params includes constructor parameters. The settings for privates and locals are not yet distinguished. ``` $ skalac -Ywarn-unused:help Enable or disable specific `unused' warnings imports Warn if an import selector is not referenced. patvars Warn if a variable bound in a pattern is unused. privates Warn if a private member is unused. locals Warn if a local definition is unused. params Warn if a value parameter is unused. implicits Warn if an implicit parameter is unused. ```
* SI-8040 Warn unused flagsSom Snytt2017-03-111-5/+35
| | | | | | | | | | | | | | | | Introduce `-Ywarn-unused:x,y,z` and exploit `-Ywarn-unused:patvars`. Although the tree attachment for shielding patvars from warnings is not structural, sneaking the settings flag into the reflection internal TreeGen is awkward. Add test to ensure isolation of patvars warning from others. `-Ywarn-unused-import` is an alias for `-Ywarn-unused:imports`. `-Xlint:unused` is an alias for `-Ywarn-unused`, but not enabled yet. The help text advises to use `-Ywarn-unused`. The future can decide if `-Xlint:unused-imports` is warranted.
* SI-8704 Also warn if effectively multiple implicitSom Snytt2016-12-141-0/+2
| | | | | | | | | | | Current semantics are that leading implicit param turns the parameter section into an implicit section (though without making other params implicitly implicit). Warn if more than one head of a param section is implicit, since that results in multiple implicit param sections.
* Add a -Xmixin-force-forwarders ChoiceSettingLukas Rytz2016-09-021-2/+0
|
* Emit mixin forwarders for JUnit-annotated trait methods by defaultLukas Rytz2016-09-011-1/+1
| | | | | | | | | | | JUnit 4 does not support default methods. For better user experience, this commit makes the compiler generate mixin forwarders for inherited trait methods that carry a JUnit annotation. The -Yjunit-trait-methods-no-forwarders flag disables this behavior. This supersedes the scala-js/scala-2.12-junit-mixin-plugin compiler plugin.
* Emit a warning when a constant expression evaluates to an ↵Olli Helenius2016-05-021-0/+2
| | | | ArithmeticException (#5123)
* More efficient code for deciding if a mixin forwarder is needed (#5116)Lukas Rytz2016-04-251-0/+2
| | | | Also adds a warning on junit test methods that compile as default methods.
* General cleanups and less warnings during a Scala buildsoc2016-04-041-2/+0
|
* it's Scaladoc, not "ScalaDoc" or "Scala doc"Seth Tisue2015-11-121-1/+1
| | | | | renaming the existing ScalaDoc and ScalaDocReporter classes might break stuff, sadly, but at least we can fix the rest
* Fix small grammar error in `Warnings`Simon Schäfer2015-05-221-1/+1
|
* SI-7623 Trailing sequence wildcard warningSom Snytt2015-01-211-5/+8
| | | | | | | | | | | | | | | | | | | An -Xlint:stars-align warning for the case of patterns with at least one "fixed" component and a varargs component. Warn if the fixed patterns don't exactly align with the fixed value components, such that a sequence wildcard aligns exactly with the varargs component (either a T* parameter in a case class or a Seq[T] in an extractor result). This addresses the case of the xml.Elem extractor, which does not correspond to the Elem class constructor. One can be fooled into supplying an extra field for extraction. Vanilla extractors of type `Option[Seq[_]]` are unaffected by this flag. It's OK to ask for `case X(a, b, c)` in the expectation that three results are forthcoming. There is no semantic confusion over where the varargs begin.
* Fix many typos in docs and commentsmpociecha2014-12-141-1/+1
| | | | | | | | | | | | | This commit corrects many typos found in scaladocs, comments and documentation. It should reduce a bit number of PRs which fix one typo. There are no changes in the 'real' code except one corrected name of a JUnit test method and some error messages in exceptions. In the case of typos in other method or field names etc., I just skipped them. Obviously this commit doesn't fix all existing typos. I just generated in IntelliJ the list of potential typos and looked through it quickly.
* Address PR feedback, fix MultiChoiceSetting.containsLukas Rytz2014-09-081-19/+14
|
* Use Enumeration for MultiChoiceSettingSom Snytt2014-09-051-47/+53
| | | | | | | | | | | This is pretty easy, since a ValueSet is a BitSet. When the setting is updated, recompute the current set of values, which is cheap and succinct. Checking a flag is also easy and fast. Choices in MultiChoiceSettings may enable other choices.
* -Ystatistics accepts a list of phases, cleanups in MultiChoiceSettingLukas Rytz2014-09-021-123/+71
| | | | | MultiChoiceSetting and Xlint with its deprecated aliases is now a bit simpler, but there's still room for improvement, as noted in comments.
* SI-5691 lint warning when a type parameter shadows an existing type.Antoine Gourlay2014-08-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | This adds a new lint warning for when a class/method/type-member's type parameter shadows an existing type: `-Xlint:type-parameter-shadow`. It excludes type parameters of synthetic methods (the user can't rename or remove those anyway), otherwise, for example, every case class triggers the warning. Also fixes a test that contained wrong java sources (that didn't even compile...), discovered thanks to the warning. --- This kind of errors shows up every now and then on the mailing-list, on stackoverflow, etc. so maybe a warning would be useful. I was afraid this would yield too many warnings for libraries that are heavy on type parameters, but no: running this on scalaz and shapeless HEAD (`v7.1.0-RC1-41-g1cc0a96` and `v2.0.0-M1-225-g78426a0` respectively) yields 44 warnings. None of them are false positives; they usually come from: - scalaz loving using `A` as type parameter, even several levels deep of parametrized classes/methods - or calling a type parameter that will hold a map `Map`, or similar, thus shadowing an existing type
* SI-8736 Restore -language to former glorySom Snytt2014-07-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | MultiChoice allows -language to work like -Xlint. The bug as described was that the setting value was set instead of updated (++=) with additional flags. The unreported bug was that `_` no longer set all settings. The corrected behavior is that "contains" means "it was enabled, or _ was set and it was not disabled explicitly." That is the behavior of `-Xlint` but with a different mechanism, since each lint option is a Setting. A semantic difference is that -Xlint enables all the lint options, but -language does not enable all the language features. `scalac -X` does not explain this additional behavior of the `-Xlint` flag. Also worth noting that `scalac -feature -language unused.scala` failed in 2.11.1 but succeeds silently now.
* SI-8525 MultiChoice takes a helper functionSom Snytt2014-07-181-11/+9
| | | | | | Clean-up code review comments. MultiChoice takes a helper function for outputting help text.
* SI-8525 Multichoice helpSom Snytt2014-07-171-5/+13
| | | | | | Enables -Xlint:help and -language:help. The Settings API makes it difficult to innovate.
* SI-8525 Clarify usage of -Xlint:_,flagSom Snytt2014-07-161-58/+62
| | | | | | | | | | | | | | | | | | | | | Also clarify usage of -Xlint flag. Align more with javac -Xlint:all,-flag,flag where once a flag is explicitly enabled it cannot be disabled, but where the wildcard is a backstop only. (There is no all option yet here.) -Xlint and -Xlint:_ just set a flag which is consulted by any unset lint warning. Xlint warnings consult the state of Xlint when they are unset. Individual -Ywarn-ings do not. Other warnings are explicitly set to false. They can only be enabled programmatically. Some tests are corrected. Also, option order is no longer significant, see the unit test.
* SI-8525 No anonymous lintSom Snytt2014-07-101-16/+81
| | | | | | | | | Turn anonymous references to `settings.lint` into named settings. After that, trust to Adriaan to make them filterable. There are a few remaining top-level -Y lint warnings that are deprecated.
* SI-8525 Add -Xlint:-warn-missing-interpolatorSom Snytt2014-07-081-7/+17
| | | | | | | | | | Turn off lint warnings with negating prefix, and add a lint-only warning for the infamously nagging "Did you forget the interpolator?" That message is made more dignified. Without `-Xlint:false`, there is no mechanism to turn off anonymous linters once `-Xlint` is selected.
* SI-8610 -Xlint is multichoice optionSom Snytt2014-07-081-2/+20
| | | | | | | | | | | | | | | | | | | | | Make -Xlint a "multichoice" option for purposes of option parsing. This allows turning on "lint with these warnings" instead of only "turn off these warnings but enable other lint warnings". ``` $ scalac -Xlint:warn-adapted-args linty.scala # lint plus a warning $ scalac -Xlint warn-adapted-args linty.scala # same $ scalac -Xlint linty.scala # same as now $ scalac -Xlint -- linty.scala # ok, not necessary $ scalac -Xlint _ -- linty.scala # another funky underscore ``` This would also enable Xlint options that are not standalone options, although that is not implemented in this commit. For example, `-Xlint:no-missing-interpolator` could be used to disable that warning. (There is no `-Xoption:flavor=off` syntax.) (`no-` switches would not be enabled by `_`.)
* Group settings should honor user-set individual optionsJason Zaugg2014-02-171-13/+5
| | | | | | | | | | | | | | | In the last commit, we added the ability to explicitly disable boolean settings form the command line. This commit changes group settings (like -optimize), to leave them alone if set explicitly. Examples: `scalac -Xlint -Ywarn-unused:false -optimize -Yinline:false` The mechanism for such settings has also been refactored to `MutableSettings`, to let use reuse this for `-Xlint`.
* SI-7707 SI-7712 Exclude unused warnings from -XlintJason Zaugg2014-02-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | Experience building open source projects like Specs that use `-Xlint` suggests that this warning is too noisy to lump in with the others. We are lacking in more fine-grained control of these things, so simply turning of `-Xlint` in favour of its underlying `-Y` options ends up *losing* some other important warnings that are predicated directly on `-Xlint`. Furthermore, bug reports against M8, SI-7707 SI-7712, show that unused private/local warnings, while far less noisy, are still in need of polish. This commit moves these warnings to a pair of new -Y options, neither of which is part of `-Xlint`.. Let's ask people to opt in for 2.11, and as it stabilizes, we can consider adding it to Xlint (or the desirable evolution of that) in the next release.
* Remove -Xcheck-null setting.Paul Phillips2013-03-131-7/+5
| | | | | | | | | | Maybe this was useful in some way; but no way I ever saw. I have comments which tell me this is exposed in the IDE so I left a stub. I also removed mkCheckInit. That probably sounds like it's related to -Xcheckinit. Guess again, guy-who-thinks-names-mean-things. It was only used by -Xcheck-null.
* Remove code from compiler central.Paul Phillips2012-11-201-6/+9
| | | | | All those old-timey methods whose melodies have become unfashionable.
* Revert "Commenting out unused members."Paul Phillips2012-11-191-9/+5
| | | | This reverts commit 951fc3a486.
* Commenting out unused members.Paul Phillips2012-11-191-5/+9
| | | | | | | | | | | | | | | | | | I want to get this commit into the history because the tests pass here, which demonstrates that every commented out method is not only unnecessary internally but has zero test coverage. Since I know (based on the occasional source code comment, or more often based on knowing something about other source bases) that some of these can't be removed without breaking other things, I want to at least record a snapshot of the identities of all these unused and untested methods. This commit will be reverted; then there will be another commit which removes the subset of these methods which I believe to be removable. The remainder are in great need of tests which exercise the interfaces upon which other repositories depend.
* Merge commit 'refs/pull/1574/head' into merge-210Paul Phillips2012-11-051-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'refs/pull/1574/head': (24 commits) Fixing issue where OSGi bundles weren't getting used for distribution. Fixes example in Type.asSeenFrom Fix for SI-6600, regression with ScalaNumber. SI-6562 Fix crash with class nested in @inline method Brings copyrights in Scaladoc footer and manpage up-to-date, from 2011/12 to 2013 Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013 SI-6606 Drops new icons in, replaces abstract types placeholder icons SI-6132 Revisited, cleaned-up, links fixed, spelling errors fixed, rewordings Labeling scala.reflect and scala.reflect.macros experimental in the API docs Typo-fix in scala.concurrent.Future, thanks to @pavelpavlov Remove implementation details from Position (they are still under reflection.internal). It probably needs more cleanup of the api wrt to ranges etc but let's leave it for later SI-6399 Adds API docs for Any and AnyVal Removing actors-migration from main repository so it can live on elsewhere. Fix for SI-6597, implicit case class crasher. SI-6578 Harden against synthetics being added more than once. SI-6556 no assert for surprising ctor result type Removing actors-migration from main repository so it can live on elsewhere. Fixes SI-6500 by making erasure more regular. Modification to SI-6534 patch. Fixes SI-6559 - StringContext not using passed in escape function. ... Conflicts: src/actors-migration/scala/actors/migration/StashingActor.scala src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala src/compiler/scala/tools/nsc/settings/AestheticSettings.scala src/compiler/scala/tools/nsc/transform/Erasure.scala src/library/scala/Application.scala src/library/scala/collection/immutable/GenIterable.scala.disabled src/library/scala/collection/immutable/GenMap.scala.disabled src/library/scala/collection/immutable/GenSeq.scala.disabled src/library/scala/collection/immutable/GenSet.scala.disabled src/library/scala/collection/immutable/GenTraversable.scala.disabled src/library/scala/collection/mutable/GenIterable.scala.disabled src/library/scala/collection/mutable/GenMap.scala.disabled src/library/scala/collection/mutable/GenSeq.scala.disabled src/library/scala/collection/mutable/GenSet.scala.disabled src/library/scala/collection/mutable/GenTraversable.scala.disabled src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled
| * Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013Heather Miller2012-11-021-1/+1
| |
* | Merge 2.10.x into master to fix breaking tests and keep things up-to-date.Josh Suereth2012-09-271-1/+2
|\|
| * Move -Xdead-code out of the standard -Xlint.Paul Phillips2012-09-261-1/+2
| | | | | | | | It has become extremely noisy for reasons not yet known.
* | Warn when Any or AnyVal is inferred.Paul Phillips2012-08-091-1/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the very small price of annotating types as Any/AnyVal in those cases where we wish to use them, we can obtain useful warnings. I made trunk clean against this warning and found several bugs or at least suboptimalities in the process. I put the warning behind -Xlint for the moment, but I think this belongs on by default, even for this alone: scala> List(1, 2, 3) contains "a" <console>:8: warning: a type was inferred to be `Any`; this may indicate a programming error. List(1, 2, 3) contains "a" ^ res0: Boolean = false Or this punishment meted out by SI-4042: scala> 1l to 5l contains 5 <console>:8: warning: a type was inferred to be `AnyVal`; this may indicate a programming error. 1l to 5l contains 5 ^ res0: Boolean = false A different situation where this arises, which I have seen variations of many times: scala> class A[T](default: T) { def get(x: => Option[T]) = x getOrElse Some(default) } <console>:7: warning: a type was inferred to be `Any`; this may indicate a programming error. class A[T](default: T) { def get(x: => Option[T]) = x getOrElse Some(default) } ^ // Oops, this was what I meant scala> class A[T](default: T) { def get(x: => Option[T]) = x getOrElse default } defined class A Harder to avoid spurious warnings when "Object" is inferred.
* update and normalize copyright noticeAdriaan Moors2012-08-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are the regexp replacements performed: Sxcala -> Scala Copyright (\d*) LAMP/EPFL -> Copyright $1-2012 LAMP/EPFL Copyright (\d*)-(\d*)(,?) LAMP/EPFL -> Copyright $1-2012 LAMP/EPFL Copyright (\d*)-(\d*) Scala Solutions and LAMP/EPFL -> Copyright $1-2012 Scala Solutions and LAMP/EPFL \(C\) (\d*)-(\d*) LAMP/EPFL -> (C) $1-2012 LAMP/EPFL Copyright \(c\) (\d*)-(\d*)(.*?)EPFL -> Copyright (c) $1-2012$3EPFL The last one was needed for two HTML-ified copyright notices. Here's the summarized diff: Created using ``` git diff -w | grep ^- | sort | uniq | mate git diff -w | grep ^+ | sort | uniq | mate ``` ``` - <div id="footer">Scala programming documentation. Copyright (c) 2003-2011 <a href="http://www.epfl.ch" target="_top">EPFL</a>, with contributions from <a href="http://typesafe.com" target="_top">Typesafe</a>.</div> - copyright.string=Copyright 2002-2011, LAMP/EPFL - <meta name="Copyright" content="(C) 2002-2011 LAMP/EPFL"/> - * Copyright 2002-2011 LAMP/EPFL - * Copyright 2004-2011 LAMP/EPFL - * Copyright 2005 LAMP/EPFL - * Copyright 2005-2011 LAMP/EPFL - * Copyright 2006-2011 LAMP/EPFL - * Copyright 2007 LAMP/EPFL - * Copyright 2007-2011 LAMP/EPFL - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL - * Copyright 2009-2011 Scxala Solutions and LAMP/EPFL - * Copyright 2010-2011 LAMP/EPFL - * Copyright 2012 LAMP/EPFL -# Copyright 2002-2011, LAMP/EPFL -* Copyright 2005-2011 LAMP/EPFL -/* NSC -- new Scala compiler -- Copyright 2007-2011 LAMP/EPFL */ -rem # Copyright 2002-2011, LAMP/EPFL ``` ``` + <div id="footer">Scala programming documentation. Copyright (c) 2003-2012 <a href="http://www.epfl.ch" target="_top">EPFL</a>, with contributions from <a href="http://typesafe.com" target="_top">Typesafe</a>.</div> + copyright.string=Copyright 2002-2012 LAMP/EPFL + <meta name="Copyright" content="(C) 2002-2012 LAMP/EPFL"/> + * Copyright 2002-2012 LAMP/EPFL + * Copyright 2004-2012 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL + * Copyright 2010-2012 LAMP/EPFL + * Copyright 2011-2012 LAMP/EPFL +# Copyright 2002-2012 LAMP/EPFL +* Copyright 2005-2012 LAMP/EPFL +/* NSC -- new Scala compiler -- Copyright 2007-2012 LAMP/EPFL */ +rem # Copyright 2002-2012 LAMP/EPFL ```
* Added two new compiler options:Paul Phillips2011-07-291-1/+3
| | | | | | | | | | | | | | | -Ywarn-adapted-args // also included in -Xlint -Yno-adapted-args The former warns when a () is inserted or an argument list is implicitly tupled. The latter errors under the same conditions. Using these options I found several bugs in the distribution which would otherwise be nearly impossible to spot. These bugs were innocuous (I think) but similar bugs could easily be (and have been) otherwise. Certain particularly threatening scenarios are at minimum warned about regardless of options given. Closes SI-4851, no review.
* Adding some Sets/Maps to perRunCaches, and elim...Paul Phillips2011-07-141-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Adding some Sets/Maps to perRunCaches, and eliminating ambiguously named imports. Did a tour of the compiler adding a few longer-lived mutable structures to the per-run cache clearing mechanism. Some of these were not a big threat, but there is (almost) literally no cost to tracking them and the fewer mutable structures which are created "lone wolf style" the easier it is to spot the one playing by his own rules. While I was at it I followed through on long held ambition to eliminate the importing of highly ambiguous names like "Map" and "HashSet" from the mutable and immutable packages. I didn't quite manage elimination but it's pretty close. Something potentially as pernicious which I didn't do much about is this import: import scala.collection._ Imagine coming across that one on lines 407 and 474 of a 1271 file. That's not cool. Some poor future programmer will be on line 1100 and use "Map[A, B]" in some function and only after the product has shipped will it be discovered that the signature is wrong and the rocket will now be crashing into the mountainside straightaway. No review.
* Oh yeah. Backward compatibility stubs, no review.Paul Phillips2011-06-301-0/+5
|
* Warning! Warning! Yes, that's what's in this co...Paul Phillips2011-06-291-0/+57
Warning! Warning! Yes, that's what's in this commit. Why are you panicking? Mostly new command line options: -Xlint // basically, the ones which aren't noisy Ywarn-all -Ywarn-dead-code Ywarn-inaccessible // try this one on the library: -it makes some good points Ywarn-nullary-override Ywarn-nullary-unit -Ywarn-numeric-widen Ywarn-value-discard Some accumulated motivations: The wontfix resolution of ticket #4506 indicates that "def foo" and "def foo()" are always going to be treated differently in some situations and the same in others without users having any way to fix it. Summary expressed in latest comment with which I agree (and quite sadly, given that I've done a lot of work to try to make them usable) is "avoid using structural types like the plague." But the least we can do is warn if you're using parentheses "wrong". I think it would be better if the warning about "def foo()" overriding "def foo" were an error instead. If we have to live with this... trait Me { def f(): Int } class A { def f: Int = 5 } class C extends A with Me { } // error: Int does not take parameters def f(x: C) = x.f() // compiles def f(x: Me) = x.f() // error: Int does not take parameters. Mmph, how can a method be // legal with parameter "Foo" and illegal with parameter "Foo with // Bar" ? def f(x: Me with C) = x.f() The warning about a method contains a reference to a type which is less accessible than the method itself is obviously to those who recall it a response to GenTraversable being private and appearing in flatMap's signature during the 2.9.0 RCs. It avoids warning in the case where the unnormalized type is inaccessible but the normalized version would be, but it could use further refinement.