summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* The new reflectionEugene Burmako2012-06-08188-6401/+8999
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A must read: "SIP: Scala Reflection": https://docs.google.com/document/d/1Z1VhhNPplbUpaZPIYdc0_EUv5RiGQ2X4oqp0i-vz1qw/edit Highlights: * Architecture has undergone a dramatic rehash. * Universes and mirrors are now separate entities: universes host reflection artifacts (trees, symbols, types, etc), mirrors abstract loading of those artifacts (e.g. JavaMirror loads stuff using a classloader and annotation unpickler, while GlobalMirror uses internal compiler classreader to achieve the same goal). * No static reflection mirror is imposed on the user. One is free to choose between lightweight mirrors and full-blown classloader-based mirror (read below). * Public reflection API is split into scala.reflect.base and scala.reflect.api. The former represents a minimalistic snapshot that is exactly enough to build reified trees and types. To build, but not to analyze - everything smart (for example, getting a type signature) is implemented in scala.reflect.api. * Both reflection domains have their own universe: scala.reflect.basis and scala.reflect.runtime.universe. The former is super lightweight and doesn't involve any classloaders, while the latter represents a stripped down compiler. * Classloader problems from 2.10.0-M3 are solved. * Exprs and type tags are now bound to a mirror upon creation. * However there is an easy way to migrate exprs and type tags between mirrors and even between universes. * This means that no classloader is imposed on the user of type tags and exprs. If one doesn't like a classloader that's there (associated with tag's mirror), one can create a custom mirror and migrate the tag or the expr to it. * There is a shortcut that works in most cases. Requesting a type tag from a full-blown universe will create that tag in a mirror that corresponds to the callsite classloader aka `getClass.getClassLoader`. This imposes no obligations on the programmer, since Type construction is lazy, so one can always migrate a tag into a different mirror. Migration notes for 2.10.0-M3 users: * Incantations in Predef are gone, some of them have moved to scala.reflect. * Everything path-dependent requires implicit prefix (for example, to refer to a type tag, you need to explicitly specify the universe it belongs to, e.g. reflect.basis.TypeTag or reflect.runtime.universe.TypeTag). * ArrayTags have been removed, ConcreteTypeTag have been renamed to TypeTags, TypeTags have been renamed to AbsTypeTags. Look for the reasoning in the nearby children of this commit. Why not in this commit? Scroll this message to the very bottom to find out the reason. * Some of the functions have been renamed or moved around. The rule of thumb is to look for anything non-trivial in scala.reflect.api. Some of tree build utils have been moved to Universe.build. * staticModule and staticClass have been moved from universes to mirrors * ClassTag.erasure => ClassTag.runtimeClass * For the sake of purity, type tags no longer have erasures. Use multiple context bounds (e.g. def foo[T: ru.TypeTag : ClassTag](...) = ...) if you're interested in having both erasures and types for type parameters. * reify now rolls back macro applications. * Runtime evaluation is now explicit, requires import scala.tools.reflect.Eval and scala-compiler.jar on the classpath. * Macro context now has separate universe and mirror fields. * Most of the useful stuff is declared in c.universe, so be sure to change your "import c.universe._" to "import c.mirror._". * Due to the changes in expressions and type tags, their regular factories are now really difficult to use. We acknowledge that macro users need to frequently create exprs and tags, so we added old-style factories to context. Bottom line: almost always prepend Expr(...)/TypeTag(...) with "c.". * Expr.eval has been renamed to Expr.splice. * Expr.value no longer splices (it can still be used to express cross-stage path-dependent types as specified in SIP-16). * c.reifyTree now has a mirror parameter that lets one customize the initial mirror the resulting Expr will be bound to. If you provide EmptyTree, then the reifier will automatically pick a reasonable mirror (callsite classloader mirror for a full-blown universe and rootMirror for a basis universe). Bottom line: this parameter should be EmptyTree in 99% of cases. * c.reifyErasure => c.reifyRuntimeClass. Known issues: * API is really raw, need your feedback. * All reflection artifacts are now represented by abstract types. This means that pattern matching against them will emit unchecked warnings. Adriaan is working on a patch that will fix that. WARNING, FELLOW CODE EXPLORER! You have entered a turbulence zone. For this commit and its nearby parents and children tests are not guaranteed to work. Things get back to normal only after the "repairs the tests after the refactoring spree" commit. Why so weird? These twentish changesets were once parts of a humongous blob, which spanned 1200 files and 15 kLOC. I did my best to split up the blob, so that the individual parts of the code compile and make sense in isolation. However doing the same for tests would be too much work.
* preparations: always explicitly provide type tagsEugene Burmako2012-06-084-10/+38
| | | | | In our codebase we now explicitly provide type tags even if they can be materialized. This is necessary to ease the upcoming reflection refactoring (or refactorings :)).
* preparations: removes DynamicProxyEugene Burmako2012-06-081-74/+0
| | | | | This is necessary because toolboxes will no longer be available from the library. Christopher Vogt will take care of the second reincarnation of DynamicRef.
* macros: refactoring of fast track infrastructureEugene Burmako2012-06-0813-309/+319
| | | | | | | | | As a result, hardwired macros don't need implementation stubs. This is very important, because in a few commits scala.reflect.makro.Context will move out from scala-library.jar. Also adding fast track entries doesn't require jumping through hoops with PDTs. It's as simple as defining PartialFunction[Tree, Any].
* macros: now use Java reflectionEugene Burmako2012-06-081-81/+71
| | | | | | | | | Due to some voodoo magic creating a new instance of a compiler cake, immediately degrades performance of the compiler. Out guess is that it makes HotSpot treat calls to cake methods as polymorphic. However we didn't do any performance testing, it just works, and that's enough. Enough for now.
* macros: -Xmacros is now retiredEugene Burmako2012-06-082-3/+1
|
* improves traces and error messagesEugene Burmako2012-06-089-51/+70
|
* REPL bells and whistles: -Dscala.repl.maxprintstring=<Integer>Eugene Burmako2012-06-083-2/+5
| | | | | Makes `maxPrintString` configurable and fixes its treatment at zero. Quite useful for debugging elaborate classloaders with long classpaths.
* REPL bells and whistles: -Dscala.repl.vids=<Boolean>Eugene Burmako2012-06-082-1/+7
| | | | | | Displays identity hashcodes next to `res` values printed by REPL. This proved quite useful in detecting reflection artifacts that look the same, but are, in fact, different.
* REPL bells and whistles: -Dscala.repl.autoruncode=<JFile>Eugene Burmako2012-06-082-3/+11
| | | | | | Useful for the upcoming reflection refactoring. Previously it was more or less okay to type "import scala.reflect.mirror._", but soon we'll have multiple universes and mirrors.
* REPL no longer hangs after initialization crashesEugene Burmako2012-06-083-8/+27
|
* typers: simplifies original calculation in typedAnnotatedEugene Burmako2012-06-081-4/+3
|
* typers: dubious line in adaptTypeEugene Burmako2012-06-081-0/+4
|
* typers: fixes error handling in checkStableEugene Burmako2012-06-081-1/+3
|
* Merge pull request #672 from axel22/issue/5857Adriaan Moors2012-06-082-2/+42
|\ | | | | Fixes SI-5857. More efficient min and max in Range and NumericRange
| * Fixes SI-5857.Aleksandar Prokopec2012-06-062-2/+42
| | | | | | | | | | | | | | | | Override `min` and `max` in `Range` and `NumericRange` to check if a default `Ordering` for the numeric type in question is used. If so, bypass traversal and compute the minimum or maximum element.
* | Merge pull request #654 from magarciaEPFL/ticket-SI-4804Adriaan Moors2012-06-081-21/+13
|\ \ | | | | | | GenASM-based fix for SI-4804. Fix of the same for GenJVM pending.
| * | GenASM-based fix for SI-4804. Fix of the same for GenJVM pending.Miguel Garcia2012-06-011-21/+13
| | |
* | | Merge pull request #678 from magarciaEPFL/fixesJosh Suereth2012-06-081-1/+5
|\ \ \ | | | | | | | | counterpart in GenASM to 241c7606d0bf5f3209b9d549fb75
| * | | counterpart in GenASM to 241c7606d0bf5f3209b9d549fb75Miguel Garcia2012-06-071-1/+5
| | | |
* | | | Merge pull request #677 from axel22/feature/util-hashing2Josh Suereth2012-06-0715-55/+133
|\ \ \ \ | |/ / / |/| | | Add the first iteration of the `util.hashing` package.
| * | | Add the first iteration of the `util.hashing` package.Aleksandar Prokopec2012-06-0715-55/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move `MurmurHash3` to `util.hashing`. Make the `class` private and retain a public companion `object`, and put the `MurmurHash3.Hashing` implementations for various types in the companion. Add a method which composes `ByteswapHashing` with some other hashing. Rename `hashOf` to `hash`. Fix chi-square test in a test-case. Review by @jsuereth. Moved a failing test that seems to use some other library version to pending.
* | | | Generate abstract methods in scala.Byte and friends.Paul Phillips2012-06-0613-778/+816
|/ / / | | | | | | | | | | | | Rather than stub implementations. This saves over 50K of bytecode. I also added the necessary imports to silence the feature warnings.
* | | Merge pull request #669 from dgruntz/masterJosh Suereth2012-06-061-5/+6
|\ \ \ | | | | | | | | Fixes typos in scaladoc of Orderes.scala
| * | | fixes typos in scaladoc of Orderes.calaDominik Gruntz2012-06-051-5/+6
| | | |
* | | | Merge pull request #673 from axel22/issue/5880Josh Suereth2012-06-061-2/+8
|\ \ \ \ | | | | | | | | | | Fix SI-5880.
| * | | | Fix SI-5880.Aleksandar Prokopec2012-06-061-2/+8
| | |_|/ | |/| | | | | | | | | | Add a ChiSquare test for the new hash code.
* | | | Merge pull request #671 from axel22/issue/5867Josh Suereth2012-06-061-0/+2
|\ \ \ \ | | | | | | | | | | Fix SI-5867.
| * | | | Fix SI-5867.Aleksandar Prokopec2012-06-061-0/+2
| |/ / / | | | | | | | | | | | | Override clone for unrolled buffer.
* | | | Merge pull request #670 from axel22/issue/5879Josh Suereth2012-06-061-15/+52
|\ \ \ \ | | | | | | | | | | Fix SI-5879.
| * | | | Fix SI-5879.Aleksandar Prokopec2012-06-061-15/+52
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a bug where a key in an immutable hash map have the corresponding value different in the iteration than when doing lookup. This use to happen after calling `merge`. Fix the order in which a key-value pair appears in the collision resolution function - the first argument always comes from the `this` hash map. Deprecate `merge` in favour of `merged`, as this is a pure method. As an added benefit, the syntax for invoking `merge` is now nicer.
* | | | Merge pull request #667 from phaller/wip-sip14-ec-configJosh Suereth2012-06-061-7/+21
|\ \ \ \ | |/ / / |/| | | Add configuration for ExecutionContext
| * | | Add configuration for ExecutionContextphaller2012-06-051-7/+21
| |/ /
* | | Merge pull request #668 from viktorklang/masterJosh Suereth2012-06-053-54/+3
|\ \ \ | |/ / |/| | Switching to the Akka-provided Unsafe detection
| * | Switching the the Akka-contributed Unsafe detection to support more ↵Viktor Klang2012-06-053-54/+3
| | | | | | | | | | | | platforms, like Android
* | | Merge pull request #655 from axel22/feature/hasherJosh Suereth2012-06-044-29/+99
|\ \ \ | | | | | | | | Implementing Hashing typeclass
| * | | Fix `Hashing`.Aleksandar Prokopec2012-06-013-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | Move `Hashing` to `scala.util.hashing`. Adde `Hashing.Default` to `Hashing` companion object. Change `TrieMap` to autoswitch from `Hashing.Default` to `TrieMap.MangledHashing`.
| * | | Remove Equality in favour of Equiv.Aleksandar Prokopec2012-06-014-46/+9
| | | | | | | | | | | | | | | | Make Equiv serializable.
| * | | Add Hashing and Equality typeclasses.Aleksandar Prokopec2012-06-013-27/+122
| | | | | | | | | | | | | | | | | | | | | | | | Modify TrieMap to use hashing and equality. Modify serialization in TrieMap appropriately.
* | | | Merge pull request #665 from retronym/ticket/5213Adriaan Moors2012-06-041-11/+10
|\ \ \ \ | | | | | | | | | | SI-5313 Revert to two traversals in substThisAndSym.
| * | | | SI-5313 Revert to two traversals in substThisAndSym.Jason Zaugg2012-06-031-11/+10
| | | | | | | | | | | | | | | | | | | | Partially reverts 334872e.
* | | | | Merge pull request #661 from retronym/ticket/5683Adriaan Moors2012-06-032-29/+38
|\ \ \ \ \ | | | | | | | | | | | | SI-5683 Fail gracefully when transposing a ragged type arg matrix.
| * | | | | SI-5683 Fail gracefully when transposing a ragged type arg matrix.Jason Zaugg2012-06-032-29/+38
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code used to do this, until `transpose` starting throwing IAE rather than AIOOBE. Symptomatic treatment only: The reported crasher now infers ill-kinded type args and reports an error.
* | | | | Revert "#653 -- no lub for statement exprs' types"Adriaan Moors2012-06-032-21/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I should not have merged this pull request yet. I didn't notice we didn't have a full successful run of the test suite. It looks like it breaks test/files/continuations-neg/lazy.scala and given the pending amount of changes, I prefer to have a stable master. This reverts commit 037d3dcbc5896864aec0f9121eeda23fcc4cd610.
* | | | | Merge pull request #653 from dragos/issue/skip-lub-in-blocksAdriaan Moors2012-06-032-6/+21
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Don't compute least upper bounds for if-like exprs in statement position
| * | | | | Don't compute least upper bounds for expressions in statement positions ↵Iulian Dragos2012-06-032-6/+21
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | inside blocks. This may save huge amount of time (Fixes SI-5862) for complicated lubs. I had to remove the a check in adapt for the part that transforms <expr> into { <expr>; () } when the expected type is Unit. The reason is in the code. As a side effect, we get more warnings for pure expressions in statement positions (see the change in the test file).
* | | | | Merge pull request #650 from adriaanm/topic-virtpatmatAdriaan Moors2012-06-035-364/+841
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Unreachability analysis for pattern matches Thanks for reviewing, @retronym!
| * | | | | incorporate @retronym's review commentsAdriaan Moors2012-06-031-69/+39
| | | | | |
| * | | | | allow disabling patmat analyses: -Xno-patmat-analysisAdriaan Moors2012-06-014-8/+13
| | | | | |
| * | | | | fixing bug found by unreachabilityAdriaan Moors2012-06-011-3/+2
| | | | | |