summaryrefslogtreecommitdiff
path: root/test/files/neg
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #2884 from retronym/ticket/3832Jason Zaugg2013-09-155-0/+38
|\ | | | | SI-1909 SI-3832 SI-7007 SI-7223 Improved handling of larval objects
| * SI-7007 Test case shows we disallow premature `this` accessJason Zaugg2013-09-112-0/+21
| | | | | | | | | | | | | | Rather than the old behaviour, which compiled successfully but led us into the jaws of a LinkageError. Related to SI-6666.
| * SI-3832 Don't lift methods in aux constructor trailing stats as STATICJason Zaugg2013-09-113-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SI-1909 modified LambdaLift to lift in auxiliary constructors methods as STATIC so they could be called before the self-constructor was called. That allowed for: class Foo (x: Int) { def this() = this( { def bar() = 5 bar }) } However, if the method is in a statement that trails the self constructor call, this is unnecessary and in fact incorrect as it robs the lifted method of `this`. This commit uses the machinery established in SI-6666 to limit the STATIC-ness of lifted methods to those used in arguments for self-constructor calls. This is used exclusively; the `isAuxillaryConstructor` check wasn't the right way to solve this, as was seen by the regression it caused in SI-3832. A new test case shows that we can statically lift methods in super-constructor calls, rather than just self-constructor calls. We also have to avoid statically lifting objects in these positions. For now, I just emit a dev warning that a VerifyError is in your future. With some more thought we could escalate that to a implementation restriction and emit an error.
* | Reducing variation of tree creation methods.Paul Phillips2013-09-133-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TreeDSL has no future - it was always a temporary measure waiting for something like quasiquotes to come along. In this commit I cull as much of it as I can, especially the delicate matter of creating new DefDefs and ValDefs, which I completely turn over to the old style creators. I unified all the symbol-based DefDef and ValDef creators under a single method, since it was yet another place where ctrl-C and ctrl-V were being punched with glee. Was beaten to the punch on adding copyTypeDef to fill out the *Def creators. Eliminated as many redundant positioning calls as I could find. If you are creating a DefTree tree based on a symbol, it will always have an atPos(sym.pos) { ... } wrapped around it. You don't need another one. All of this is motivated by positions work: positions are assigned in so many places and in such an ad hoc fashion that it is impossible to bring consistency to that without first bringing some consistency to tree creation.
* | Merge pull request #2859 from som-snytt/issue/7622-phaserGrzegorz Kossakowski2013-09-1224-9/+193
|\ \ | | | | | | SI-7622 Clean Up Phase Assembly
| * | SI-7622 Scaladoc and error message polishSom Snytt2013-08-212-2/+2
| | | | | | | | | | | | Restores the verbiage "run right after".
| * | SI-7622 Clean Up Phase AssemblySom Snytt2013-08-2122-0/+186
| | | | | | | | | | | | | | | | | | | | | | | | Let optimiser components and continuations plugin opt-out when required flags are not set. Wasted time on a whitespace error in check file, so let --debug dump the processed check file and its diff.
| * | SI-7622 Plugins can be not enabledSom Snytt2013-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Plugins can interrogate options and declare themselves not enabled. The plugin itself can return false from its init if the options do not compute. A plugin phase component can declare itself not enabled, same as an internal phase. No one exploits this facility at this commit.
| * | SI-7622 Phases are enabled or notSom Snytt2013-08-214-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the calculation of the "phase chain" a bit. In particular, initial and terminal phases are not special except that they must be head and last. When done, filter for enabled phases. At this commit, nobody claims to be disabled. Additional sanity support of phases settings.
| * | SI-7622 Phase assembly is testableSom Snytt2013-08-212-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | Fixing hash on nodes makes fault detection deterministic, which aids testing. Error messages are shortened and .dot files are dumped automatically on faults to guard against future flakiness.
* | | SI-7834 Type equivalence of C.this and C.super.Paul Phillips2013-09-112-0/+117
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | Foo.this.x and Foo.super.x were roughly unrelated in the eyes of isSubType. I implemented conformance as described in the comment: This is looking for situations such as B.this.x.type <:< B.super.x.type. If it's a ThisType on the lhs and a SuperType on the right, and they originate in the same class, and the 'x' in the ThisType has in its override chain the 'x' in the SuperType, then the types conform. I think this is overly conservative but it's way ahead of where it was.
* | Merge pull request #2930 from retronym/topic/patmat-inference-prepJason Zaugg2013-09-1140-149/+13
|\ \ | | | | | | Topic/patmat inference prep
| * | Limit bad advice given for erroneous pattern.Paul Phillips2013-08-293-0/+13
| | | | | | | | | | | | | | | Don't suggest "_: <none>" as an alternative when the pattern type doesn't conform to the expected type.
| * | Removing orphan check/flag files.Paul Phillips2013-08-2937-149/+0
| | |
* | | Merge pull request #2907 from paulp/pr/typetree-original-rangeposJason Zaugg2013-09-092-11/+2
|\ \ \ | | | | | | | | Eliminate TypeTrees with null original.
| * | | Eliminate TypeTrees with null original.Paul Phillips2013-09-042-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a retry of #2801 after figuring out the range position error. Should there be anyone out there who compiles with -Xdev, know that this commit eliminates the 1406 errors one presently incurs compiling src/library. A val declared in source code receives only one tree from the parser, but two are needed - one for the field and one for the getter. I discovered long ago that if the val had an existential type, this was creating issues with incompatible existentials between the field and the getter. However the remedy for that did not take into account the whole of the wide range of super subtle issues which accompany tree duplication. In particular, the duplicated tree must be given not only a fresh TypeTree(), but that TypeTree cannot share the same original without running afoul of range position invariants. That's because typedTypeTree resurrects the original tree with whatever position it has - so the "original" needs to be a duplicate of the original with a focused position. Should the call to TypeTree.duplicate also duplicate the original? I think so, but I bequeath this question to others. This commit also eliminated some duplicate error messages, because duplicate suppression depends on the errors having the same position. See c478eb770d, 7a6fa80937 for previous related work.
* | | | Merge pull request #2855 from adriaanm/modularize-xml-parsersv2.11.0-M5Grzegorz Kossakowski2013-09-0612-177/+18
|\ \ \ \ | |/ / / |/| | | Modularize: xml & parser-combinators
| * | | Prepare removal of scala-xml, scala-parser-combinatorsAdriaan Moors2013-08-2712-177/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Every test deleted here has found its way to the respective repositories of scala-xml and scala-parser-combinators, where they will continue to be tested with partest. The modified tests became independent of these modules, as they should've been from the start.
* | | | Merge pull request #2861 from densh/topic/deprecate-early-type-defsGrzegorz Kossakowski2013-08-304-5/+7
|\ \ \ \ | | | | | | | | | | Deprecate early type defs
| * | | | deprecate early type defsDen Shabalin2013-08-284-5/+7
| |/ / / | | | | | | | | | | | | | | | | | | | | This feature is neither properly supported by Scala compiler nor a part of the language spec and therefore should be removed. Due to source compatiblity with 2.10 we need to deprecate it first.
* | | | Merge pull request #2886 from gkossakowski/merge-2.10.xJason Zaugg2013-08-3012-0/+145
|\ \ \ \ | |_|/ / |/| | | Merge 2.10.x into master
| * | | Merge remote-tracking branch 'scala/2.10.x'Grzegorz Kossakowski2013-08-2912-0/+145
| |\ \ \ | | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the merge, the test/run/t7733 started to fail on Jenkins. I tried to reproduce it locally but I couldn't so I think it's system dependent failure. Per @retronym's suggestion I moved it to pending to not block the whole merge. Conflicts: bincompat-backward.whitelist.conf bincompat-forward.whitelist.conf src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala src/compiler/scala/tools/nsc/typechecker/Macros.scala src/compiler/scala/tools/nsc/typechecker/Namers.scala src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala src/compiler/scala/tools/nsc/typechecker/RefChecks.scala src/compiler/scala/tools/nsc/util/MsilClassPath.scala src/compiler/scala/tools/reflect/ToolBoxFactory.scala src/reflect/scala/reflect/internal/ClassfileConstants.scala src/reflect/scala/reflect/internal/Importers.scala src/reflect/scala/reflect/internal/Trees.scala src/reflect/scala/reflect/runtime/JavaMirrors.scala test/files/run/macro-duplicate/Impls_Macros_1.scala test/files/run/t6392b.check test/files/run/t7331c.check
| | * | Merge remote-tracking branch 'origin/2.10.2' into merge/2.10.2-to-2.10.xJason Zaugg2013-08-214-13/+16
| | |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Better late than never. Conflicts: src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
| | * | | SI-7752 Don't disambiguate type parameters of overloaded altsJason Zaugg2013-08-152-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are passed through from `InferencerContextErrors#applyErrorMsg` to `withDisambiguation` as the `locals` parameter, which is promptly ignored. This looks to be an unintended change in 39938bcc299. Without this patch, the enclosed test case enters a pathalogical disambiguation session, that not only flirts with unpleasant big-O complexities, but also flails about appending "(in method foo)" only to find that *all* occurences of the same-named type parameter come from some method named "foo". [snipping error message 40 seconds in the making] method foo), O(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo), P(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo), Q(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo), R(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo), S(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo), T, U(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo)(in method foo), V) cannot be applied to (Int) foo((1))
| | * | | Merge pull request #2828 from adriaanm/rebase-2771James Iry2013-08-131-0/+7
| | |\ \ \ | | | | | | | | | | | | [Rebase #2771] SI-7694 @uncheckedBounds, an opt-out from type bounds checking
| | | * | | SI-7694 Add @uncheckedBounds to the libraryJason Zaugg2013-08-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Followup to the previous commit that added the compiler support for opting out of bounds checking. With both pieces, we can test that the temporaries introduced by the named/default arguments transform don't trigger bounds violations.
| | * | | | SI-7020 Determinism for pattern matcher warningsJason Zaugg2013-08-133-0/+48
| | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use LinkedHashSet for the DPLL algorithm for determistic counter example generation. Before, the test compiled with: [info] v2.10.2 => /Users/jason/usr/scala-v2.10.2-0-g60d462e test/files/neg/t7020.scala:3: warning: match may not be exhaustive. It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List(_, _) List(5) match { ^ test/files/neg/t7020.scala:10: warning: match may not be exhaustive. It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List(_, _) List(5) match { ^ test/files/neg/t7020.scala:17: warning: match may not be exhaustive. It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 6, 7)), _), List(1, _), List(2, _), List(4, _), List(5, _), List(6, _), List(7, _), List(??, _) List(5) match { ^ test/files/neg/t7020.scala:24: warning: match may not be exhaustive. It would fail on the following input: List(_, _) List(5) match { ^
| | * | | [nomaster] macro errors now always have positionsEugene Burmako2013-08-106-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back then when I implemented macros for inclusion in trunk (Spring 2012), partest didn't support the _1, _2, ... convention for neg tests, so I had to use toolboxes to test macro-generated exceptions. Unfortunately toolboxes aren't very good with positions (mostly because their inputs are almost always constructed without corresponding sources) so I didn't notice that errors signalizing about macro-generated exceptions actually don't carry positions with them because of a typo. This patch fixes the oversight, but it doesn't need to be ported to master, because over there everything's already fixed by one of the backports from macro paradise.
* | | | | Merge pull request #2847 from retronym/ticket/7501Grzegorz Kossakowski2013-08-283-0/+24
|\ \ \ \ \ | |/ / / / |/| | | | SI-7501 Pickler: owner adjustment for param syms in annotation args
| * | | | SI-7501 Pickler: owner adjustment for param syms in annotation argsJason Zaugg2013-08-173-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pickling of trees within annotation arguments led to an unfortunate situation: the MethodType of a symbol contained a value parameter symbol that was pickled as though it were owned by the enclosing class (the root symbol of the pickle.) Under separate compilation, this would appear as a member of that class. Anyone using `@deprecatedName('oldName)` was exposed to this problem, as the argument expands to `Symbol.apply("oldName")`. This commit extends some similar treatment of local type parameters to also consider value parameters.
* | | | | Merge pull request #2852 from retronym/ticket/1980-warningAdriaan Moors2013-08-213-0/+22
|\ \ \ \ \ | | | | | | | | | | | | SI-1980 A lint warning for by-name parameters in right assoc methods
| * | | | | SI-1980 A lint warning for by-name parameters in right assoc methodsJason Zaugg2013-08-193-0/+22
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The desugaring of right associative calls happens in the parser. This eagerly evaluates the arguments (to preserve left-to-right evaluation order the arguments are evaluated before the qualifier). This is pretty surprising if the method being called has a by-name parameter in the first parameter section. This commit adds a warning under -Xlint when defining such a method. The relevent spec snippets: > SLS 4.6.1 says that call-by-name argument "is not evaluated at the point of function application, but instead is evaluated at each use within the function". > > But 6.12.3 offers: > "If op is right- associative, the same operation is interpreted as { val x=e1; e2.op(x ) }, where x is a fresh name."
* | | | | Merge pull request #2810 from xeno-by/topic/compile-time-onlyAdriaan Moors2013-08-214-0/+128
|\ \ \ \ \ | |_|_|_|/ |/| | | | @compileTimeOnly: moved to scala-library.jar, got some fixes
| * | | | @compileTimeOnly now works for symbols from the empty packageEugene Burmako2013-08-151-1/+22
| | | | | | | | | | | | | | | | | | | | Looks like we've got the entire language covered now.
| * | | | @compileTimeOnly now works for annotationsEugene Burmako2013-08-151-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | http://docs.scala-lang.org/overviews/macros/annotations.html say sincere "thank you!".
| * | | | marks Expr.splice and Expr.value with @compileTimeOnlyEugene Burmako2013-08-152-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Now that @compileTimeOnly is part of the standard library, why don't we use it within the standard library.
| * | | | moves compileTimeOnly to scala-libraryEugene Burmako2013-08-142-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the notion that's come to be universally useful, so I suggest we promote it to be universally accessible. Note that the attached test incorrectly fails to report errors for definitions coming from the empty package and for annotations. These are bugs, and they are fixed in subsequent commits of this pull request.
* | | | | Merge branch 'master' into patmatPaul Phillips2013-08-2014-10/+51
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/compiler/scala/tools/nsc/Global.scala src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
| * \ \ \ \ 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.
* | | | | 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.
* | | | | SI-5903 extractor macrosEugene Burmako2013-08-1815-0/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-175-0/+226
| | | | |
* | | | | Pattern matcher: extractors become name-based.Paul Phillips2013-08-175-19/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.