summaryrefslogtreecommitdiff
path: root/test/files/neg
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'merge/2.10-to-2.11-sept-2' into ↵Lukas Rytz2014-09-027-7/+59
|\ | | | | | | | | | | | | merge/2.11-to-2.12-is-it-really-sept-2-already-where-was-summer Conflicts: versions.properties
| * Merge pull request #3905 from gourlaysama/wip/t5691-2Lukas Rytz2014-08-267-7/+59
| |\ | | | | | | SI-5691 lint warning when a type parameter shadows an existing type.
| | * SI-5691 lint warning when a type parameter shadows an existing type.Antoine Gourlay2014-08-127-7/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge commit '47908f1' into ↵Lukas Rytz2014-09-025-8/+18
|\| | | | | | | | | | | | | | | | | | | | merge/2.11-to-2.12-is-it-really-sept-2-already-where-was-summer Conflicts: src/library/scala/util/matching/Regex.scala
| * | Merge pull request #3886 from adriaanm/report-filterGrzegorz Kossakowski2014-08-262-1/+10
| |\ \ | | | | | | | | part 2 of the big error reporting refactoring
| | * | Encapsulate reporting mode as class of reportBuffer.Adriaan Moors2014-07-181-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reporting mode used to be governed by contextMode. This logic is left in place by this commit, and the consistency of the new and the old is checked. Will be removed in follow-up commit. The main difference is that we no longer throw TypeErrors in buffering mode. There was one instance of context.error in implicit search the exploited the fact that implicit search runs in buffering (silent) mode and thus calls to error(pos,msg) used to throw new TypeError(pos, msg) -- made this explicit, and removed throwing behavior from the buffering context reporter.
| | * | Simplify (ambiguous) error issuing.Adriaan Moors2014-07-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The two functional differences are: - always add the diagnostics string - check erroneousness in `issueAmbiguousTypeErrorUnlessErroneous`, before even constructing the error message. Consider this nugget: ``` - def issueAmbiguousError(pre: Type, sym1: Symbol, sym2: Symbol, err: AbsTypeError) { - issueCommon(err) { case _ if ambiguousErrors => - if (!pre.isErroneous && !sym1.isErroneous && !sym2.isErroneous) ``` I'd like to state for the record that the if-erroneous in the case of the partial function looked super-dodgy: it meant that, when `ambiguousErrors`, `issueCommon` would not get to the `else` branches that buffer or throw, and if the erroneous condition was met, nothing would be issued/buffered/thrown. This refactoring checks this condition up front.
| * | | SI-8512 Infer a type for f"$args"Som Snytt2014-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The f-interpolator gets a type param that better be Any to avoid unfortunate widenings. Hey, it worked! Unfortunately, when `Any` is inferred, `-Xlint:infer-any` takes notice. This is probably a greater problem for the f-interpolator than for quasiquotes, which are a more specialized tool.
| * | | Merge pull request #3889 from som-snytt/issue/6476-altLukas Rytz2014-08-121-2/+2
| |\ \ \ | | |_|/ | |/| | SI-6476 Improve error on escapement
| | * | SI-6476 Improve error on escapementSom Snytt2014-07-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Behavior of escape processing under string interpolation can be confusing. This commit improves the exception message so you know at least what sort of escapes are handled. This came up on SO in the form `s"\d".r`, where it may not be obvious what is throwing and how to work around it. ``` scala> s"\d".r scala.StringContext$InvalidEscapeException: invalid escape '\d' not one of [\b, \t, \n, \f, \r, \\, \", \'] at index 0 in "\d". Use \\ for literal \. scala> s"a\" scala.StringContext$InvalidEscapeException: invalid escape at terminal index 1 in "a\". Use \\ for literal \. ``` Referencing SI-6476 because that has become the magnet ticket for "escape processing under string interpolation, huh?" This doesn't address `$"` and doesn't handle the more interesting parse error `s"a\"b"`.
| * | | Better error message than 'bad symbolic reference'.Adriaan Moors2014-07-221-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | Let's not scare people, and try to give them some advice. PS: we should really come up with a better mechanism for testing errors/warnings
* | | | Merge commit '01f2d27' into ↵Lukas Rytz2014-09-0219-13/+132
|\| | | | | | | | | | | | | | | merge/2.11-to-2.12-is-it-really-sept-2-already-where-was-summer
| * | | SI-8736 Restore -language to former glorySom Snytt2014-07-203-0/+19
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Clarify usage of -Xlint:_,flagSom Snytt2014-07-162-14/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Merge pull request #3792 from som-snytt/issue/8525Lukas Rytz2014-07-1613-13/+97
| |\ | | | | | | SI-8525 -Xlint:nowarn-missing-interpolator
| | * SI-8525 No anonymous lintSom Snytt2014-07-105-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-089-20/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-086-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 `_`.)
| * | Fix -Yno-adapted-args, it would just warn, not errLukas Rytz2014-07-153-0/+28
| | |
* | | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2014-07-1414-6/+96
|\| | | | | | | | | | | merge/2.11.x-to-2.12.x-20140714
| * | Merge pull request #3867 from lrytz/t8708Lukas Rytz2014-07-094-0/+19
| |\ \ | | |/ | |/| SI-8708 Fix pickling of LOCAL_CHILD child of sealed classes
| | * SI-8708 Fix pickling of LOCAL_CHILD child of sealed classesLukas Rytz2014-07-074-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a sealed class or trait has local children, they are not pickled in as part of the children of the symbol (introduced in 12a2b3b to fix Aladdin bug 1055). Instead the compiler adds a single child class named LOCAL_CHILD. The parents of its ClassInfoType were wrong: the first parent should be a class. For sealed traits, we were using the trait itself. Also, the LOCAL_CHILD dummy class was entered as a member of its enclosing class, which is wrong: it represents a local (non-member) class, and it's a synthetic dummy anyway.
| * | Use countElementsAsString for summarized warnings.Adriaan Moors2014-07-042-2/+2
| | |
| * | Move reporting logic into Reporting traitAdriaan Moors2014-07-046-14/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move code from Global/SymbolTable to separate Reporting traits to start carving out an interface in scala.reflect.internal.Reporting, with internals in scala.tools.nsc. Reporting is mixed into the cake. It contains a nested class PerRunReporting. Should do the same for debugging/logging. The idea is that CompilationUnit and Global forward all reporting to Reporter. The Reporting trait contains these forwarders, and PerRunReporting, which accumulates warning state during a run. In the process, I slightly changed the behavior of `globalError` in reflect.internal.SymbolTable: it used to abort, weirdly. I assume that was dummy behavior to avoid introducing an abstract method. It's immediately overridden in Global, and I couldn't find any other subclasses, so I don't think the behavior in SymbolTable was ever observed. Provide necessary hooks for scala.reflect.macros.Parsers#parse. See scala/reflect/macros/contexts/Parsers.scala's parse method, which overrides the reporter to detect when parsing goes wrong. This should be refactored, but that goes beyond the scope of this PR. Don't pop empty macro context stack. (Ran into this while reworking -Xfatal-warnings logic.) Fix -Xfatal-warnings behavior (and check files): it wasn't meant to influence warning reporting, except for emitting one final error; if necessary to fail the compile (when warnings but no errors were reported). Warnings should stay warnings. This was refactored in fbbbb22946, but we soon seem to have relapsed. An hour of gitfu did not lead to where it went wrong. Must've been a merge.
| * | Unclutter Reporter. Move truncation to ReplReporter.Adriaan Moors2014-07-044-4/+8
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor to reduce the Reporter interface. Working towards minimal interfaces in scala.reflect.internal that can be consumed by sbt/IDE/.... The scala.tools.nsc package is entirely private to the compiler (in principle). A `Reporter` should only be used to inform (info/warning/error). No state. Ideally, we'd move to having only one reporter, whose lifetime is adjusted appropriately (from per-run in general to per-context for type checking, so errors can be buffered -- "silenced" -- during nested type checking calls). Start the clean up by moving truncation to the REPL, since it's not relevant for regular reporting. Perversely, we were checking truncation all the time, even though it's only on during a repl run. (Truncation is now always turned off in the repl under -verbose.) Untangle error resetting on symbols from error reporting (reportAdditionalErrors). This fixes a nice&subtle bug that caused feature warnings to be suppressed under `-Xfatal-warnings`: ``` def reportCompileErrors() { if (!reporter.hasErrors && reporter.hasWarnings && settings.fatalWarnings) globalError("No warnings can be incurred under -Xfatal-warnings.") if (reporter.hasErrors) { ... } else { // will erroneously not get here if // `reporter.hasWarnings && settings.fatalWarnings` // since the `globalError` call above means `reporter.hasErrors`... allConditionalWarnings foreach (_.summarize()) ... } } ``` The second `if`'s condition depends on the `globalError` call in the first `if`...
| * Merge pull request #3828 from retronym/ticket/8675Adriaan Moors2014-07-034-0/+63
| |\ | | | | | | SI-8675 Avoid unreported error after second try using implicit view
| | * SI-8675 Add another test case for swallowed type errorsJason Zaugg2014-06-262-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | As reported on scala-internals. After tightening up the treatment of undetermined type parameters in SI-7944, the enclosed test case no longer typechecks. And since the regression fixed in the previous commit, the error was swallowed by the typechecker only to be burped up by a crash in the backend.
| | * SI-8675 Avoid unreported error after second try using implicit viewJason Zaugg2014-06-252-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is specific to situations in which we first typecheck an application `qual.m(arg)` against the method `m` directly provided by `qual`, and then fall back to `implicitView(qual).m(arg)`. Regressed in SI-3971 / 7fa77af, in which error reports were moved to the innermost `Apply`, and the check for `errorInResult` was accordingly changed to recurse through `Apply` trees. Before that change, we did not fall back to using a view. After the change, we do try a view. We retypecheck the arguments under the `retyping` mode (see `tryTypedArgs`), but this doesn't seem to be enough to avoid leaking the error typed nested trees from the first try. Here's an example from the enclosed test case: a.update(0, x[A]({new isString(true)})) `-- error typed refArrayOps(a).update(0, x[A]({new isString(true)})) ` `-- error type persists `-- this tree is retypecked by tryTypedArgs This commit changes `onError` to only proceed with the second try if the retyped argument trees are error free.
* | | Merge remote-tracking branch 'origin/2.11.x' into merge/2.11.x-2.12.x-20140627Jason Zaugg2014-06-276-1/+97
|\| |
| * | Merge pull request #3832 from jrudolph/w/fix-tailrecJason Zaugg2014-06-272-0/+51
| |\ \ | | | | | | | | SI-8657 don't miss tailrec defs in more positions
| | * | SI-8657 don't miss tailrec defs in more positionsJohannes Rudolph2014-06-252-0/+51
| | |/ | | | | | | | | | | | | | | | | | | 1) First operand of boolean expression using `&&` or `||`. Second operands of those boolean exprs were already treated specially here but handling for first operands was missing. 2) Condition of `If`. Also added a test for guards.
| * | Merge pull request #3749 from huitseeker/issue/DeprecWarningJason Zaugg2014-06-271-1/+1
| |\ \ | | |/ | |/| SI-8185 Correct grammar for single-warning compilation run
| | * SI-8185 Correct grammar for single-warning compilation runFrançois Garillot2014-05-141-1/+1
| | |
| * | SI-8631 Treat `A with Sealed` as enumerable for pattern matchingJason Zaugg2014-06-103-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | Enumerate the subtypes of sealed parent types of refinement types, and filter those that conform to the refinement type. Such types can crop up easily when LUB-bing case classes which add `Product with Serializable` to the mix.
* | | Merge remote-tracking branch 'origin/2.11.x' into merge/2.11.x-to-2.12.xJason Zaugg2014-06-103-1/+9
|\| |
| * | Support Java 8 in the checkfile for neg/t6289Jason Zaugg2014-06-041-1/+1
| | |
| * | SI-8630 lineToString no longer long by one at eofSom Snytt2014-05-272-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One more EOL crasher, or lack-of-EOL crasher, when the text is at EOF. It was not caught by the last round of excellent and thorough tests because ``` // If non-whitespace tokens run all the way up to EOF, // positions go wrong because the correct end of the last // token cannot be used as an index into the char array. // The least painful way to address this was to add a // newline to the array. ```
* | | Merge branch '2.11.x' into merge-211Lukas Rytz2014-06-025-0/+17
|\| |
| * | Eliminate some N^2 performance in type checkingJason Zaugg2014-05-265-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Where N is the number of members of the enclosing package. Double definition errors for top level classes/objects are issued elsewhere, as demonstrated by the enclosed test. So we can omit the call to `checkNoDoubleDefs` in this content. We can't omit the call to `addSynthetics` for package class owners (case- and value-class synthetic companions are added here), but we can make the process cheaper by moving the expensive-but-usually-true call to `shouldAdd`. Here's an example of the improvement. % rm -rf /tmp/pkg; (for i in {1..50}; do for j in {1..100}; do echo "package pkg { class A_${i}_${j}___(val a: Int, val b: Int) }"; done; done) > sandbox/A1.scala && time scalac-hash v2.11.0 -Ybackend:GenASM -J-Xmx1G -J-XX:MaxPermSize=400M -d /tmp sandbox/A1.scala; real 0m49.762s user 1m12.376s sys 0m2.371s % rm -rf /tmp/pkg; (for i in {1..50}; do for j in {1..100}; do echo "package pkg { class A_${i}_${j}___(val a: Int, val b: Int) }"; done; done) > sandbox/A1.scala && time qbin/scalac -Ybackend:GenASM -J-Xmx1G -J-XX:MaxPermSize=400M -d /tmp sandbox/A1.scala; real 0m35.662s user 0m58.275s sys 0m2.355s We've still got another source of pathological performance in creating nested scopes that I'll fix in the next commit.
* | | Merge branch '2.11.x' into 2.12.xLukas Rytz2014-05-221-7/+1
|\| |
| * | SI-8574 Copy @SerialVersionUID, etc, to specialized subclassesJason Zaugg2014-05-161-7/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | The test case demonstrates that this is important for serialization and for strictfp. (Although the latter is still pretty broken, see SI-7954.) Now that the synthetic subclass of `Tuple2[Int, Int]` also has the `@deprecatedInheritance` annotation, I had to change the spot that issues this warning to be silent after the typer phase. Otherwise, we get two warnings in `run/t3888.scala`. This also remedies double warnings that were incurred in `neg/t6162-inheritance`.
* / Deprecation of @BeanInfoLukas Rytz2014-05-133-0/+9
|/
* Merge pull request #3719 from retronym/ticket/8546Jason Zaugg2014-05-092-3/+1
|\ | | | | SI-8546 Pattern matcher analysis foiled by over-widening
| * SI-8546 Pattern matcher analysis foiled by over-wideningJason Zaugg2014-05-072-3/+1
| | | | | | | | | | | | | | | | | | In the enclosed test, the prefix checkable type `ModuleTypeRef(F2.this, C)` was being inadvertently widened to `ModuleTypeRef(F2[?], C)`. This started after some misguided future-proofing in SI-6771 / 3009916. This commit changes the `dealiasWiden` to a `delias`.
* | Merge pull request #3711 from retronym/ticket/8549-2Jason Zaugg2014-05-082-0/+17
|\ \ | | | | | | SI-8549 Serialization: fix regression with @SerialVersionUID / start enforcing backwards compatibility
| * | SI-6988 Test case for non-literal / non-constant SerialVersionUIDJason Zaugg2014-05-052-0/+17
| |/ | | | | | | | | | | | | The `neg` test was already working since `SerialVersionUID` was changed to a `ClassFileAnnotation`; the `run` test only started working since the recently preceding commit that made a compensatory test in the backend.
* / SI-8325 Accept infix star type outside patternsSom Snytt2014-05-056-0/+51
|/ | | | | | | | | | | | | | | This is a follow-up to SI-5702 which enabled use of `*` in infix notation in patterns. Most of the work is in distinguishing infix from a sequence pattern. Also, do not take backticked star as the repeated parameter marker in postfix position. That is, `Int``*``` is not `Int*` -- I hope double-tick renders as tick. There is not a special use case except that backticks mean "I am an identifier, as is, and not a keyword."
* Merge pull request #3670 from retronym/ticket/8463Jason Zaugg2014-04-212-0/+48
|\ | | | | SI-8463 Avoid unpositioned errors from search for views
| * SI-8463 Avoid unpositioned errors from search for viewsJason Zaugg2014-04-022-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ideally, I'd like to fix this using `saveErrors = false` here to firewall the enclosing context from the ambiguiouty error encountered during implicit search. I originally proposed that patch as a fix for SI-8419 in https://github.com/scala/scala/pull/3460 but withdrew from that approach as I uncovered a deeper bug that meant that we actually shouldn't have even been looking for views in that case. But, this runs into SI-8230 and these failures: test/partest --update-check \ /Users/jason/code/scala/test/files/pos/t2504.scala \ /Users/jason/code/scala/test/files/pos/t4457_1.scala \ /Users/jason/code/scala/test/files/neg/t4457_2.scala Turns out that typechecking the ostensible straight forward application, `Array("abc")`, hinges on us leaking an ambiguity error from `viewExists` to find a path through overload resolution! This commit takes a tiny step forward by using `context.tree` rather than `EmptyTree` as the argument to `inferImplicit`. This avoids unpositioned type errors.
* | Merge pull request #3645 from retronym/ticket/8430Jason Zaugg2014-04-213-0/+60
|\ \ | | | | | | SI-8430 Less non-determinism in patmat exhautiveness warnings