summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/reflect
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | Merge pull request #3455 from densh/topic/patdefEugene Burmako2014-02-163-33/+61
| |\ \ \ | | | | | | | | | | Fix SI-8202 and improve support for splicing patterns into vals
| | * | | Improve support for patterns in valsDenys Shabalin2014-02-092-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commits adds construction-only support for splicing patterns into vals (a.k.a. PatDef). Due to non-locality of the desugaring it would have been quite expensive to support deconstruction as the only way to do it with current trees is to perform implodePatDefs transformation on every single tree.
| | * | | Move placeholder construction logic into PlaceholdersDenys Shabalin2014-02-092-22/+36
| | | | | | | | | | | | | | | | | | | | | | | | | Previously construction logic used to be in Parsers and deconstruction in Placeholders making it easy to forget one if you change the other.
| | * | | SI-8202 bug compatibility with SI-8211 for quasiquotesDenys Shabalin2014-02-091-0/+6
| | | | |
| * | | | Merge pull request #3511 from som-snytt/issue/interp-octalAdriaan Moors2014-02-151-1/+50
| |\ \ \ \ | | |_|/ / | |/| | | SI-8266 Deprecate octal escapes in f-interpolator
| | * | | SI-8266 Deprecate octal escapes in f-interpolatorSom Snytt2014-02-111-1/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also turns the f-interpolator into a migration assistant by suggesting alternatives for the standard escapes.
* | | | | renames some methods in ReificationSupportEugene Burmako2014-02-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per Denys's request, renames methods in ReificationSupport that are eponymous to methods in Universe, so that we don't get nasty name intersections. This change is not source/binary-compatible, because we don't make any promises about the contents of the build API. Feedback welcome.
* | | | | addresses pull request feedbackEugene Burmako2014-02-153-2/+7
| | | | |
* | | | | some renamingsEugene Burmako2014-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It’s almost 1am, so I’m only scratching the surface, mechanistically applying the renames that I’ve written down in my notebook: * typeSignature => info * declarations => decls * nme/tpnme => termNames/typeNames * paramss => paramLists * allOverriddenSymbols => overrides Some explanation is in order so that I don’t get crucified :) 1) No information loss happens when abbreviating `typeSignature` and `declarations`. We already have contractions in a number of our public APIs (e.g. `typeParams`), and I think it’s fine to shorten words as long as people can understand the shortened versions without a background in scalac. 2) I agree with Simon that `nme` and `tpnme` are cryptic. I think it would be thoughtful of us to provide newcomers with better names. To offset the increase in mouthfulness, I’ve moved `MethodSymbol.isConstructor` to `Symbol.isConstructor`, which covers the most popular use case for nme’s. 3) I also agree that putting `paramss` is a lot to ask of our users. The double-“s” convention is very neat, but let’s admit that it’s just weird for the newcomers. I think `paramLists` is a good compromise here. 4) `allOverriddenSymbols` is my personal complaint. I think it’s a mouthful and a shorter name would be a much better fit for the public API.
* | | | | adds internal.subpatternsEugene Burmako2014-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per Denys’s request, this commit exposes the hack that we use to obtain subpatterns of UnApply nodes. This is useful when writing quasiquoting macros that do pattern matching.
* | | | | establishes scala.reflect.api#internalEugene Burmako2014-02-144-11/+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.
* | | | | SI-6814 adds typechecker modes to c.typecheckEugene Burmako2014-02-142-10/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per multiple user requests, this commit introduces a shortcut to typecheck trees under multiple different modes: terms (EXPRmode, was exposed in Scala 2.10) and types (TYPEmode). Looking into the rest of a dozen of internal typechecker modes, to the best of my knowledge, I can’t find other modes that we could expose. FUNmode is useful, but very situational. PATTERNmode is useful, but also situational, because we don’t expand macros inside patterns except for whitebox extractor macros. The rest (e.g. POLYmode or TAPPmode) are too low-level.
* | | | | additional class tags for reflection APIEugene Burmako2014-02-141-0/+8
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduces a test that iterates all abstract types in reflection API and makes sure that every one of them has an associated class tag. After being introduced, the test has immediately failed exposing the lack of tags for TreeCopier, Mirror and RuntimeClass, which has been subsequently fixed in this commit.
* / / / Tweak parser entry point for pqDenys Shabalin2014-02-111-1/+1
|/ / / | | | | | | | | | | | | | | | 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.
* | | Merge pull request #3406 from xeno-by/ticket/7570Jason Zaugg2014-02-102-11/+45
|\ \ \ | | | | | | | | SI-7570 top-level codegen for toolboxes
| * | | addresses pull request feedbackEugene Burmako2014-02-061-2/+1
| | | |
| * | | SI-7570 top-level codegen for toolboxesEugene Burmako2014-01-242-11/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides a way to inject top-level classes, traits and modules into toolbox universes. Previously that was impossible, because compile and eval both wrap their arguments into an enclosing method of a synthetic module, which makes it impossible to later on refer to any definitions from the outside.
* | | | Merge pull request #3409 from xeno-by/ticket/6411Jason Zaugg2014-02-101-3/+4
|\ \ \ \ | |_|_|/ |/| | | SI-6411 SI-7328 value class fixes for runtime reflection
| * | | SI-6411 reflection is now aware of posterasureEugene Burmako2014-01-241-3/+4
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `transformedType` method, which is used to bring Scala types to Java world, was written in pre-valueclass times. Therefore, this method only called transforms from erasure, uncurry and refChecks. Now runtime reflection becomes aware of posterasure and as a consequence methods, which have value classes in their signatures, can be called without having to wrap them in catch-a-crash clause. Another facet to this fix was the realization that value classes need to be unwrapped, e.g. C(2) needs to be transformed to just 2, when they are used naked in method signatures (i.e. `c` in `def foo(c: C)` needs to be unwrapped, whereas `cs: List[C]`, `cs: C*` and even `cs: Array[C]` do not).
* | | Merge pull request #3485 from xeno-by/topic/reset-all-attrsJason Zaugg2014-02-092-16/+2
|\ \ \ | |_|/ |/| | kills resetAllAttrs
| * | renames resetLocalAttrs to resetAttrsEugene Burmako2014-02-071-2/+2
| | | | | | | | | | | | | | | Now when resetAllAttrs is gone, we can use a shorter name for the one and only resetLocalAttrs.
| * | further limits discoverability of resetAttrsEugene Burmako2014-02-072-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit removes resetAllAttrs from the public reflection API. This method was previously deprecated, but on a second thought that doesn't do it justice. People should be aware that resetAllAttrs is just wrong, and if they have code that uses it, this code should be rewritten immediately without beating around the bush with deprecations. There's a source-compatible way of achieving that (resetLocalAttrs), so that shouldn't bring much trouble. Secondly, resetAllAttrs in compiler internals becomes deprecated. In subsequent commits I'm going to rewrite the only two locations in the compiler that uses it, and then I think we can remove it from the compiler as well.
* | | Merge pull request #3420 from som-snytt/issue/8092-f-parsingEugene Burmako2014-02-093-174/+332
|\ \ \ | | | | | | | | SI-8092 More verify for f-interpolator
| * | | SI-8092 Review cleanup, no qqSom Snytt2014-02-081-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | No crazyquoting. Use global.abort on total fail. Remove unnecessary usage of varargs Apply, per review.
| * | | SI-8092 Refactor f-interpSom Snytt2014-02-043-299/+316
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A denshish refactor makes the FormatInterpolator a nice bundle that destructures its input and flattens out the classes to give the code some elbow room. Everything shifts left. The `checkType` method is refolded and renamed `pickAcceptable`. An additional test case captures the leading edge test, that a % should follow a hole, and which is the most basic requirement.
| * | | SI-8092 More verify for f-interpolatorSom Snytt2014-01-281-137/+262
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Attempt to verify the nooks and crannies of the format string. Allows all syntax in the javadoc, including arg indexes. If the specifier after an arg has an index that doesn't refer to the arg, a warning is issued and the missing `%s` is prepended (just as for a part with a leading `%n`). Other enhancements include detecting that a `Formattable` wasn't supplied to `%#s`. Error messages attempt to be pithy but descriptive.
* | | Add support for a more straightforward alternative to import selectorsDenys Shabalin2014-02-071-0/+2
| | |
* | | Represent tq"" as SyntacticEmptyTypeTree rather than TypeTree()Denys Shabalin2014-02-071-0/+2
| |/ |/| | | | | | | | | | | | | | | | | | | | | 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-062-20/+21
|\ \ | | | | | | Fix inconsistent binding in patterns with 10+ holes
| * | Fix inconsistent binding in patterns with 10+ holesDenys Shabalin2014-02-062-21/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-022-15/+27
|/ / | | | | | | | | | | | | | | | | | | | | | | 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-293-4/+28
|\ \ | | | | | | SI-6844 SI-8076 improve handling of function parameters in quasiquotes
| * | SI-8076 improve support for implicit argument listDenys Shabalin2014-01-161-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | SI-6844 restrict splicing in parameter positionDenys Shabalin2014-01-163-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously were a bit too permissive on how splicing in function parameter position worked. This made confusing things like possible: val x = TermName(“x”) q”def foo($x)” Now you can either splice trees in that position (ValDefs) or you have to provide type if you splice a name.
* | | Merge pull request #3402 from densh/si/7275Eugene Burmako2014-01-293-39/+84
|\ \ \ | | | | | | | | SI-7275 allow flattening of blocks with ..$
| * | | Addresses feedback from JasonDenys Shabalin2014-01-273-35/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | Reify all blocks as syntactic blocksDenys Shabalin2014-01-241-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous version of the pattern wasn't precise enough due to the fact that synthetic units are now erased by syntactic block and this could cause incorrect reification for cases like: val x = { val y = 1 } Here syntactic block would extract one element but we still need to reify it through syntactic block endpoint. So we can't filter based on the number of elements extracted but rather filter on type of a tree.
| * | | Address pull request feedbackDenys Shabalin2014-01-231-1/+1
| | | |
| * | | SI-7275 allow flattening of blocks with ..$Denys Shabalin2014-01-231-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)) }
| * | | Refactor reification of high-cardinality holesDenys Shabalin2014-01-231-16/+51
| | | | | | | | | | | | | | | | | | | | New approach makes iterated function much more clear through aggressive code reuse, recursion and large descriptive comment on top of it.
| * | | Tag synthetic unit with attachmentDenys Shabalin2014-01-231-2/+2
| | |/ | |/| | | | | | | | | | | | | | | | | | | This makes it easy to differentiate unit inserted by a compiler vs unit written by the user. Useful for quasiquotes and pretty printing. Additionally SyntacticBlock extractor is changed to treat EmptyTree as zero-element block.
* / | SI-8171 make tq"" an alias for empty type treeDenys Shabalin2014-01-241-1/+6
|/ /
* | Merge pull request #3392 from xeno-by/topic/untypecheckEugene Burmako2014-01-212-6/+11
|\ \ | | | | | | deprecates resetAllAttrs and resetLocalAttrs in favor of the new API
| * | deprecates resetAllAttrs and resetLocalAttrs in favor of the new APIEugene Burmako2014-01-212-6/+11
| |/ | | | | | | | | | | | | | | | | | | We now have c.untypecheck, which is supposed to be a counterpart of c.typecheck in the sense that it goes back from typed trees to untyped ones: http://stackoverflow.com/questions/20936509/scala-macros-what-is-the-difference-between-typed-aka-typechecked-an-untyped. Let’s hope that c.untypecheck will soon be able to solve our problems with partially/incorrectly attributed trees emitted by macros: https://groups.google.com/forum/#!topic/scala-internals/TtCTPlj_qcQ.
* | quasiquotes no longer evaluate debug logs when debug logging is offEugene Burmako2014-01-191-2/+2
| |
* | Merge pull request #3373 from densh/topic/std-liftable-refinementAdriaan Moors2014-01-171-8/+9
|\ \ | | | | | | A few minor changes to standard liftable instances and liftable support
| * | Give better names to UnliftHelper1 and UnliftHelper2Denys Shabalin2014-01-161-6/+8
| | | | | | | | | | | | | | | Previous ones were inscrutable but thankfully @xeno_by helped me out to find better alternatives.;
| * | Remove redundant asInstanceOf for liftableDen Shabalin2014-01-161-2/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous encoding of Liftables which had universe passed in as a parameter required a cast to solve path-dependant madness problems: trait OldLiftable[T] { def apply(u: Universe, v: T): u.Tree } In this case compiler wasn't smart enough to find out that liftFoo(universe, foo) returns the same type of tree we were working with (universe.Tree) and we had to cast to make it work: liftFoo(universe, foo).asInstanceOf[universe.Tree] Now this cast is redundant as universe is not a parameter of Liftable's apply.
* / SI-8148 fix anonymous functions with placeholdersDenys Shabalin2014-01-161-2/+2
|/ | | | | | | | | | | 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 #3245 from densh/si/8047Jason Zaugg2014-01-031-9/+20
|\ | | | | SI-8047 change fresh name encoding in quasiquotes to avoid symbol owner corruption