summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #2931 from paulp/pr/TreeDSLJason Zaugg2013-09-153-59/+54
|\ | | | | Reducing variation of tree creation methods.
| * Reducing variation of tree creation methods.Paul Phillips2013-09-131-51/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Corrects behavior of finalResultType.Paul Phillips2013-09-133-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | The implementation had come to depend on finalResultType accidentally doing things beyond its charter - in particular, widening types. After hunting down and fixing the call sites depending on the bugs, I was able to rewrite the method to do only what it's supposed to do. I threw in a different way of writing it entirely to suggest how some correctness might be obtained in the future. It's a lot harder for a method written like this to break.
* | Removed deprecated calls.Paul Phillips2013-09-121-92/+95
| | | | | | | | | | | | | | | | | | And changed the implementation internal traits to private[util] rather than sealed because that's closer to the point. I would make them "private" except that this incurs "private type escapes scope" errors where private[util] does not. Also improved file organization.
* | Consolidate Position classes.Paul Phillips2013-09-122-302/+210
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having now been burned several times thinking I had a chunk of positions under my belt only to find my pants had vanished when I forged ahead, I am carving out some intermediate stages for positions. This one only reshuffles the internals. It consolidates almost all the behavior into one class, leaving little stub subclasses to mimic the classes which came before - since nothing is final or has access anything less than public, there's no way to touch any constructor without breakage, so they all have to stay. I removed redundant/incorrect documentation and rewrote the rest of it, although I don't expect the lifespan of any of it to be enormous. The overall thinking behind the existing design was a bit elusive. Concrete exception-throwing implementations were provided in the base class for every method, with less exceptional overrides defined in selected subclasses. If you're going to define every method in the base class, concretely no less, then there is little advantage and lots of disadvantage to spreading out over a bunch of subclasses. Note that now Position contains no state and has no constructor, characteristics which behoove its possibly distant ambition toward AnyValhood. Though that does ignore the "api" class it inherits which brims with implementation detail, api.Position. It is a burden which will likely prove heavy.
* Merge pull request #2859 from som-snytt/issue/7622-phaserGrzegorz Kossakowski2013-09-121-3/+6
|\ | | | | SI-7622 Clean Up Phase Assembly
| * SI-7622 Phases are enabled or notSom Snytt2013-08-211-3/+6
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #2905 from retronym/ticket/7801Grzegorz Kossakowski2013-09-121-4/+10
|\ \ | | | | | | SI-7801 Fix a nightmarish bug in Symbols#adaptInfos
| * | SI-7801 Fix a nightmarish bug in Symbols#adaptInfosJason Zaugg2013-09-041-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compiler-in-residence has always been a sketchy affair; FSC and REPL offers a bounty of bugs that exploit the menagerie of time-travel mechanisms in play for symbols' metadata (type, flags, name and owner.) but are often cleverly masked by optimizations in the compiler based on reference equality. The latest: an innocuous change in Erasure: https://github.com/scala/scala/commit/d8b96bb8#commitcomment-3995163 means that some `ErasureMap`-s over `MethodType`-s are now true identities (as `UnitTpe` is always the same object, whereas `erasedTypeRef(UnitClass)` returns an different `TypeRef` each time.) This, in turn, enables `TypeMap#mapOver` to reuse the existing enclosing type, and so on. On such subtleties hinge further optimizations, such as whether or not a given phase's `InfoTransformer` needs to add an entry in a symbols type history. When the REPL (or FSC / Presentation Compiler) creates a new `Run`, `Symbol#rawInfo` tries to adapt the entries in the type history for the new run. For packages, this was taken to be a no-op; each entry is marked as being valid in the new run and no further action is taken. This logic lurks in `adaptInfos`. But, when the namer enters a new symbol in a package, it *mutates* the Scope of that package classes info `enteringTyper`. So the later entries in the type history *must* be invalidated and recomputed. We have two choices for a fix: 1) modify `Namers#enterInScope` to blow away the subsequent type history for the owning symbol after inserting the new member. Something like `owner.setInfo(owner.info)` would have the desired effect. 2) Change `adaptInfos` to be more conservative when it comes to package classes, and retain only the oldest entry in the type history. This commit goes for option 2.
* | | SI-7834 Type equivalence of C.this and C.super.Paul Phillips2013-09-112-13/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #2910 from densh/topic/quasiquote-improvement-finalJason Zaugg2013-09-115-100/+493
|\ \ \ | | | | | | | | Various bugfixes and improvements for the quasiquotes
| * | | streamline implementation of annotation splicingDen Shabalin2013-09-052-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | Syntax spec mislead me to believe that annotation can't have type parameters or multiple argument lists... I guess the lesson here is don't trust the spec.
| * | | unify handling of references to scala members for functions and tuplesDen Shabalin2013-09-051-19/+35
| | | |
| * | | better support for ValDefs, VarDefs and DefDefsDen Shabalin2013-09-053-0/+48
| | | |
| * | | rename TupleN and TupleTypeN into SyntacticTuple and SyntacticTupleTypeDen Shabalin2013-09-053-7/+7
| | | |
| * | | SI-7723 better support for deconstruction of new expressionsDen Shabalin2013-09-053-0/+23
| | | |
| * | | SI-7803 support for matching of anonymous function literalsDen Shabalin2013-09-053-5/+30
| | | |
| * | | first-class early def splicing and extraction supportDen Shabalin2013-09-054-31/+166
| | | |
| * | | add support for function type splicing and extractionDen Shabalin2013-09-054-1/+34
| | | |
| * | | reify ScalaPackage symbol with the help of ScalaDotDen Shabalin2013-09-053-0/+16
| | | |
| * | | refine block and applied/typeapplied splicing/matching semanticsDen Shabalin2013-09-054-22/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. blocks now match single term-level expressions to account for automatic block elimination. E.g. val q"{ ..$stats }" = q"foo" will match into stats = List(q"foo"). This is useful to uniformly deal with blocks on term level. 2. blocks in quasiquotes collapse into single expressions 3. Applied and TypeApplied now have constructors too which helps to unify matching and extraction in quasiquote reifier 4. TypeApplied now matches AppliedTypeTree too 5. Add Syntactic prefix to Applied and TypeApplied
| * | | SI-7196 add support for refineStat splicing and extractionDen Shabalin2013-09-053-2/+19
| | | |
| * | | minor changes to TreeGen.mkTemplateDen Shabalin2013-09-051-8/+9
| | | | | | | | | | | | | | | | | | | | 1. Make superPos parameter optional with default value NoPosition 2. use Option instead of List for local optional constructor variable
| * | | move mkNew from tools.nsc.ast.TreeGen to reflect.internal.TreeGenDen Shabalin2013-09-051-0/+35
| | | | | | | | | | | | | | | | This is needed for quasiquotes to implement SyntacticNew combinator.
| * | | use NoMods and NoFlags for reification of empty valuesDen Shabalin2013-09-051-0/+1
| | | |
| * | | merge flagsFromBits and FlagsAsBits into FlagsReprDen Shabalin2013-09-053-10/+8
| | | |
| * | | rename mkAnnotationCtor into mkAnnotationDen Shabalin2013-09-053-3/+3
| | | |
| * | | add missing copyTypeDef utility functionDen Shabalin2013-09-051-0/+16
| |/ /
* | | Merge pull request #2904 from som-snytt/issue/reflect-priv-ctorJason Zaugg2013-09-101-1/+1
|\ \ \ | | | | | | | | SI-7810 Reflect private constructor
| * | | SI-7810 Reflect private constructorSom Snytt2013-09-031-1/+1
| |/ / | | | | | | | | | | | | `JavaMirror.constructorToJava` uses `getDeclaredConstructor` now instead of `getConstructor`.
* | | Merge pull request #2926 from paulp/pr/treecheckersJason Zaugg2013-09-101-4/+5
|\ \ \ | | | | | | | | Noise reduction + minor enhance in TreeCheckers.
| * | | Noise reduction + minor enhance in TreeCheckers.Paul Phillips2013-09-091-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Misc irrelevant work, which I can only offer as-is. It lowers the noise in -Ycheck:* output and performs some common sense chillaxes like not screaming ERROR IN INTERNAL CHECKING! WE'RE ALL GOING TO DIE! when a tree doesn't hit all nine points at the Jiffy Tree. You can see some reasonably well reduced symbol flailing if you run the included pending tests: test/partest --show-diff test/pending/pos/treecheckers Example output, Out of scope symbol reference { tree TypeTree Factory[Traversable] position OffsetPosition test/pending/pos/treecheckers/c5.scala:3 with sym ClassSymbol Factory: Factory[CC] and tpe ClassArgsTypeRef Factory[Traversable] encl(1) ModuleSymbol object Test5 ref to AbstractTypeSymbol X (<deferred> <param>) }
* | | | Merge pull request #2915 from retronym/ticket/7817Jason Zaugg2013-09-101-1/+1
|\ \ \ \ | |/ / / |/| | | SI-7817 Fix regression in structural types
| * | | SI-7817 Fix regression in structural typesJason Zaugg2013-09-091-1/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calls to structural types are converted to reflective calls in the `cleanup` phase, which, along with `mixin`, does its work after `flatten`. `Symbol#owner` behaves in a phase dependent manner; after flatten the owner of lifted class is given as the enclosing package. Except when they're not. `ModuleSymbol`s representing an object nested inside a class are viewed dually as modules *and* methods (see the comments on `isModuleNotMethod` for some background). When it comes time to flatten, we're presented with a quandary: the method must clearly stay owned by the enclosing class, but surely the lifted module should be owned by the enclosing package, to have the same owner as its associated module class. The `method` nature of this symbol seems to win: override def owner = { if (Statistics.hotEnabled) Statistics.incCounter(ownerCount) if (!isMethod && needsFlatClasses) rawowner.owner else rawowner This wrinkle leads to a wrong turn in `TreeGen#mkAttributedRef`, which incorrectly rewrites `REF(O)` to `p1.`package`.O`. It seems this problem has gone unnoticed because the tree emitted referred to a static symbol (the reflection cache for structural types), and the backend simply elided the qualifier `p1.package`. A recent change to the backend makes it more conservative about dropping qualifiers on the floor, and it started emitting a reference to a package object that doesn't exist. This commit despairingly checks `isDefinedInPackage` of both the module *and* the module class. The test cases from the previous commit illustrated the status quo, and this commit updates the joint compilation test with the bug fix. A new test is to show that the symptom (structural type crash) is now fixed.
* | | Merge pull request #2885 from som-snytt/issue/7791-script-linenumsJason Zaugg2013-09-081-0/+5
|\ \ \ | | | | | | | | SI-7791 Line number table reflects underlying file
| * | | SI-7791 Line number table reflects underlying fileSom Snytt2013-09-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since positions ultimately know their ultimate positions in their ultimate source, use that line number, ultimately, when emitting line number table entries. It is possible, but possibly not useful, to emit both the actual (ultimate) line number and the nominal one. The `int`-valued line number of the `StackTraceElement` is "derived" from the attribute. In global, wrapping a `BatchSourceFile` as a `ScriptSource` happens in `compileSources` to facilitate testing. A `ScriptTest` facility is provided to facilitate testing the script facility. It is rather facile.
* | | | Merge remote-tracking branch 'scala/2.10.x' into merge-2.10.xGrzegorz Kossakowski2013-09-053-1/+23
|\ \ \ \ | |_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: bincompat-backward.whitelist.conf bincompat-forward.whitelist.conf src/reflect/scala/reflect/internal/SymbolTable.scala src/reflect/scala/reflect/internal/util/WeakHashSet.scala src/reflect/scala/reflect/runtime/JavaMirrors.scala
| * | | Merge pull request #2901 from gkossakowski/backport-uniques-memory-fixGrzegorz Kossakowski2013-09-043-54/+416
| |\ \ \ | | | | | | | | | | Backport #2605 to 2.10.x: SI-7149 Use a WeakHashSet for type uniqueness
| | * | | Modify perRunCaches to not leak WeakReferencesJames Iry2013-09-031-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | perRunCaches was using a HashMap of WeakReferences which meant it would accumulate WeakReferences over time. This commit uses a WeakHashSet instead so that the references are cleaned up.
| | * | | SI-7149 Use a WeakHashSet for type uniquenessGrzegorz Kossakowski2013-09-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently type uniqueness is done via a HashSet[Type], but that means the Types live through an entire compile session, even ones that are used once. The result is a huge amount of unnecessarily retained memory. This commit uses a WeakHashSet instead so that Types and their WeakReferences are cleaned up when no longer in use.
| | * | | SI-7150 Replace scala.reflect.internal.WeakHashSetGrzegorz Kossakowski2013-09-031-42/+411
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaces scala.reflect.internal.WeakHashSet with a version that * extends the mutable.Set trait * doesn't leak WeakReferences * is unit tested
| * | | | Merge pull request #2876 from retronym/ticket/7782Jason Zaugg2013-09-041-1/+8
| |\ \ \ \ | | |/ / / | |/| | | SI-7782 Derive type skolems at the ground level
| | * | | SI-7782 Derive type skolems at the ground levelJason Zaugg2013-08-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than at the current value of `skolemizationLevel`, which could be influenced by an in-flight existential subtype computation. This method is called in `PolyTypeCompleter`, which could be constructed by the lazy type completer of the enclosing class. So currently it is closing over a mutable variable; hence the Heisenbug. This issue was exposed by the changes in b74c33eb860, which was introduced in Scala 2.10.1.
| * | | | Merge pull request #2871 from retronym/ticket/7779Jason Zaugg2013-08-292-0/+15
| |\ \ \ \ | | | | | | | | | | | | SI-7779 Account for class name compactification in reflection
| | * | | | SI-7779 Account for class name compactification in reflectionJason Zaugg2013-08-232-0/+15
| | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have to assume that the classes we are reflecting on were compiled with the default value for -Xmax-classfile-name (255). With this assumption, we can apply the same name compactification as done in the regular compiler. The REPL is particularly prone to generating long class names with the '$iw' prefixes, so this is an important fix for runtime reflection. Also adds support for getting the runtime class of `O.type` if `O` is a module.
* | | | | Merge pull request #2864 from retronym/ticket/6240-namesJason Zaugg2013-09-022-43/+70
|\ \ \ \ \ | | | | | | | | | | | | SI-6240 Synchronizes Names
| * | | | | Lock down methods in NamesJason Zaugg2013-08-311-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Marking some methods as final. Once known to be overriden in scala-ide are instead marked with @deprecatedOveriding. This is to signal the new means of synchronization to subclasses.
| * | | | | SI-6240 Synchronizes NamesJason Zaugg2013-08-222-33/+57
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we didn't have all possible name creation facilities covered with locks, so some of them silently misbehaved and caused much grief: http://groups.google.com/group/scala-internals/browse_thread/thread/ec1d3e2c4bcb000a. This patch gets all the name factories under control. Rather than relying on subclasses to override mutating methods and add synchronization, they should instead override `synchronizeNames` to return true and leave the placement of the locks up to `reflect.internal.Names`. These locks are placed around sections that mutate `typeHashtable` and `termHashtable`. This is done in the reflection universe, and in the interactive compiler. The latter change will obviate an incomplete attempt do to the same in `ScalaPresentationCompiler` in the scala-ide project.
* | | | | Merge pull request #2886 from gkossakowski/merge-2.10.xJason Zaugg2013-08-309-36/+63
|\ \ \ \ \ | | | | | | | | | | | | Merge 2.10.x into master
| * \ \ \ \ Merge remote-tracking branch 'scala/2.10.x'Grzegorz Kossakowski2013-08-299-36/+63
| |\ \ \ \ \ | | | |/ / / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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