summaryrefslogtreecommitdiff
path: root/test/files/neg
Commit message (Collapse)AuthorAgeFilesLines
* Allow user-defined `[un]apply` in case companionAdriaan Moors2017-04-052-0/+44
| | | | | | | | | | | | | 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 #5724 from jvican/stub-errors-2.12.xAdriaan Moors2017-03-271-15/+12
|\ | | | | SCP-009: Improve direct dependency experience
| * Improve stub error messages (SCP-009 proposal)jvican2017-03-241-15/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #5643 from som-snytt/issue/8417Adriaan Moors2017-03-223-0/+22
|\ \ | | | | | | SI-8417 Check adapts of each param section
| * | SI-8417 Check adapts of each param sectionSom Snytt2017-02-203-0/+22
| |/ | | | | | | | | | | | | Previously, adaptations like auto-tupling were checked only on the last param section of an application. This commit runs the sanity check always.
* | remove orphaned checkfilesSeth Tisue2017-03-202-8/+0
| | | | | | | | thank you tools/rm-orphan-checkfiles script
* | Merge pull request #5622 from edmundnoble/extra-errsAdriaan Moors2017-03-023-8/+8
|\ \ | | | | | | Improved error messages for identically named, differently prefixed types
| * | Match error lengthsEdmund Noble2017-02-071-1/+1
| | |
| * | Improved error messages for identically named, differently prefixed typesEdmund Noble2016-12-313-8/+8
| | |
* | | SI-10207 Error before update conversionSom Snytt2017-02-262-0/+20
| | | | | | | | | | | | | | | | | | Gaze deeper for errors before committing to conversion of assignment to update. The error buried in the transformed tree escapes notice of retypechecking and leaks to backend.
* | | Revert "SI-10133 Require escaped single quote char lit"Adriaan Moors2017-02-213-15/+2
| | |
* | | Merge pull request #5629 from som-snytt/issue/10120-quote-errAdriaan Moors2017-02-203-2/+15
|\ \ \ | |_|/ |/| | SI-10133 Require escaped single quote char lit
| * | SI-10120 Extra advice on unclosed char literalSom Snytt2017-01-083-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Folks from other languages might mistakenly enclose a string in single quotes. Since this presents as a symbol literal followed by the unpaired single quote, we can add a syntax reminder. Also polish the wording for bad string interpolation.
| * | SI-10133 Require escaped single quote char litSom Snytt2017-01-082-1/+8
| |/ | | | | | | | | | | The spec specifically requires `'\''` and not `'''`. The error consumes all consecutive single quotes.
* | Merge pull request #5648 from som-snytt/issue/10148Seth Tisue2017-02-162-2/+25
|\ \ | | | | | | SI-10148 Follow Java for float literals
| * | SI-10148 Follow Java for float literalsSom Snytt2017-01-182-2/+25
| |/ | | | | | | | | Use `Float.parseFloat` instead of converting from Double. Error when a value rounds to zero.
* | Merge pull request #5546 from som-snytt/issue/9636Adriaan Moors2017-02-164-1/+25
|\ \ | | | | | | SI-9636 More precise error pos on apply inference
| * | SI-9636 More precise error pos on apply inferenceSom Snytt2016-12-204-1/+25
| |/ | | | | | | | | If a method type arg is inferred Any, warn about the function and not the innocent arg.
* | Merge pull request #5662 from teldosas/SI-9675Adriaan Moors2017-02-163-0/+52
|\ \ | | | | | | SI-9675 warn about non-sensible equals in anonymous functions
| * | Add warning about non-sensible equals in anonymous functionsteldosas2017-02-013-0/+52
| |/
* | Merge pull request #5542 from retronym/ticket/10066Adriaan Moors2017-02-162-0/+45
|\ \ | | | | | | SI-10066 Fix crash in erroneous code with implicits, dynamic
| * | SI-10066 Fix crash in erroneous code with implicits, dynamicJason Zaugg2016-11-182-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compiler support in the typechecker for `scala.Dynamic` is very particular about the `Context` in which it is typechecked. It looks at the `tree` in the enclosing context to find the expression immediately enclosing the dynamic selection. See the logic in `dyna::mkInvoke` for the details. This commit substitutes the result of `resetAttrs` into the tree of the typer context before continuing with typechecking.
* | | Correct the AbstractVar error messageJon Pretty2017-02-093-5/+5
| | | | | | | | | | | | | | | | | | | | | The error currently reads "only classes can have declared but undefined members", which isn't true on two counts: traits can have them, and concrete classes cannot. This corrects the error message to read "only traits and abstract classes can have declared but undefined members".
* | | Merge pull request #5245 from dwijnand/trailing-commasAdriaan Moors2017-02-082-0/+186
|\ \ \ | | | | | | | | SI-4986 The glorious return of Comma McTraily
| * | | SI-4986 SIP-27 Trailing Comma (multi-line only) supportDale Wijnand2016-12-112-0/+186
| | | |
* | | | Merge pull request #5646 from som-snytt/issue/8685Adriaan Moors2017-02-071-1/+4
|\ \ \ \ | | | | | | | | | | SI-8685 Warn on deprecated case ctor
| * | | | SI-8685 Warn on deprecated case ctorSom Snytt2017-01-161-1/+4
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The narrow use case in the ticket was just to warn on `C.apply` when the constructor has been deprecated. Someone added code to warn after the apply is rewritten, but it wasn't checking the constructor (and the tree was checked before but not after transform).
* | | | Merge pull request #5585 from som-snytt/issue/10097Adriaan Moors2017-02-0710-2/+45
|\ \ \ \ | | | | | | | | | | SI-10097 Error if no non-implicit case class param
| * | | | SI-10097 Adapt unless -Xsource:2.13Som Snytt2016-12-145-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For 2.12 migration, insert missing case class param section, strip caseaccessor from implicit paramsection, and deprecate the adaptation.
| * | | | SI-8704 Also warn if effectively multiple implicitSom Snytt2016-12-143-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | SI-8704 Error on bad implicit sectionsSom Snytt2016-12-144-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of aborting when a class def has extra parameter section, take all parameter sections and sanity check the use of leading implicit to indicate an implicit parameter section.
| * | | | SI-10097 Error if no non-implicit case class paramSom Snytt2016-12-143-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Case class must have a non-implicit param list. Error early, error often. Also update spec to say that class implicitly gets a non-implicit parameter section if it doesn't have one, and that a case class must have one.
* | | | | Merge pull request #5667 from som-snytt/issue/maxerrsLukas Rytz2017-02-036-0/+94
|\ \ \ \ \ | | | | | | | | | | | | SI-9729 -Xmaxerrs to limit messages
| * | | | | SI-9729 -Xmaxerrs to limit messagesSom Snytt2017-01-316-0/+94
| | |/ / / | |/| | | | | | | | | | | | | | | | | | Since 2.7.2, console reporter has limited error messages to a fixed 100. Use `-Xmaxerrs -Xmaxwarns` as from `javac` to configure.
* / | | | adjust to partest 1.1.0's new mixed Java/Scala compilationLukas Rytz2017-01-275-8/+8
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | upgrades partest from 1.0.17 to 1.1.0 https://github.com/scala/scala-partest/pull/69 changed the mode for mixed compilation, which used to be 1. scalac *.java *.scala -d o 2. javac *.java -d o -cp o 3. scalac *.scala -d o -cp o Now the third step is skipped. This required some adjustments to existing tests. - t7014 is split in two groups, the fix is for separate compilation. - t7582 is also split. It tests inliner warnings when inling code that accesses Java-defined package-private code. Inlining from Java only works in separate compilation (no bytecode available in mixed compilation). - Java compiler warnings of "run" tests were not reported in the old scheme, now they are. Deprecation / unchecked warnings were removed from t6240, t8786, varargs. - t4788 required a .check file update to pass, which hints at a bug. I will re-open SI-4788 and investigate later.
* | | | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2016-12-2013-0/+138
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | merge/2.11.x-to-2.12.x-20161220 Conflicts: bincompat-backward.whitelist.conf build.xml src/compiler/scala/tools/nsc/typechecker/Typers.scala src/library/scala/collection/immutable/NumericRange.scala
| * \ \ \ Merge pull request #5487 from lrytz/java-constantsAdriaan Moors2016-12-157-0/+104
| |\ \ \ \ | | | | | | | | | | | | SI-3236 constant types for literal final static java fields
| | * | | | neg test for parsing constants in Java sourcesLukas Rytz2016-11-027-0/+104
| | | | | |
| * | | | | SI-9834 Show expansion of update on errorSom Snytt2016-11-251-0/+1
| | | | | |
| * | | | | SI-9834 Improve error on failed op=Som Snytt2016-11-256-0/+33
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If rewriting `x += y` fails to typecheck, emit error messages for both the original tree and the assignment. If rewrite is not attempted because `x` is a val, then say so. The error message at `tree.pos` is updated with the additional advice. SI-8763 Crash in update conversion When there are already errors, don't attempt mechanical rewrites.
| * | | | Merge pull request #5343 from milessabin/topic/si-2712-backportAdriaan Moors2016-10-188-0/+78
| |\ \ \ \ | | | | | | | | | | | | SI-2712 Add support for higher order unification
| | * | | | SI-2712 Add support for higher order unificationMiles Sabin2016-08-158-0/+78
| | | | | |
| * | | | | Partial fix for SI-7046Miles Sabin2016-08-156-0/+85
| |/ / / /
| * | | | Update partest to 1.0.12, test case for reporting invalid flagsLukas Rytz2016-02-174-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: test/files/pos/t3420.flags versions.properties
* | | | | SI-10068 Only permit elidable methodsSom Snytt2016-12-143-0/+23
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | In refchecks, check that symbol with `@elidable` is a method. When eliding in uncurry, doublecheck. The check is enabled under `-Xsource:2.13`.
* | | | Merge pull request #5558 from larsrh/topic/deprecated-y-flagsAdriaan Moors2016-12-133-13/+0
|\ \ \ \ | | | | | | | | | | Remove deprecated -Y flags
| * | | | remove deprecated compiler flag "-Yeta-expand-keeps-star"Lars Hupel2016-12-013-13/+0
| | | | | | | | | | | | | | | | | | | | This was slated for removal in 2.12.
* | | | | Merge pull request #5550 from retronym/ticket/3772Lukas Rytz2016-12-124-0/+40
|\ \ \ \ \ | |_|_|/ / |/| | | | SI-3772 Fix detection of term-owned companions
| * | | | SI-3772 Fix detection of term-owned companionsJason Zaugg2016-11-294-0/+40
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Companion detection consults the scopes of enclosing Contexts during typechecking to avoid the cycles that would ensue if we had to look at into the info of enclosing class symbols. For example, this used to typecheck: object CC { val outer = 42 } if ("".isEmpty) { case class CC(c: Int) CC.outer } This logic was not suitably hardened to find companions in exactly the same nesting level. After fixing this problem, a similar problem in `Namer::inCurrentScope` could be solved to be more selective about synthesizing a companion object. In particular, if a manually defined companion trails after the case class, don't create an addiotional synthetic comanpanion object.
* | | | Revert existential infer part of #5376Adriaan Moors2016-12-012-13/+0
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | It wasn't a good idea after all. Also removed some tracing code that I cannot imagine was ever used in a production compiler. It's still just a recompile away. Fixes scala/scala-dev#280