summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #3074 from Jentsch/filterInDocsJason Zaugg2013-10-241-33/+38
|\ | | | | Prevent useless filter operation in docs
| * Prevent useless filter operation in docsJentsch2013-10-231-33/+38
| |
* | Merge pull request #3027 from etaty/patch-2Jason Zaugg2013-10-231-1/+1
|\ \ | | | | | | IterableLike grouped : fix documentation
| * | IterableLike.grouped() : More explicit documentationValerian2013-10-141-1/+1
| | |
| * | IterableLike grouped : fix documentationValerian2013-10-101-1/+1
| | | | | | | | | | | | scala> Seq(1,2,3).grouped(2).toList res1: List[Seq[Int]] = List(List(1, 2), List(3))
* | | Merge pull request #3059 from densh/pull/si-6840Jason Zaugg2013-10-232-2/+2
|\ \ \ | | | | | | | | SI-6840 fixes weird typing of quasiquote arguments
| * | | SI-6840 fixes weird typing of quasiquote argumentsDen Shabalin2013-10-192-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously quasiquote arguments were type checked against Any which caused weird inference that made splicing of complex expressions unusable: val l1 = List(q"foo") val l2 = List(q"bar") q"f(..${l1 ++ l2})" // argument type checked as Any instead of List[Tree] This is fixed by forcing compiler to type check against type variable which itself isn't used in any other way.
* | | | Merge pull request #3070 from xeno-by/topic/macro-impl-wrong-shapeJason Zaugg2013-10-232-8/+20
|\ \ \ \ | | | | | | | | | | better macro impl shape errors
| * | | | better macro impl shape errorsEugene Burmako2013-10-232-8/+20
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the advent of quasiquotes, we allowed both arguments and return types of macro impls to be c.Tree's (as opposed to traditional c.Expr[T]'s). This warrants an update of macro def <-> macro impl signature mismatch errors that include a printout of suggested macro impl signatures. Now along with a signature that contains exprs, we suggest another signature that has all exprs replaced by trees
* | | | Merge pull request #3068 from retronym/ticket/7020-3-1Jason Zaugg2013-10-232-8/+11
|\ \ \ \ | | | | | | | | | | Deterministic warnings for pattern matcher, take 2
| * | | | SI-7020 Deterministic warnings for pattern matcher, take 2Jason Zaugg2013-10-222-8/+11
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous swing at determinism, ebb01e05cbe4, made decent contact but apparently didn't hit it out of the park. The test wavered every hundred or so runs, as witnessed occasionally in nightly builds or pull request validation. I setup a test to run neg/7020.scala a few hundred times, and could trigger the failure reliably. I then swept through the pattern matcher in search of HashMap and HashSet creation, and changed them all to the Linked variety. The results of that are published in retronym#ticket/7020-3 [1]. This commit represents the careful whittling down of that patch to the minimal change required to exhibit determinism. [1] https://github.com/retronym/scala/compare/ticket/7020-3
* | | | Merge pull request #3057 from xeno-by/topic/fancy-java-classesJason Zaugg2013-10-233-31/+29
|\ \ \ \ | | | | | | | | | | fixes handling of fancy nested classes in runtime reflection
| * | | | fixes handling of fancy nested classes in runtime reflectionEugene Burmako2013-10-193-31/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaces the `jclazz.isMemberClass` check for whether we have an inner/nested class with `jclazz.getEnclosingClass != null`, because there exist classes produced by javac (see the attached jar file and the test log) which have the following properties: * They are nested within a parent class * getEnclosingClass returns a non-null value * isMemberClass returns false Previously such classes were incorrectly treated as non-nested, were incorrectly put into an enclosing package rather than an enclosing class, and had their names trimmed in the process, leading to situations when a package has multiple declarations with the same name. This is now fixed. When changing the check, we need to be careful with interpretation of what Class.getEnclosingXXX methods return. If getEnclosingClass produces a non-null result, this doesn't mean that the class is inner or nested, because getEnclosingClass is also not null for local classes (the ones with getEnclosingMethod != null || getEnclosingConstructor != null). This is expressed in the order of pattern match clauses in `sOwner`. Now when the bug is fixed, I also revert b18a2f8798b2, restoring a very important integrity check in runtime reflection, which I had to disable a couple hours ago to fix a master breakage. More details at scala-internals: https://groups.google.com/forum/#!topic/scala-internals/hcnUFk75MgQ
* | | | | Merge pull request #3047 from xeno-by/topic/deprecateEugene Burmako2013-10-225-1/+37
|\ \ \ \ \ | |_|/ / / |/| | | | deprecates raw tree manipulation facilities in macros.Context
| * | | | deprecates raw tree manipulation facilities in macros.ContextEugene Burmako2013-10-185-1/+37
| | |_|/ | |/| |
* | | | Merge pull request #3007 from densh/pull/fresh-name-and-package-supportEugene Burmako2013-10-1925-283/+463
|\ \ \ \ | |_|/ / |/| | | Add support for packages into quasiquotes and toolbox, improve handling of fresh names, unhardcode quasiquote expansion logic
| * | | annotate return type of the implicit fresh name creatorDen Shabalin2013-10-181-2/+2
| | | |
| * | | use more descriptive types instead of ints in the parser and scannerDen Shabalin2013-10-182-82/+85
| | | |
| * | | use concurrent hash map with atomic integersDen Shabalin2013-10-182-11/+7
| | | | | | | | | | | | | | | | | | | | This should ensure that concurrent access to the fresh name creator is properly synchronized.
| * | | re-wire fresh name creator to currentUnit.fresh at compile-timeDen Shabalin2013-10-184-1/+5
| | | |
| * | | use NameTransformer.encode for fresh name prefix sanitizationDen Shabalin2013-10-181-2/+2
| | | |
| * | | eliminate isCaseDefEnd override by moving the logic into stock parserDen Shabalin2013-10-182-3/+1
| | | |
| * | | decrease duplication of fresh* function definitionsDen Shabalin2013-10-189-67/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit extracts out freshTermName and freshTypeName to the top-level with implicit fresh name creator argument. This will let to refactor out more methods out of tree builder into treegen that are dependent on fresh name generator. We also save quite a bit of boilerplate by not having to redefined fresh functions all over the place.
| * | | move fresh name creator into scala.reflect.internal.utilDen Shabalin2013-10-185-56/+38
| | | |
| * | | rename selfdef into selfTypeDen Shabalin2013-10-182-27/+27
| | | | | | | | | | | | | | | | For sake of consistency with noSelfType.
| * | | fix minor regression in quasiquote reificationDen Shabalin2013-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | emptyValDef should always be reified as emptyValDef. After the the introduction of SyntacticValDef this ceased to be true.
| * | | better name for isCaseDefStartDen Shabalin2013-10-182-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | As it was pointed out by @paulp current isCaseDefStart method's name doesn't really correspond to one of it's primary usages: checking if the block within case has reached it's end.
| * | | make q"f(..$xs)" deconstruction symmetrical to q"f[..$xs]"Den Shabalin2013-10-184-0/+20
| | | |
| * | | advanced fresh name reificationDen Shabalin2013-10-186-6/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During parsing some names are generated artificially using freshTermName & freshTypeName (e.g. `x$1`). Such names should be reified in a different way because they are assumed to be always fresh and non-overlapping with the environment. So `x$1` should reify down to equivalent of `freshTermName("x$")` rather than `TermName("x$1")`. But this is not enough. One name can be used more than once in a tree. E.g. `q"_ + 1"` desugars into `q"x$1 => x$1 + 1"`. So we need to ensure that every place where `x$1` is used gets the same fresh name. Hence the need for `withFreshTermName` that lets q"_ + 1" quasiquote desugare into equivalent of `withFreshTermName("x$") { freshx => q"$freshx => $freshx + 1" }`. For pattern quasiquotes it's a bit different. Due to the fact that end-result must be a pattern we need to represent fresh names as patterns too. A natural way to express that something is fresh is to represent it as a free variable (e.g. any name will do in that place). But due to possible use of the same name in multiple places we need to make sure that all such places have the same values by adding a sequence of guards to the pattern. Previously such names were reified naively and it could have caused name collision problems and inability to properly much on trees that contain such names.
| * | | use regular macro expansion logic for unapply quasiquotesDen Shabalin2013-10-146-11/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously due to limited support for expansion in apply position quasiquotes had to use a compiler hook for deconstruction. Now with recent changes in pattern matcher it's possible to remove that special case.
| * | | minor changes due to typosDen Shabalin2013-10-141-2/+2
| | | |
| * | | SI-6841 SI-6657 add support for packages into quasiquotes and toolboxDen Shabalin2013-10-1410-25/+94
| | | | | | | | | | | | | | | | | | | | | | | | In order to implement this a new parser entry point `parseStatsOrPackages` that augments current parseStats with ability to parse "package name { ... }" syntax.
| * | | refactor out range position utility constructorsDen Shabalin2013-10-141-2/+4
| | | | | | | | | | | | | | | | | | | | This will help to re-use same logic for creating range positions even if atPos isn't used to assign position to the tree.
| * | | refactor out common logic between various statSeq-s in parserDen Shabalin2013-10-141-35/+31
| | | | | | | | | | | | | | | | | | | | Partial functions are left outside of the call to statSeq to allow re-use and overriding capabilities for quasiquotes.
* | | | hotfix for runtime reflectionEugene Burmako2013-10-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent runtime reflection sync pull request, which among other things, introduced more restricted package completion rules, led to a nightmarish regression on java7, which prevented the entire scalac from starting up. This commit temporarily disables the introduced assert in order to hotfix runtime reflection. In the hours to come I'll be looking into the root of the problem, preparing a pull request that reinstates the assert, which indicates a bug in our code that's been there since 2.10.0-M3, and fixes the said bug. Details: https://groups.google.com/forum/#!topic/scala-internals/hcnUFk75MgQ
* | | | Merge pull request #3029 from xeno-by/ticket/6240Eugene Burmako2013-10-1825-319/+1085
|\ \ \ \ | | | | | | | | | | reflection sync
| * | | | pull request feedbackEugene Burmako2013-10-181-1/+2
| | | | | | | | | | | | | | | | | | | | https://github.com/scala/scala/pull/3029
| * | | | makes all locks and tlses private and lazyEugene Burmako2013-10-182-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We do need lazy to be robust, because initialization sequence might trigger synced operations in unexpected order, leading to NPE's. Even if this is optimizable by removing some of the lazies or by carefully reordering cake layers, there's no guarantee that all this effort won't break after another reflection refactoring.
| * | | | need to synchronize Symbols.recursionTableEugene Burmako2013-10-183-1/+9
| | | | | | | | | | | | | | | | | | | | Fixes this glaring omission of synchronization for a core part of Symbol.info.
| * | | | replaces locks over numbers with AtomicIntegersEugene Burmako2013-10-183-15/+10
| | | | | | | | | | | | | | | | | | | | This is another optimization we discussed with Roland.
| * | | | thread locals instead of locks for vars in Types.scalaEugene Burmako2013-10-189-106/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is one of the changes suggested by Roland in order to reduce contention caused by reflection GIL. Locks optimized away here are indirectly used for such fundamental operations as subtyping tests, so the optimization looks quite important.
| * | | | removes the assertion in missingHookEugene Burmako2013-10-181-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the current synchronization scheme multiple threads can enter the missingHook trying to materialize a package, which hasn't been created. That's fine, because makeScalaPackage, which creates and enters package symbols is synchronized and checks whether the creation is necessary before commencing. Therefore even if makeScalaPackage is called multiple times in rapid succession, the calls will be serialized and all calls except the first one won't do anything.
| * | | | synchronizes pendingVolatilesEugene Burmako2013-10-183-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Called from isVolatile, which is called from isStable, which is a part of the public reflection API.
| * | | | synchronizes toolboxesEugene Burmako2013-10-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | We don't guarantee thread-safety of the front end, but everything else looks good now.
| * | | | SI-7045 reflection now auto-initializes selfTypeEugene Burmako2013-10-181-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | selfType joins the happy family of flags, annotations and privateWithin, which automatically trigger initialization, when used within runtime reflection.
| * | | | optimizes Scala reflection GILEugene Burmako2013-10-184-65/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First of all, GIL should only apply to runtime reflection, because noone is going to run toolboxes in multiple threads: a) that's impossible, b/c the compiler isn't thread safe, b) ToolBox api prevents that. Secondly, the only things in symbols which require synchronization are: 1) info/validTo (completers aren't thread-safe), 2) rawInfo and its dependencies (it shares a mutable field with info) 3) non-trivial caches like in typeAsMemberOfLock If you think about it, other things like sourceModule or associatedFile don't need synchronization, because they are either set up when a symbol is created or cloned or when it's completed. The former is obviously safe, while the latter is safe as well, because before acquiring init-dependent state of symbols, the compiler calls `initialize`, which is synchronized. We can say that symbols can be in four possible states: 1) being created, 2) created, but not yet initialized, 3) initializing, 4) initialized. Of those only #3 is dangerous and needs protection, which is what this commit does.
| * | | | SI-6240 introduces GIL to Scala reflectionEugene Burmako2013-10-1810-111/+226
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On a serious note, I feel really uncomfortable about having to juggle this slew of locks. Despite that I can't immediately find a deadlock, I'm 100% sure there is one hiding in the shadows. Hence, I'm abandoning all runtime reflection locks in favor of a single per-universe one.
| * | | | eagerly initializes lazy vals and objects in runtime reflectionJason Zaugg2013-10-184-11/+497
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code to do so is curated with the help of a generator. Because this needs to inspect code post-typer, the code generator is run during partest as a code-validator. We could concievably do the same with a macro, but this approach might be a better starting point which macros continue to stabilize. Removes Definitions.AnyRefModule and an already deprecated alias, as these have been throwing exceptions for more than a year since 6bb5975289. They used to be used by AnyRef specialization.
| * | | | cleans up initialization of runtime reflectionEugene Burmako2013-10-188-34/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At first I just tried to remove syntheticCoreClasses from missingHook and put them into the initializer of freshly created mirrors in order to reduce the non-determinism in mutations of the global symbol table. And then it didn't work, crashing on me claiming that AnyRef is missing. Apparently we still need AnyRefClass in missingHook, just because it's impossible to initialize (i.e. unpickle) ScalaPackageClass without it. And then it still didn't work, whining about multiple overloaded defs of some synthetic symbols. That was really tricky, but I figured it out as well by initializing ScalaPackageClass first before forcing any synthetic symbols (see the details in comments). And then it worked, but stopped working half a year later when Jason and I came to revisit this old pull request. The final twist was pre-initializing ObjectClass, because it's a dependency of AnyRefClass, which is a critical dependency of ScalaPackageClass (full information can be found in comments).
| * | | | reflection no longer uses enteringPhase and friendsEugene Burmako2013-10-185-28/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mentioned methods mutate the global `atPhaseStack` variable, which can easily lead to imbalances and, ultimately, to the empty stack error. Luckily for us, there's only one dummy phase, SomePhase, which is used by runtime reflection, so there is absolutely zero need to invoke atPhase in non-compiler reflexive universes. The cleanest solution would be to override `atPhase` for runtime reflection, but it's @inline final, so I didn't want to pay performance penalties for something that's used three times in runtime reflection (during unpickling, in reflection-specific completers and in `Symbol.typeParams/unsafeTypeParams`). Therefore I added overrideable analogues of `atPhase` and `atPhaseNotLaterThan` which are called from the aforementioned code shared between the compiler and runtime reflection. I also had to duplicate the code of `Symbol.XXXtypeParams` (only in SynchronizedSymbols, not in normal Symbols) again due to those methods being very performance-sensitive.