summaryrefslogtreecommitdiff
path: root/test/files/scalacheck
Commit message (Collapse)AuthorAgeFilesLines
* establishes scala.reflect.api#internalEugene Burmako2014-02-147-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Reflection API exhibits a tension inherent to experimental things: on the one hand we want it to grow into a beautiful and robust API, but on the other hand we have to deal with immaturity of underlying mechanisms by providing not very pretty solutions to enable important use cases. In Scala 2.10, which was our first stab at reflection API, we didn't have a systematic approach to dealing with this tension, sometimes exposing too much of internals (e.g. Symbol.deSkolemize) and sometimes exposing too little (e.g. there's still no facility to change owners, to do typing transformations, etc). This resulted in certain confusion with some internal APIs living among public ones, scaring the newcomers, and some internal APIs only available via casting, which requires intimate knowledge of the compiler and breaks compatibility guarantees. This led to creation of the `internal` API module for the reflection API, which provides advanced APIs necessary for macros that push boundaries of the state of the art, clearly demarcating them from the more or less straightforward rest and providing compatibility guarantees on par with the rest of the reflection API. This commit does break source compatibility with reflection API in 2.10, but the next commit is going to introduce a strategy of dealing with that.
* Merge pull request #3437 from Ichoran/issue/6736Adriaan Moors2014-02-121-1/+2
|\ | | | | SI-6736 Range.contains is wrong
| * Reasonable Range operations consistently work when overfull.Rex Kerr2014-02-091-1/+2
| | | | | | | | | | | | Operations are reasonable when they don't require indexing or conversion into a collection. These include head, tail, init, last, drop, take, dropWhile, takeWhile, dropRight, takeRight, span. Tests added also to verify the new behavior.
* | Tweak parser entry point for pqDenys Shabalin2014-02-112-1/+10
|/ | | | | | Previously pq used pattern1 which required parens to be used in alternative pattern. This commit tweaks it to allow pq"a | b" syntax. Also adds some tests for alternative syntax.
* Add support for a more straightforward alternative to import selectorsDenys Shabalin2014-02-073-14/+82
|
* Represent tq"" as SyntacticEmptyTypeTree rather than TypeTree()Denys Shabalin2014-02-073-2/+15
| | | | | | | | | | | | Such representation codifies the fact that type tree that doesn't have embedded syntactic equivalent must have been inferred or otherwise provided by the compiler rather than specified by the end user. Additionally it also ensures that we can still match trees without explicit types (e.g. vals without type) after typechecking. Otherwise the same quote couldn't be used in situations like: val q"val x = 42" = typecheck(q"val x = 42")
* Merge pull request #3475 from densh/topic/holemap-orderingEugene Burmako2014-02-061-0/+5
|\ | | | | Fix inconsistent binding in patterns with 10+ holes
| * Fix inconsistent binding in patterns with 10+ holesDenys Shabalin2014-02-061-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously a map that was storing bindings of fresh hole variables with their contents (tree & cardinality) used to be a SortedMap which had issues with inconsistent key ordering: "$fresh$prefix$1" < "$fresh$prefix$2" ... "$fresh$prefix$8" < "$fresh$prefix$9" "$fresh$prefix$9" > "$fresh$prefix$10" This issue is solved by using a LinkedHashMap instead (keys are inserted in the proper order.)
* | SI-8173 add support for patterns like init :+ last to quasiquotesDenys Shabalin2014-02-027-47/+111
|/ | | | | | | | | | | | Adds support for patterns like: val q"{ ..$init; $last }" = q"{ a; b; c }" // init == List(q"a", q"b") // last == q"c" Which under the hood get compiled as `:+` patterns: SyntacticBlock(init :+ last)
* Merge pull request #3374 from densh/si/6844-8076Jason Zaugg2014-01-292-2/+44
|\ | | | | SI-6844 SI-8076 improve handling of function parameters in quasiquotes
| * SI-8076 improve support for implicit argument listDenys Shabalin2014-01-162-2/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for construction and deconstruction of implicit argument list which was originally suggested by @cvogt. 1. Splicing vale into implicit argument list automatically adds implicit flag to them: val x = q"val x: Int" q"def foo(implicit $x)" // <=> q"def foo(implicit x: Int)" 2. One might extract implicit argument list separately from other argument lists: val q”def foo(...$argss)(implicit ..$impl)" = q"def foo(implicit x: Int) // argss is Nil, impl contains valdef for x But this doesn't require you to always extract it separatly: val q”def foo(...$argss)" = q"def foo(implicit x: Int) // argss contains valdef for x
* | Merge pull request #3402 from densh/si/7275Eugene Burmako2014-01-292-16/+64
|\ \ | | | | | | SI-7275 allow flattening of blocks with ..$
| * | Addresses feedback from JasonDenys Shabalin2014-01-271-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Adds tests for new synthetic unit stripping. 2. Marks implementation-specific parts of Holes as private. 3. Trims description of iterated method a bit. 4. Provides a bit more clear wrapper for q interpolator. 5. Refactors SyntacticBlock, adds documentation. 6. Makes q"{ ..$Nil }" return q"" to be consist with extractor.
| * | SI-7275 allow flattening of blocks with ..$Denys Shabalin2014-01-232-15/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit extends current splicing rules to allow flattening of trees into other trees. Without such support it is impossible to correctly create vals with patterns and use it in other location as they could expand into multiple-statement blocks: scala> q"val (a, b) = (1, 2)" res0: reflect.runtime.universe.Tree = { <synthetic> <artifact> private[this] val x$1 = scala.Tuple2(1, 2): @scala.unchecked match { case scala.Tuple2((a @ _), (b @ _)) => scala.Tuple2(a, b) }; val a = x$1._1; val b = x$1._2; () } scala> q"..$res0; println(a + b)" res1: reflect.runtime.universe.Tree = { <synthetic> <artifact> private[this] val x$1 = scala.Tuple2(1, 2): @scala.unchecked match { case scala.Tuple2((a @ _), (b @ _)) => scala.Tuple2(a, b) }; val a = x$1._1; val b = x$1._2; println(a.$plus(b)) }
* | | SI-8171 make tq"" an alias for empty type treeDenys Shabalin2014-01-241-1/+7
|/ /
* | Merge pull request #3373 from densh/topic/std-liftable-refinementAdriaan Moors2014-01-171-1/+49
|\ \ | | | | | | A few minor changes to standard liftable instances and liftable support
| * | Test edge cases of literal liftingDen Shabalin2014-01-161-0/+11
| | | | | | | | | | | | | | | | | | | | | Previously in some corner situation proper Liftable instance might not have been resolved. In particular q"${true}" and q"${""}" used to fail.
| * | Lift Some, None, Nil, Left, Right not just supertypesDenys Shabalin2014-01-161-1/+38
| |/ | | | | | | | | | | | | | | | | Previously leaf concrete types were not lifted which could have caused weird problems when types is too precise: val s1 = Some(2) q"$s1" // used to fail
* / SI-8148 fix anonymous functions with placeholdersDenys Shabalin2014-01-161-0/+5
|/ | | | | | | | | | | Quasiquotes used to fail to generate proper fresh identifiers for anonymous functions like: q"_ + _" Due to improper initialization of FreshNameCreator in quasiquote parser which was erroneously not preserved throughout parsing of the code snippet but re-created on every invocation.
* Merge pull request #3124 from DarkDimius/fix-7443Adriaan Moors2014-01-091-0/+41
|\ | | | | Fix SI-7443 Range.sum ignoring Numeric argument and always assuming default 'plus' implementation
| * SI-7443 Use typeclass instance for {Range,NumericRange}.sumDmitry Petrashko2013-12-291-0/+41
| | | | | | | | | | | | | | | | Previously both Range and NumeriRange used formula for sum of elements of arithmetic series and thus always assumed that provided Numeric is regular one. Bug is now fixed by conservatively checking if Numeric is one of default ones and the formula still holds.
* | ExistentialTypeTree.whereClauses are now MemberDefsEugene Burmako2014-01-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | Today’s flight back to Lausanne wasn’t as productive as the recent flight to Minsk (https://github.com/scala/scala/pull/3305), but I noticed one minor thingie: ExistentialTypeTree had an imprecise type specified for its whereClauses. This is now fixed. I didn’t increment PickleFormat.*Version numbers, because this change introduces only a miniscule incompatibility with what would have been a meaningless and most likely crash-inducing pickle anyway.
* | Merge pull request #3245 from densh/si/8047Jason Zaugg2014-01-031-0/+0
|\ \ | | | | | | SI-8047 change fresh name encoding in quasiquotes to avoid symbol owner corruption
| * | Use t- prefix instead of si- prefix for test filesDen Shabalin2013-12-161-0/+0
| | |
* | | Merge pull request #3254 from xeno-by/topic/typeCheckJason Zaugg2014-01-031-1/+1
|\ \ \ | |_|/ |/| | typeCheck => typecheck
| * | typeCheck => typecheckEugene Burmako2013-12-101-1/+1
| |/ | | | | | | | | This method has always been slightly bothering me, so I was really glad when Denys asked me to rename it. Let’s see how it pans out.
* | Test possible quasiquote runtime failuresDen Shabalin2013-12-112-0/+76
| |
* | Test tuple lifting and unliftingDen Shabalin2013-12-102-0/+73
| |
* | SI-7789 make quasiquotes deconstruct UnApply treesDen Shabalin2013-12-101-0/+25
| |
* | Introduce support for Unliftable for QuasiquotesDen Shabalin2013-12-102-0/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Unliftable is a type class similar to existing Liftable that lets users to extract custom data types out of trees with the help of straightforward type ascription syntax: val q“foo.bar(${baz: Baz})” = ... This will use Unliftable[Baz] to extract custom data type Baz out of a tree nested inside of the another tree. A simpler example would be extracting of constant values: val q”${x: Int} + ${y: Int}” = q”1 + 2”
* | Refactor Holes and Reifiers slices of Quasiquotes cakeDen Shabalin2013-12-103-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit performs a number of preliminary refactoring needed to implement unliftable: 1. Replace previous inheritance-heavy implementation of Holes with similar but much simpler one. Holes are now split into two different categories: ApplyHole and UnapplyHole which correspondingly represent information about holes in construction and deconstruction quasiquotes. 2. Make Placeholders extract holes rather than their field values. This is required to be able to get additional mode-specific information from holes (e.g. only ApplyHoles have types). 3. Bring ApplyReifier & UnapplyReifier even closer to the future where there is just a single base Reifier with mode parameter. Along the way a few bugs were fixed: 1. SI-7980 SI-7996 fail with nice error on bottom types splices 2. Use asSeenFrom instead of typeArguments in parseCardinality. This fixes a crash if T <:< Iterable[Tree] but does not itself have any type arguments. 3. Fix spurious error message on splicing of Lists through Liftable[List[T]]
* | Move Liftable into the Universe cake; add additional standard LiftablesDen Shabalin2013-12-102-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | Previously we believed that having Liftable outside of the Universe will bring some advantages but it turned out this wasn’t worth it. Due to infectious nature of path dependent types inside of the universe one had to cast a lot. A nice example of what I’m talking about is a change in trait ArbitraryTreesAndNames. Additionally a number of standard Liftables is added for types that are available through Predef and/or default scala._ import: Array, Vector, List, Map, Set, Option, Either, TupleN.
* | SI-7979 Fix quasiquotes crash on mismatch between fields and constructorDen Shabalin2013-12-101-0/+16
| |
* | SI-6842 Make splicing less sensitive to precise types of treesDen Shabalin2013-12-103-14/+26
| | | | | | | | | | | | | | | | | | Previously trees that represent parameters, case clauses and type variables had strictly defined ValDef, TypeDef and CaseDef types which caused problems in compositionality. Now this checks are moved to runtime so it's possible to pass a tree that is CaseDef but has Tree type.
* | SI-8009 Ensure that Idents preserve isBackquoted propertyDen Shabalin2013-12-101-0/+4
| |
* | SI-8016 Ensure that q”..$xs” is equivalent to q”{..$xs}”Den Shabalin2013-12-101-0/+6
| |
* | SI-8008 Make q”f(..$xs)” only match trees with Apply nodeDen Shabalin2013-12-101-2/+4
|/ | | | | | | | | | Previously it also matched other nodes but returned Nil as value of xs. This behavior was added for sake of consistentcy with q”f[..$ts]”. On the other hand q”f[..$Nil]” == q”f” but q”f(..$Nil)” == q”f()” not q”f”. Due to this deconstruction/construction symmetry was broken. On the other hand applications also have q"f(...$xss)" option which is infact similar to q"f[..$ts]". Splicing Nil into it also results in q"f".
* Merge pull request #3138 from densh/pr/fresh-name-extractorJason Zaugg2013-11-221-7/+6
|\ | | | | Refactor out fresh name prefix extraction logic
| * refactor out fresh name prefix extraction logicDen Shabalin2013-11-171-7/+6
| | | | | | | | | | | | | | | | | | | | | | 1. refactor out FreshNameExtractor out of Quasiquotes cake into SymbolTable (can’t put it outside due to the fact that names are path-dependent) 2. add optional parameter to the fresh name creator to cover additional qq$ prefix needed for quasiquotes 3. add unit tests
* | Merge pull request #3152 from paulp/pr/deprecationsJason Zaugg2013-11-221-1/+1
|\ \ | | | | | | Removing deprecated code.
| * | Removing deprecated code.Paul Phillips2013-11-181-1/+1
| |/ | | | | | | | | Code which has been deprecated since 2.10.0 and which allowed for straightforward removal.
* / Prepare upgrade to scalacheck 1.11.Adriaan Moors2013-11-207-31/+9
|/ | | | | | | | | | | | | | | | Our scalacheck tests now compile against 1.10.1 and 1.11.0. They pass on 1.10.1, but fail on 1.11.0. Once (that)[https://github.com/rickynils/scalacheck/issues/79]'s fixed, and 1.11.1 released, we should be able to upgrade to it by simply changing scalacheck.version.number in versions.properties. The changes are mostly removing dead code (e.g., consolereporter business). Of interest: the type ascription for `oneOf`. I haven't quite investigated, but something seems to have changed between 1.10.1 and 1.11.0 that caused a different overload to be picked without the type ascription. Probably not a scalac bug, just a scalacheck api change.
* test legacy .filter support in for loop resugaringDen Shabalin2013-11-121-0/+11
|
* add support for for loops and for enumerators to quasiquotesDen Shabalin2013-11-122-3/+47
| | | | | | 1. q"for (..$enums) $body", q"for (..$enums) yield $body" 2. fq"..." quote to construct/deconstruct enumerators
* implement inverse transformation to mkForDen Shabalin2013-11-122-0/+39
| | | | | | | | | | | This effectively reconstructs a sequence of enumerators and body from the tree produced by mkFor. This lets to define bi-directional SyntacticFor and SyntacticForYield constructors/extractors to work with for loops. Correctness of the transformation is tested by a scalacheck test that generates a sequence of random enumerators, sugars them into maps/flatMaps/foreach/withFilter calls and reconstructs them back.
* make fresh names compare similar in quasiquotesDen Shabalin2013-11-122-4/+26
| | | | | | Otherwise it's annoying that trees that look the same are not equal due to some fresh name hidden underneath. Due to this one test needs to be changed to use plain equalsStructure.
* simplify imports in quasiquotes scalacheck testsDen Shabalin2013-11-1212-91/+25
|
* add some post-typecheck tests for quasiquotesDen Shabalin2013-11-123-2/+45
| | | | | | Typecheck trees with toolbox and check that they are still matched by corresponding quasiquote. Fix tuples and function types matchers to account for different shape of trees after typing.
* deduplicate tuple tree creation codeDen Shabalin2013-11-122-5/+5
| | | | | | Previously tuple tree generation code has been implemented in three place: tree builder, tree gen, build utils. Now it's just defined once in tree gen.
* SI-7938 - parallel collections should use default ExecutionContextAleksandar Prokopec2013-10-299-64/+114
| | | | | | | | | | Parallel collections now use `scala.concurrent.ExecutionContext` by default. The `ExecutionContextTaskSupport` is optimized to use the `ForkJoinPool` underlying the `ExecutionContext` if possible. Otherwise, a fallback `TaskSupport` that creates a reduction tree and execute an operation through `Future`s is used.