summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | | | SI-7740 Trim stack trace before printing in REPLChristoffer Sawicki2013-08-191-0/+33
| | | | | | | |
* | | | | | | | Merge branch 'master' into patmatPaul Phillips2013-08-2015-10/+55
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/compiler/scala/tools/nsc/Global.scala src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
| * | | | | | | Merge pull request #2853 from retronym/ticket/6797Adriaan Moors2013-08-191-0/+4
| |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | SI-6797 Test case for already-fixed DelayedInit bug
| | * | | | | | | SI-6797 Test case for already-fixed DelayedInit bugJason Zaugg2013-08-191-0/+4
| | | |/ / / / / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Progressed in b4fbb7be0e2, "translation for DelayedInit keeps more code in original class."
| * | | | | | | Merge pull request #2840 from retronym/ticket/7756-2.11Adriaan Moors2013-08-195-0/+30
| |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | SI-7756 Uncripple refchecks in case bodies
| | * | | | | | | SI-7756 Uncripple refchecks in case bodiesJason Zaugg2013-08-165-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 65340ed4ad2e, parts of RefChecks were disabled when we traversed into the results of the new pattern matcher. Similar logic existed for the old pattern matcher, but in that case the Match / CaseDef nodes still existed in the tree. The new approach was too broad: important checks no longer scrutinized the body of cases. This commit turns the checks back on when it finds the remnants of a case body, which appears as an application to a label def.
| * | | | | | | | Merge pull request #2854 from som-snytt/issue/7729-slashAdriaan Moors2013-08-195-10/+10
| |\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | SI-7729 Fix broken windows build
| | * | | | | | | | SI-7729 Fix broken windows buildSom Snytt2013-08-195-10/+10
| | | |/ / / / / / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixing #ifdiff uncovered a latent bug in partest when it detects paths to normalize in test log output. It would not normalize file separators for test names with non-word characters. This commit normalizes the test name to the ticket number as a workaround until the next partest version is picked up. It also fixes partest in this repo in case we've not yet switched over to the new repo. A separate PR will be submitted to the new repo as necessary.
| * | | | | | | | Merge pull request #2839 from densh/topic/si-7757Adriaan Moors2013-08-194-0/+11
| |\ \ \ \ \ \ \ \ | | |/ / / / / / / | |/| | | | | | | SI-7757 disallow constructor annotations on traits
| | * | | | | | | SI-7757 add additional test case with annotation on the next lineDen Shabalin2013-08-165-4/+10
| | | | | | | | |
| | * | | | | | | SI-7757 disallow constructor annotations on traitsDen Shabalin2013-08-162-0/+5
| | |/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously it was possible to define constructor annotations on traits with really weird side-effects (parser lost the body of the trait). Now constructor annotations on traits will cause appropriate syntax errors.
* | | | | | | | Refinement of name-based unapplySeq.Paul Phillips2013-08-182-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Can't finnesse the drop method. Call it blindly for now, even though in the long run you won't have to write drop.
* | | | | | | | An unapplySeq-via-String test.Paul Phillips2013-08-182-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a lot of details yet to be ironed out when it comes to sequences, but at least here's a little evidence that the basic mechanisms work.
* | | | | | | | Refined name-based patmat methods.Paul Phillips2013-08-181-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fleshes out some of the slightly unfinished corners of the adventure, especially for unapplySeq. There's still an unhealthy amount of duplication and a paucity of specification, but I think it's in eminently good shape for a milestone.
* | | | | | | | Revert "Minor improvement in pattern typer inference."Paul Phillips2013-08-181-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 35122d6cda84bb2df69ca51c6b1b80e61693bf6f. It also includes a test case embodying the reversion reason: the test case no longer compiled. Parties interested in the surrounding details may want to look at SI-7472.
* | | | | | | | SI-5903 extractor macrosEugene Burmako2013-08-1831-0/+322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Establishes a pattern that can be used to implement extractor macros that give the programmer control over signatures of unapplications at compile-time. === The pattern === In a nutshell, given an unapply method (for simplicity, in this example the scrutinee is of a concrete type, but it's also possible to have the extractor be polymorphic, as demonstrated in the tests): ``` def unapply(x: SomeType) = ??? ``` One can write a macro that generates extraction signatures for unapply on per-call basis, using the target of the calls (c.prefix) and the type of the scrutinee (that comes with x), and then communicate these signatures to the typechecker. For example, here's how one can define a macro that simply passes the scrutinee back to the pattern match (for information on how to express signatures that involve multiple extractees, visit https://github.com/scala/scala/pull/2848). ``` def unapply(x: SomeType) = macro impl def impl(c: Context)(x: c.Tree) = { q""" new { class Match(x: SomeType) { def isEmpty = false def get = x } def unapply(x: SomeType) = new Match(x) }.unapply($x) """ } ``` In addition to the matcher, which implements domain-specific matching logic, there's quite a bit of boilerplate here, but every part of it looks necessary to arrange a non-frustrating dialogue with the typer. Maybe something better can be done in this department, but I can't see how, without introducing modifications to the typechecker. Even though the pattern uses structural types, somehow no reflective calls are being generated (as verified by -Xlog-reflective-calls and then by manual examination of the produced code). That's a mystery to me, but that's also good news, since that means that extractor macros aren't going to induce performance penalties. Almost. Unfortunately, I couldn't turn matchers into value classes because one can't declare value classes local. Nevertheless, I'm leaving a canary in place (neg/t5903e) that will let us know once this restriction is lifted. === Use cases === In particular, the pattern can be used to implement shapeshifting pattern matchers for string interpolators without resorting to dirty tricks. For example, quasiquote unapplications can be unhardcoded now: ``` def doTypedApply(tree: Tree, fun0: Tree, args: List[Tree], ...) = { ... fun.tpe match { case ExtractorType(unapply) if mode.inPatternMode => // this hardcode in Typers.scala is no longer necessary if (unapply == QuasiquoteClass_api_unapply) macroExpandUnapply(...) else doTypedUnapply(tree, fun0, fun, args, mode, pt) } } ``` Rough implementation strategy here would involve writing an extractor macro that destructures c.prefix, analyzes parts of StringContext and then generates an appropriate matcher as outlined above. === Implementation details === No modifications to core logic of typer or patmat are necessary, as we're just piggybacking on https://github.com/scala/scala/pull/2848. The only minor change I introduced is a guard against misbehaving extractor macros that don't conform to the pattern (e.g. expand into blocks or whatever else). Without the guard we'd crash with an NPE, with the guard we get a sane compilation error.
* | | | | | | | New tests for name-based pattern matcher.Paul Phillips2013-08-1727-0/+1011
| | | | | | | |
* | | | | | | | Pattern matcher: extractors become name-based.Paul Phillips2013-08-178-26/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An extractor is no longer required to return Option[T], and can instead return anything which directly contains methods with these signatures: def isEmpty: Boolean def get: T If the type of get contains methods with the names of product selectors (_1, _2, etc.) then the type and arity of the extraction is inferred from the type of get. If it does not contain _1, then it is a single value extractor analogous like Option[T]. This has significant benefits and opens new territory: - an AnyVal based Option-like class can be used which leverages null as None, and no allocations are necessary - for primitive types the benefit is squared (see below) - the performance difference between case classes and extractors should now be largely eliminated - this in turn allows us to recapture great swaths of memory which are currently squandered (e.g. every TypeRef has fields for pre and args, even though these are more than half the time NoPrefix and Nil) Here is a primitive example: final class OptInt(val x: Int) extends AnyVal { def get: Int = x def isEmpty = x == Int.MinValue // or whatever is appropriate } // This boxes TWICE: Int => Integer => Some(Integer) def unapply(x: Int): Option[Int] // This boxes NONCE def unapply(x: Int): OptInt As a multi-value example, after I contribute some methods to TypeRef: def isEmpty = false def get = this def _1 = pre def _2 = sym def _3 = args Then it's extractor becomes def unapply(x: TypeRef) = x Which, it need hardly be said, involves no allocations.
* | | | | | | | SI-4425 do some validity checking on unapplies.Paul Phillips2013-08-173-1/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Filter out unapplies which can't be called (such as those with a second non-implicit parameter list) and report the error in a meaningful fashion.
* | | | | | | | Simplified the MaybeBoundTyped extractor a bit.Paul Phillips2013-08-172-0/+9
|/ / / / / / /
* | | | | | | Merge pull request #2843 from xeno-by/topic/kill-introduce-top-levelAdriaan Moors2013-08-1618-180/+0
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | kills introduceTopLevel
| * | | | | | | kills introduceTopLevelEugene Burmako2013-08-1618-180/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As we've figured out from the practice, introduceTopLevel is seductively useful but unfortunately not robust, potentially bringing compilation order problems. Therefore, as discussed, I'm removing it from the public macro API. Alternatives are either: 1) delving into internals, or 2) using macro paradise and experimenting with macro annotations: http://docs.scala-lang.org/overviews/macros/annotations.html.
* | | | | | | | Merge pull request #2841 from gourlaysama/wip/t6507Adriaan Moors2013-08-162-0/+40
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | SI-6507 do not call .toString on REPL results when :silent is on.
| * | | | | | | | SI-6507 do not call .toString on REPL results when :silent is on.Antoine Gourlay2013-08-162-0/+40
| | |/ / / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Member handlers used to always call .toString on REPL results, even when :silent was on, which could force evaluation or cause unwanted side effects. This forwards the current value of `printResults` to the member handlers (through Request) for them to decide what to do when the results must not be printed. 2 handlers now do not return any extraction code when silent: - ValHandler, so that it doesn't call toString on the val - Assign, so that it doesn't call toString on the right-hand side of the assignement.
* | | | | | | | Merge pull request #2837 from soc/SI-7630Adriaan Moors2013-08-161-4/+9
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | SI-7630 [Avian] Skip test run/repl-javap-outdir-funs on Avian
| * | | | | | | | SI-7630 [Avian] Skip test run/repl-javap-outdir-funs on AvianSimon Ochsenreither2013-08-161-4/+9
| | |/ / / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test fails, because the REPL command reports that no anonfuns were found. I have spent a considerable amount of time to figure out what's the issue here with no success. Skip it for now, so that we don't lose sight of the big picture.
* | | | | | | | Merge pull request #2836 from soc/SI-7564-reduxAdriaan Moors2013-08-161-18/+18
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | SI-7564 [Avian] Whitespace fixes to run/tailcalls.check
| * | | | | | | | SI-7564 [Avian] Whitespace fixes to run/tailcalls.checkSimon Ochsenreither2013-08-161-18/+18
| | |/ / / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looks like the differences in the whitespace caused the test to fail on Avian.
* | | | | | | | Merge pull request #2830 from densh/topic/stats-parsing-2Adriaan Moors2013-08-1613-10/+208
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | updated SI-7331, SI-6843, SI-7731, parser entry point refactoring, assertThrows utility function
| * | | | | | | | addresses feedback regarding new junit testsDen Shabalin2013-08-154-21/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. don't recreate symbol table manually and just let JUnit do it automatically behind the scenes 2. minor changes to assertThrow's description 3. add one more test case to check that exception's subclasses are catched too 4. refine rethrow test to ensure that the exception wasn't swallowed
| * | | | | | | | SI-6843 well-positioned syntax errors for quasiquotesDen Shabalin2013-08-143-6/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is achieved in a following way: 1. Similarly to toolbox quasiquotes can go away with wrapping for parsing purpose after introduction of `parseStats` and `parseRule` entry points. 2. In case of syntax error quasiquote computes equivalent corresponding position in the source code with the help of `corrrespondingPosition` mapper which relies on position data collected into `posMap` during code generation.
| * | | | | | | | SI-7331 remove all the wrapping code from toolboxDen Shabalin2013-08-146-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change toolbox parsing to use `parseStats` parser entry point instead of current code-wrappign technique that makes positions much less useful to end users. There is also no need to create a compiler `Run` for parsing.
| * | | | | | | | SI-7731 make CannotHaveAttrs more consistentDen Shabalin2013-08-141-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously setPos, pos_=, setType, tpe_= all behaved inconsistently between each other even though they all represent similar attributes that cannot be changed on CannotHaveAttrs trees. In order to simplify handling of such trees in compiler code each of these fields now supports assignment to its current default value: NoType for tpe and NoPosition for pos. Such assignments don't mutate underlying trees.
| * | | | | | | | add assertThrows testing utility functionDen Shabalin2013-08-142-0/+44
| |/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | This is much easier to use than built-in JUnit method-level checks.
* | | | | | | | Merge pull request #2823 from som-snytt/issue/7715Adriaan Moors2013-08-164-0/+58
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | SI-7715 String inpatternation s"$_" for s"${_}"
| * | | | | | | | SI-7715 String inpatternation s"$_" for s"${_}"Som Snytt2013-08-124-0/+58
| | |_|/ / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a pattern, ``` scala> implicit class RX(val sc: StringContext) { | def rx = sc.parts.mkString("(.+)").r } defined class RX scala> "2 by 4" match { case rx"$a by $_" => a } res0: String = 2 scala> val rx"$_ by $b" = "2 by 4" b: String = 4 ```
* | | | | | | | Merge pull request #2821 from xeno-by/topic/fundep-materializationAdriaan Moors2013-08-167-2/+108
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | SI-7470 implements fundep materialization
| * | | | | | | | SI-7470 implements fundep materializationEugene Burmako2013-08-137-2/+108
| |/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fix provides implicit macros with an ability to affect type inference in a more or less sane manner. That's crucial for materialization of multi-parametric type class instances (e.g. Iso's from shapeless). Details of the technique can be found in comments.
* | | | | | | | Merge pull request #2798 from som-snytt/issue/7544-errmsgAdriaan Moors2013-08-166-11/+7
|\ \ \ \ \ \ \ \ | |_|_|/ / / / / |/| | | | | | | SI-7544 Interpolation message for %% literal
| * | | | | | | StringContext#checkLengths reports bad args countSom Snytt2013-08-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since interpolator args are of type Any, it's easy to write s(args) instead of s(args: _*). I wonder if Xlint would have warned me about that.
| * | | | | | | In tests, interpolation is no longer -Xperimental.Som Snytt2013-08-064-4/+0
| | | | | | | |
| * | | | | | | SI-7544 Interpolation message for %% literalSom Snytt2013-08-061-5/+5
| |/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new error text: "conversions must follow a splice; use %% for literal %, %n for newline". The error is emitted when % is not at the start of a part; only the non-conversions %% and %n are allowed. It would be nice if it were convenient to parse the part to see what the user may have intended, but c'est l'erreur.
* | | | | | | Merge pull request #2831 from soc/SI-7624Grzegorz Kossakowski2013-08-1520-52/+52
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | SI-7624 Fix -feature and some -Xlint warnings
| * | | | | | | Whitespace fixes in scala/tools/scalapSimon Ochsenreither2013-08-1520-52/+52
| | |/ / / / / | |/| | | | |
* | | | | | | Merge pull request #2792 from ScrapCodes/partest-script-fixedAdriaan Moors2013-08-151-1/+4
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Bug fix ! , if $color_opts is unset partest script does not work.
| * | | | | | | Added a warning from scala runner script.Prashant Sharma2013-08-131-0/+3
| | | | | | | |
| * | | | | | | Bug fix ! , if $color_opts is unset partest script does not work.Prashant Sharma2013-08-011-1/+1
| | | | | | | |
* | | | | | | | Merge pull request #2819 from som-snytt/issue/regextract-charAdriaan Moors2013-08-141-0/+58
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | SI-7737 Regex matches Char
| * | | | | | | | SI-7737 Regex matches CharSom Snytt2013-08-101-0/+58
| | |_|/ / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enables Char extraction by regex. ``` val r = """(\p{Lower})""".r "cat"(0) match { case r(x) => true } val nc = """\p{Lower}""".r "cat"(0) match { case nc() => true } ```
* | | | | | | | Merge pull request #2791 from som-snytt/issue/7265-2.11Adriaan Moors2013-08-142-27/+13
|\ \ \ \ \ \ \ \ | |_|_|/ / / / / |/| | | | | | | SI-7265 javaSpecVersion, adjust isJava... tests for 2.11