summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #5402 from som-snytt/issue/8040-unusedSeth Tisue2017-04-1048-129/+737
|\ | | | | SI-8040 Improve unused warnings
| * SD-363 Xlint no warn deprecated params, defaultsSom Snytt2017-04-062-4/+15
| | | | | | | | | | | | | | Deprecation is an escape hatch for unused params. Since default arg getters receive values of previous args, don't warn when they are unused.
| * 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 No warn DummyImplicitSom Snytt2017-03-112-1/+4
| | | | | | | | It's just a dummy.
| * SI-8040 Xlint enables unused warningsSom Snytt2017-03-1115-19/+23
| | | | | | | | | | | | | | | | | | | | | | | | `-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 No warn args to super, main argsSom Snytt2017-03-118-23/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | `class B(x: X) extends A(x)` uses `x` in ctor, where it is detectable as an ordinary param. `implicit class C(val s: String)` may not use `s` in extension methods, so don't warn. Don't warn required args to main method. Don't warn about synthetic isDefinedAt in anonymous functions, or about defaultCase$.
| * SI-8040 Avoid Null companionSom Snytt2017-03-111-2/+2
| | | | | | | | | | | | Don't warn on the private constructor of an abstract class. Instead, take it as a signal that the class must not be instantiated.
| * SI-7860 No warn private implicit value classSom Snytt2017-03-116-4/+74
| | | | | | | | | | | | | | | | | | | | | | | | Previously, warned on unused synthetic companion. Also avoid false negative via hashcode reference to the underlying value. Avoid the synthetic conversion method for the implicit class (whose RHS always uses the class); the def itself is synthetic so is normally not warned.
| * SI-8040 Warn patvars in casedefsSom Snytt2017-03-114-23/+51
| | | | | | | | | | | | | | | | Collect bindings in casedefs unless "@-bound to _". Also minor refactor to make it easier to see the cases of `id @ _`. Tupled matching is supposed to be efficient either now or soon.
| * SI-9839 Avoid crash in macro import selector posSom Snytt2017-03-114-7/+27
| | | | | | | | | | | | Ignore bad name pos. Also delete unused val. Thanks, `-Ywarn-unused`!
| * SI-8040 Warn unused parametersSom Snytt2017-03-1112-46/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1112-20/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-9158 No warn for comprehension patvarsSom Snytt2017-03-113-9/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Midstream assignments should not cause unused warnings. Currently the encoding doesn't pass them along, but passes the value from which they were destructured. For for-comprehensions only, the patvar transform tags the binds so that they are not warned if they turn up in a valdef and are unused. Extractors are invoked multiple times if the patvar is used later, as noted on the ticket. In a yield, the valdef is emitted only if the patvar is referenced (possibly saving the extra extraction), so there is no warning there currently.
| * SI-8040 Heeding -Ywarn-unusedSom Snytt2017-03-115-10/+8
| | | | | | | | | | | | | | Polish notation, as in shoe-shine, as recommended by the warning. Minor clean-ups as advocated by `Ywarn-unused` and `Xlint`.
| * SI-8040 Warn unused pattern varsSom Snytt2017-03-118-10/+84
| | | | | | | | | | | | | | | | | | | | | | | | Warn for unused `case X(x) =>` but, as an escape hatch, not for `case X(x @ _) =>`. The latter form is deemed documentary. (Named args could serve a similar purpose, `case X(x = _) =>`.) An attachment is used to mark the bound var, and the symbol position is used to correlate the identifier with the variable that is introduced. This mechanism doesn't work yet when only a single var is defined.
| * SI-8040 Improve unused warningsSom Snytt2017-03-113-28/+101
| | | | | | | | | | | | | | Add symbol names, don't warn for both getters and setters or for synthetics (except default arg getters). Tweak messages for readability.
* | Merge pull request #5816 from adriaanm/userdefined-apply-212Adriaan Moors2017-04-1010-213/+451
|\ \ | | | | | | Allow user-defined `[un]apply` in case companion
| * | Boy scout mkTypeCompleterAdriaan Moors2017-04-062-118/+143
| | | | | | | | | | | | | | | Create named subclasses, preserve factory methods for external users. Make explicit that TypeCompleterBase is not meant for wrapping.
| * | Use CompleterWrapper for implicitFactoryMethodCompleterAdriaan Moors2017-04-062-7/+8
| | | | | | | | | | | | | | | mkTypeCompleter is not suitable for wrapping potentially polymorphic completers
| * | Clean up copyMethodCompleter, capture lessAdriaan Moors2017-04-061-8/+8
| | |
| * | Refactor to reduce assignSymbol indirectionAdriaan Moors2017-04-063-55/+37
| | | | | | | | | | | | | | | | | | - remove logging wrapper that also does important work - `assignAndEnterSymbol(tree)` --> `enterInScope(assignMemberSymbol(tree))` - reduce redundant type test (we know it's an import/package/member)
| * | Create scope only onceAdriaan Moors2017-04-061-6/+7
| | |
| * | `CompleterWrapper` delegates `typeParams`.Adriaan Moors2017-04-062-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes the problem reported with #5730 by xuwei-k in scala/scala-dev#352. The problem was already present before the introduction of `applyUnapplyMethodCompleter`, as 63f7b35 (in #5294) introduced a similar bug where the `PolyTypeCompleter`'s `typeParams` override was masked.
| * | Improvements based on reviews by Lukas & JasonAdriaan Moors2017-04-066-24/+107
| | |
| * | Clarify spec of interaction of existing vs synthetic apply/unapplyAdriaan Moors2017-04-061-11/+10
| | | | | | | | | | | | | | | When matching user-defined apply/unapply members exist in a case class's companion object, don't add clashing synthetic ones.
| * | Allow user-defined `[un]apply` in case companionAdriaan Moors2017-04-054-24/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't emit a synthetic `apply` (or `unapply`) when it would clash with an existing one. This allows e.g., a `private apply`, along with a `case class` with a `private` constructor. We have to retract the synthetic method in a pretty roundabout way, as we need the other methods and the owner to be completed already. Unless we have to complete the synthetic `apply` while completing the user-defined one, this should not be a problem. If this does happen, this implies there's a cycle in computing the user-defined signature and the synthetic one, which is not allowed.
* | | Merge pull request #5801 from janekdb/topic/2.12/spec-trailing-punctuationSeth Tisue2017-04-104-10/+15
|\ \ \ | | | | | | | | Consistify trailing punctuation in spec
| * | | Fix == in spec linearization examplesJanek Bogucki2017-04-104-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Also - Consistify trailing punctuation - Use whitespace to group linearization examples
* | | | Merge pull request #5786 from ↵Seth Tisue2017-04-1015-24/+24
|\ \ \ \ | |/ / / |/| | | | | | | | | | | janekdb/topic/2.12.x-scaladoc-spelling-corrections-3 Fix Greek Mythology references in compiler package
| * | | Fix Greek Mythology references in compiler packageJanek Bogucki2017-04-1015-24/+24
|/ / / | | | | | | | | | | | | | | | | | | Improve documentation some packages and correct some typos in these directories, - compiler - library
* | | Merge pull request #5838 from som-snytt/issue/2458Lukas Rytz2017-04-105-33/+58
|\ \ \ | | | | | | | | SI-2458 Make spec example live test
| * | | SI-2458 Make spec example live testSom Snytt2017-04-095-33/+58
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | Synchronize the live test with the spec update, which is trivial. Also add a neg test showing that an imported name remains ambiguous even if it resolves to the definition in scope with which it is ambiguous.
* | | Merge pull request #5837 from adriaanm/merge-2.11.x-into-2.12.xAdriaan Moors2017-04-0819-653/+78
|\ \ \ | | | | | | | | Catch up with 2.11.x
| * \ \ Merge 2.11.x into 2.12.xAdriaan Moors2017-04-070-0/+0
| |\ \ \ | | | | | | | | | | | | | | | Skip to 7fa3823 (2.11.x HEAD)
| | * | | Bye bye JIRAAdriaan Moors2017-04-071-2/+1
| | | | |
| | * | | Merge pull request #5828 from adriaanm/userdefined-apply-352Adriaan Moors2017-04-052-0/+16
| | |\ \ \ | | | | | | | | | | | | `CompleterWrapper` delegates `typeParams`.
| | | * | | `CompleterWrapper` delegates `typeParams`.Adriaan Moors2017-04-042-0/+16
| | |/ / / | | | | | | | | | | | | | | | Fixes the problem reported with #5730 by xuwei-k in scala/scala-dev#352.
| | * | | Merge pull request #5821 from adriaanm/revert-5664-bincoStefan Zeiger2017-04-048-622/+25
| | |\ \ \ | | | | | | | | | | | | Revert #5664 because the binary incompatible change leaks via erasure
| | | * | | Revert "Optimize slice and take in ArrayOps, WrappedArray"Adriaan Moors2017-04-034-450/+10
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit d540bf01fe4d9e5c56a68b0d3bada9d97af77e3f.
| | | * | | Revert "Optimised implementation of List.filter/filterNot"Adriaan Moors2017-04-035-128/+5
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit eb5c51383a63c5c3420e53ef021607ff5fd20296.
| | | * | | Revert "Handle WrappedArray the same way as ArrayOps for binary compatibility"Adriaan Moors2017-04-032-67/+33
| | |/ / / | | | | | | | | | | | | | | | This reverts commit f24c2603d0acee5bcb6d5d80bf1e1a4645fa74f0.
| * | | | Revert "Optimize slice and take in ArrayOps, WrappedArray"Adriaan Moors2017-04-074-451/+11
| | | | | | | | | | | | | | | | | | | | This reverts commit d540bf01fe4d9e5c56a68b0d3bada9d97af77e3f.
| * | | | Revert "Optimised implementation of List.filter/filterNot"Adriaan Moors2017-04-075-128/+5
| | | | | | | | | | | | | | | | | | | | This reverts commit eb5c51383a63c5c3420e53ef021607ff5fd20296.
| * | | | Revert "Handle WrappedArray the same way as ArrayOps for binary compatibility"Adriaan Moors2017-04-072-67/+33
| | | | | | | | | | | | | | | | | | | | This reverts commit f24c2603d0acee5bcb6d5d80bf1e1a4645fa74f0.
| * | | | Merge 2.11.x into 2.12.xAdriaan Moors2017-04-070-0/+0
| |\| | | | | | | | | | | | | | | | | | Skip to 6008e4b Bump versions on 2.11.9 release
| | * | | Bump versions on 2.11.9 releaseAdriaan Moors2017-03-285-6/+6
| | | | |
| | * | | Merge pull request #5804 from jvican/stub-errors-2.11.8Adriaan Moors2017-03-2731-36/+465
| | |\ \ \ | | | | | | | | | | | | Backport 2.11.9: Improve stub error messages (SCP-009 proposal)
| | | * | | Disable stub warning by default.Oscar Boykin2017-03-254-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we create a class symbols from a classpath elements, references to other classes that are absent from the classpath are represented as references to "stub symbols". This is not a fatal error; for instance if these references are from the signature of a method that isn't called from the program being compiled, we don't need to know anything about them. A subsequent attempt to look at the type of a stub symbols will trigger a compile error. Currently, the creation of a stub symbol incurs a warning. This commit removes that warning on the basis that it isn't something users need to worry about. javac doesn't emit a comparable warning. The warning is still issued under any of `-verbose` / `-Xdev` / `-Ydebug`.
| | | * | | Improve stub error messages (SCP-009 proposal)jvican2017-03-2428-31/+461
| | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following commit message is a squash of several commit messages. - This is the 1st commit message: Add position to stub error messages Stub errors happen when we've started the initialization of a symbol but key information of this symbol is missing (the information cannot be found in any entry of the classpath not sources). When this error happens, we better have a good error message with a position to the place where the stub error came from. This commit goes into this direction by adding a `pos` value to `StubSymbol` and filling it in in all the use sites (especifically `UnPickler`). This commit also changes some tests that test stub errors-related issues. Concretely, `t6440` is using special Partest infrastructure and doens't pretty print the position, while `t5148` which uses the conventional infrastructure does. Hence the difference in the changes for both tests. - This is the commit message #2: Add partest infrastructure to test stub errors `StubErrorMessageTest` is the friend I introduce in this commit to help state stub errors. The strategy to test them is easy and builds upon previous concepts: we reuse `StoreReporterDirectTest` and add some methods that will compile the code and simulate a missing classpath entry by removing the class files from the class directory (the folder where Scalac compiles to). This first iteration allow us to programmatically check that stub errors are emitted under certain conditions. - This is the commit message #3: Improve contents of stub error message This commit does three things: * Keep track of completing symbol while unpickling First, it removes the previous `symbolOnCompletion` definition to be more restrictive/clear and use only positions, since only positions are used to report the error (the rest of the information comes from the context of the `UnPickler`). Second, it adds a new variable called `lazyCompletingSymbol` that is responsible for keeping a reference to the symbol that produces the stub error. This symbol will usually (always?) come from the classpath entries and therefore we don't have its position (that's why we keep track of `symbolOnCompletion` as well). This is the one that we have to explicitly use in the stub error message, the culprit so to speak. Aside from these two changes, this commit modifies the existing tests that are affected by the change in the error message, which is more precise now, and adds new tests for stub errors that happen in complex inner cases and in return type of `MethodType`. * Check that order of initialization is correct With the changes introduced previously to keep track of position of symbols coming from source files, we may ask ourselves: is this going to work always? What happens if two symbols the initialization of two symbols is intermingled and the stub error message gets the wrong position? This commit adds a test case and modifications to the test infrastructure to double check empirically that this does not happen. Usually, this interaction in symbol initialization won't happen because the `UnPickler` will lazily load all the buckets necessary for a symbol to be truly initialized, with the pertinent addresses from which this information has to be deserialized. This ensures that this operation is atomic and no other symbol initialization can happen in the meantime. Even though the previous paragraph is the feeling I got from reading the sources, this commit creates a test to double-check it. My attempt to be better safe than sorry. * Improve contents of the stub error message This commit modifies the format of the previous stub error message by being more precise in its formulation. It follows the structured format: ``` s"""|Symbol '${name.nameKind} ${owner.fullName}.$name' is missing from the classpath. |This symbol is required by '${lazyCompletingSymbol.kindString} ${lazyCompletingSymbol.fullName}'. ``` This format has the advantage that is more readable and explicit on what's happening. First, we report what is missing. Then, why it was required. Hopefully, people working on direct dependencies will find the new message friendlier. Having a good test suite to check the previously added code is important. This commit checks that stub errors happen in presence of well-known and widely used Scala features. These include: * Higher kinded types. * Type definitions. * Inheritance and subclasses. * Typeclasses and implicits. - This is the commit message #4: Use `lastTreeToTyper` to get better positions The previous strategy to get the last user-defined position for knowing what was the root cause (the trigger) of stub errors relied on instrumenting `def info`. This instrumentation, while easy to implement, is inefficient since we register the positions for symbols that are already completed. However, we cannot do it only for uncompleted symbols (!hasCompleteInfo) because the positions won't be correct anymore -- definitions using stub symbols (val b = new B) are for the compiler completed, but their use throws stub errors. This means that if we initialize symbols between a definition and its use, we'll use their positions instead of the position of `b`. To work around this we use `lastTreeToTyper`. We assume that stub errors will be thrown by Typer at soonest. The benefit of this approach is better error messages. The positions used in them are now as concrete as possible since they point to the exact tree that **uses** a symbol, instead of the one that **defines** it. Have a look at `StubErrorComplexInnerClass` for an example. This commit removes the previous infrastructure and replaces it by the new one. It also removes the fields positions from the subclasses of `StubSymbol`s. - This is the commit message #5: Keep track of completing symbols Make sure that cycles don't happen by keeping track of all the symbols that are being completed by `completeInternal`. Stub errors only need the last completing symbols, but the whole stack of symbols may be useful to reporting other error like cyclic initialization issues. I've added this per Jason's suggestion. I've implemented with a list because `remove` in an array buffer is linear. Array was not an option because I would need to resize it myself. I think that even though list is not as efficient memory-wise, it probably doesn't matter since the stack will usually be small. - This is the commit message #6: Remove `isPackage` from `newStubSymbol` Remove `isPackage` since in 2.12.x its value is not used.