summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-1838-89/+62
| | | | | | | | | | - Language imports are preceding other imports - Deleted empty file: InlineErasure - Removed some unused private[parallel] methods in scala/collection/parallel/package.scala This removes hundreds of warnings when compiling with "-Xlint -Ywarn-dead-code -Ywarn-unused -Ywarn-unused-import".
* Merge pull request #4729 from retronym/topic-trait-defaults-moduleLukas Rytz2015-12-183-3/+3
|\ | | | | Desugar module var and accessor in refchecks/lazyvals
| * Desugar module var and accessor in refchecks/lazyvalsJason Zaugg2015-10-083-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than leaving it until mixin. The broader motivation is to simplify the mixin phase of the compiler before we get rid of implementatation classes in favour of using JDK8 default interface methods. The current code in mixin is used for both lazy val and modules, and puts the "slow path" code that uses the monitor into a dedicated method (`moduleName$lzyCompute`). I tracked this back to a3d4d17b77. I can't tell from that commit whether the performance sensititivity was related to modules or lazy vals, from the commit message I'd say the latter. As the initialization code for a module is just a constructor call, rather than an arbitraryly large chunk of code for a lazy initializer, this commit opts to inline the `lzycompute` method. During refchecks, mixin module accessors are added to classes, so that mixed in and defined modules are translated uniformly. Trait owned modules get an accessor method with an empty body (that shares the module symbol), but no module var. Defer synthesis of the double checked locking idiom to the lazyvals phase, which gets us a step closer to a unified translation of modules and lazy vals. I had to change the `atOwner` methods to to avoid using the non-existent module class of a module accessor method as the current owner. This fixes a latent bug. Without this change, retypechecking of the module accessor method during erasure crashes with an accessibility error selecting the module var. In the process, I've tweaked a tree generation utility method to wvoid synthesizing redundant blocks in module desugaring.
* | Merge pull request #4265 from retronym/ticket/9110Lukas Rytz2015-12-181-1/+2
|\ \ | | | | | | SI-9110 Pattern `O.C` must check `$outer eq O` for a top level O
| * | SI-9110 Pattern `O.C` must check `$outer eq O` for a top level OJason Zaugg2015-11-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The outer check was not being generated when the prefix was a top level module. The enclosed test shows that we in fact must synthesize the outer check in that case. Perhaps the bug was introduced by neglecting to consider that a module can inherit member classes.
* | | Merge commit '5e99f82' into merge-2.11-to-2.12-nov-27Lukas Rytz2015-11-274-8/+8
|\ \ \ | |/ / |/| |
| * | Apply some static code analysis recommendationsJanek Bogucki2015-11-264-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a batch of code inspection recommendations generated by IntelliJ 14.1.5. Categories of fix, Unnecessary public modifier in interface Replace filter+size with count Replace filter+nonEmpty with exists Replace filter+headOption with find Replace `if (x != null) Some(x) else None` with Option(x) Replace getOrElse null with orNull Drop redundant semicolons Replace anon fun with PF Replace anon fun with method
* | | Merge commit '8eb1d4c' into merge-2.11-to-2.12-nov-24Lukas Rytz2015-11-242-13/+29
|\| |
| * | Attacking exponential complexity in TypeMapsJason Zaugg2015-11-132-13/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Don't normalize existentials during the `contain`-s type map; `ExistentialType#normalize' calls contains internally and an exponential blowup ensues. - Ensure that the type map used in variance validation never returns modified types in order to avoid needless cloning of symbols. The enclosed test case still gets stuck in Uncurry, thanks to the way that `TypeMap#mapOver(List[Symbol])` recurses through the type first to check whether the type map would be an no-op or not. If not, it repeats the type map with cloned symbols. Doing the work twice at each level of recursion blows up the complexity. Removing that "fast path" allows the enclosed test to compile completely. As at this commit, it gets stuck in uncurry, which dealiases `s.List` to `s.c.i.List` within the type. Some more background on the troublesome part of `TypeMap`: http://lrytz.github.io/scala-aladdin-bugtracker/displayItem.do%3Fid=1210.html https://github.com/scala/scala/commit/f8b2b21050e7a2ca0f537ef70e3e0c8eead43abc
* | | Clean up a bit more in Constructors.Adriaan Moors2015-11-121-0/+2
| | | | | | | | | | | | | | | | | | Comment about my poor naming choice in Types. NullaryMethodType sounds like the method has one empty argument list, whereas it really has no argument lists at all.
* | | Sbt-compatible implementation of `isPastXXXPhase`Adriaan Moors2015-11-121-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sbt's [API extraction phase](https://github.com/sbt/sbt/blob/0.13/compile/interface/src/main/scala/xsbt/API.scala#L25) extends `scala.reflect.internal.Phase`, which implements a bunch of methods, such as `erasedTypes` as `false`, which are then overridden by scalac in `GlobalPhase` (nested in scala.tools.nsc.Global). (`erasedTypes` in particular is again overridden in the back-end -- for performance?) However, since sbt's compiler phases extend `reflect.internal.Phase`, the logic for detecting the current phase does not work, as the default implementation is called (simply returning `false`), when chasing the `prev` pointers hits an sbt-injected phase, as its implementation is `reflect.internal`'s constant `false`.
* | | Annotation filtering & derivation in one place.Adriaan Moors2015-11-121-0/+16
| | | | | | | | | | | | | | | This logic was scattered all over the hierarchy, even though it's only needed in one spot, and is unlikely to evolve.
* | | Also mutate module *class*'s owner in ChangeOwnerTraverserAdriaan Moors2015-11-122-15/+5
| | | | | | | | | | | | | | | Keep owner for module (symbol of the tree) and module class (holds the members) in synch while moving trees between owners (e.g., while duplicating them in specialization)
* | | Use BTypes when building the lambdaMetaFactoryBootstrapHandleLukas Rytz2015-11-062-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | All class internal names that are referenced from a class being compiled should be referenced through their ClassBType. This makes sure that the ClassBType is cached in `classBTypeFromInternalName`, which is required during classfile writing: when ASM computes stack map frames, we need to answer subtyping queries, for which we need to look up the ClassBTypes.
* | | SI-9535 correct bytecode and generic signatures for @throws[TypeParam]Lukas Rytz2015-10-262-12/+6
| | | | | | | | | | | | | | | | | | | | | For @throws[E] where E is not a class type, GenASM incorrectly writes the non-class type to the classfile. GenBCode used to crash before this commit. Now GenBCode correctly emits the erased type (like javac) and adds a generic signature.
* | | Allow @inline/noinline at callsites (in addition to def-site)Lukas Rytz2015-10-202-0/+6
| |/ |/| | | | | | | | | | | Allow annotating individual callsites @inline / @noinline using an annotation ascription c.foo(): @inline
* | Merge commit 'bb3ded3' into merge-2.11-to-2.12-oct-5Lukas Rytz2015-10-055-4/+18
|\|
| * Merge pull request #4770 from SethTisue/windows-testing-fixesLukas Rytz2015-10-051-0/+8
| |\ | | | | | | get test suite passing on Windows
| | * add comments warning of InputStream leaks in scala.io.reflectSeth Tisue2015-09-251-0/+8
| | |
| * | Merge pull request #4768 from SethTisue/fix-indentationSeth Tisue2015-09-241-1/+1
| |\ \ | | |/ | |/| fix indentation
| | * fix indentationSeth Tisue2015-09-241-1/+1
| | | | | | | | | | | | this sneaked into 2d025fe2d0c9cd0e01e390055b0531166988f901
| * | Improve presentation compilation of annotationsJason Zaugg2015-09-243-3/+9
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A trio of problems were hampering autocompletion of annotations. First, given that that annotation is written before the annotated member, it is very common to end parse incomplete code that has a floating annotation without an anotatee. The parser was discarding the annotations (ie, the modifiers) and emitting an `EmptyTree`. Second, the presetation compiler was only looking for annotations in the Modifiers of a member def, but after typechecking annotations are moved into the symbol. Third, if an annotation failed to typecheck, it was being discarded in place of `ErroneousAnnotation`. This commit: - modifies the parser to uses a dummy class- or type-def tree, instead of EmptyTree, which can carry the annotations. - updates the locator to look in the symbol annotations of the modifiers contains no annotations. - uses a separate instance of `ErroneousAnnotation` for each erroneous annotation, and stores the original tree in its `original` tree.
* | SI-9498 Centralize and bolster TypeRef cache invalidationJason Zaugg2015-09-301-11/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | I found another spot where I had previously needed to manually invalidate a TypeRef cache, and modified that to route through the newly added `invalidatedCaches`. `invalidatedCaches` now invalidates all the other caches I could find in our types of types. I opted for a non-OO approach here, as we've got a fairly intricate lattice of traits in place that define caches, and I didn't have the stomach for adding a polymorphic `Type::invalidatedCaches` with the the right sprinkling over overrides and super calls.
* | SI-9498 Avoid caching bug with pattern type variablesJason Zaugg2015-09-302-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Typechecking a pattern that defines a pattern type variable initially assigns abstract type symbol with open type bounds. Later on, pattern type inference kicks in to sharpen the type of the variable based on constraints imposed by the expected type (ie, the type of scrutinee of the pattern.) However, before inference does this, a `TypeRef` to the abstract type symbol can be queried for its base type with respect to some class, which leads to it populating an internal cache. This cache becomes stale when the underlying symbol has its type mutated. The repercussions of this meant that a subsequent call to `baseType` gave the wrong result (`NoType`), which lead to an `asSeenFrom` operation to miss out of substitution of a type variable. Note the appearance of `A` in the old type errors in the enclosed test case. This commit takes an approach similar to 286dafbd to invalidate caches after the mutation. I've routed both bandaids through the same first aid kit: I'm sure over time we'll add additional calls to this method, and additional cache invalidations within it.
* | Merge commit '03aaf05' into merge-2.11-to-2.12-sep-22Lukas Rytz2015-09-222-1/+14
|\|
| * Merge pull request #4725 from retronym/topic/completely-2.11Lukas Rytz2015-09-212-1/+14
| |\ | | | | | | Topic/completely 2.11
| | * Merge remote-tracking branch 'origin/2.11.x' into topic/completely-2.11Jason Zaugg2015-09-179-16/+24
| | |\
| | * | Exclude <byname> and friends from REPL completionJason Zaugg2015-09-091-1/+1
| | | |
| | * | Add a convenience method to Symbol to "resugar" fieldsJason Zaugg2015-09-021-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | val and var members of classes are split into getter/setter and field symbols. However, we can't call `defString` on any of these and see what existed in source code. Example: ``` scala> class X { protected var x: Int = 0 } defined class X scala> val xField = typeOf[X].member(TermName("x ")) xField: $r.intp.global.Symbol = variable x scala> xField.defString res10: String = private[this] var x: Int scala> xField.getterIn(xField.owner).defString res11: String = protected def x: Int scala> xField.setterIn(xField.owner).defString res12: String = protected def x_=(x$1: Int): Unit ``` This commit introduces a new method on `Symbol` that pieces together the information from these symbols to create an artificial symbol that has the `defString` we're after: ``` scala> xField.sugaredSymbolOrSelf.defString res14: String = protected var x: Int ```
| * | | [backport] Include owner in ErrorNonExistentField messageAlexey Romanov2015-09-181-3/+3
| | | | | | | | | | | | | | | | This should be particularly helpful for synthetic field names like `evidence$21`.
* | | | Merge commit 'a170c99' into 2.12.xLukas Rytz2015-09-226-6/+9
|\| | |
| * | | SI-9475 Dependent PolyTypes are dependent typesVlad Ureche2015-09-171-0/+3
| | |/ | |/| | | | | | | Such that uncurry can correctly un-dependify them.
| * | Merge pull request #4738 from janekdb/2.11.x-urls-driftedSeth Tisue2015-09-151-1/+1
| |\ \ | | | | | | | | Improve drifted URLs
| | * | Improve drifted URLsJanek Bogucki2015-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Any.scala: Link to the guide instead of the SIP. - AnyVal.scala: Remove SIP link and align guide link to Any.scala. - Commands.scala: Use a less out of date team link. - Logic.scala: Link was broken. Substitute found. - Process.scala: Links were 403 & 404. Fixed as this is a code sample. - TypeMaps.scala: Move old EPFL Trac to JIRA. - RedBlackTree.scala: Replaced broken link with substitutes based on site maintainer input [1]. [1] When asked where Data-Set-RBTree.html had gone Don@UNSW advised "I think it's on the Haskell wiki now. It was Chris Okazaki's version". The closest I could find to what this document probably was is this paper by Hinze edited by Okasaki, http://www.cs.ox.ac.uk/ralf.hinze/publications/WAAAPL99b.ps.gz The paper cites the Okasaki document so I included a link to that as well. The Haskell Wiki does have a link to a RB document but that's broken too, https://wiki.haskell.org/Research_papers/Data_structures > Constructing red-black trees
| * | | Merge pull request #4728 from janekdb/2.11.x-urls-docs-codehaus-citeseerSeth Tisue2015-09-154-5/+5
| |\ \ \ | | |/ / | |/| | Update links to docs, codehaus and citeseer
| | * | Update links to docs, codehaus and citeseerJanek Bogucki2015-09-044-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | docs.scala-lang.org - Align some links to new layout for docs.scala-lang.org - Include link to concrete parallel collection performance characteristics codehaus - Subsitute a link to a JIRA email for the 404 JRUBY-3576 JIRA link in Codec.scala. jira.codehaus.org is not redirecting this. citeseer - Replace the citeseer link with a direct link to a PDF which is not behind a login challenge.
| * | | Merge pull request #4713 from SethTisue/batch-of-typosJason Zaugg2015-09-081-1/+1
| |\ \ \ | | | | | | | | | | fix typos/spelling
| | * | | fix assorted typosSeth Tisue2015-08-281-1/+1
| | | |/ | | |/|
| * | | Merge pull request #4704 from VladUreche/issue/9442Jason Zaugg2015-09-062-8/+16
| |\ \ \ | | |_|/ | |/| | SI-9442 Fix the uncurry-erasure types
| | * | SI-9442 Fix the uncurry-erasure typesVlad Ureche2015-08-232-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using the "uncurry-erased" type (the one after the uncurry phase) can lead to incorrect tree transformations. For example, compiling: ``` def foo(c: Ctx)(l: c.Tree): Unit = { val l2: c.Tree = l } ``` Results in the following AST: ``` def foo(c: Ctx, l: Ctx#Tree): Unit = { val l$1: Ctx#Tree = l.asInstanceOf[Ctx#Tree] val l2: c.Tree = l$1 // no, not really, it's not. } ``` Of course, this is incorrect, since `l$1` has type `Ctx#Tree`, which is not a subtype of `c.Tree`. So what we need to do is to use the pre-uncurry type when creating `l$1`, which is `c.Tree` and is correct. Now, there are two additional problems: 1. when varargs and byname params are involved, the uncurry transformation desugares these special cases to actual typerefs, eg: ``` T* ~> Seq[T] (Scala-defined varargs) T* ~> Array[T] (Java-defined varargs) =>T ~> Function0[T] (by name params) ``` we use the DesugaredParameterType object (defined in scala.reflect.internal.transform.UnCurry) to redo this desugaring manually here 2. the type needs to be normalized, since `gen.mkCast` checks this (no HK here, just aliases have to be expanded before handing the type to `gen.mkAttributedCast`, which calls `gen.mkCast`)
| * | | Update Java and Sun URLs to replacement Java and Oracle URLsJanek Bogucki2015-09-021-1/+1
| | |/ | |/| | | | | | | | | | | | | | | | For each URL - Where it redirected the target of the redirection was used - Where is no longer existed a replacement was selected
| * | Fix typos in spec, docs and commentsMichaƂ Pociecha2015-08-234-4/+4
| |/
* | Merge pull request #4711 from lrytz/opt/heuristicsLukas Rytz2015-09-221-1/+3
|\ \ | | | | | | Inliner heuristic for higher-order methods
| * \ Merge remote-tracking branch 'upstream/2.12.x' into opt/heuristicsLukas Rytz2015-09-188-18/+31
| |\ \
| * | | Store SAM information in ClassBTypesLukas Rytz2015-08-271-1/+3
| | | | | | | | | | | | | | | | | | | | If a class (trait) is a SAM type, store the name and descriptor of the SAM in the ClassBType's InlineInfo.
* | | | Merge pull request #4749 from retronym/ticket/9473Lukas Rytz2015-09-221-1/+10
|\ \ \ \ | | | | | | | | | | SI-9473 Cleaner references to statically owned symbols
| * | | | SI-9473 Cleaner references to statically owned symbolsJason Zaugg2015-09-221-1/+10
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ever wonder why `identity("")` typechecks to `scala.this.Predef.identity("")`? It turns out that `mkAttributedRef` was importing `q"$scalaPackageClass.this.Predef._"` for all these years, rather than `q"$scalaModule.Predef._"`. This commit makes `mkAttributedRef` special case static owners by referring the the corresponding module, instead.
* | | | Merge pull request #4699 from alexeyr/patch-1Lukas Rytz2015-09-181-3/+3
|\ \ \ \ | |/ / / |/| | | Include owner in ErrorNonExistentField message
| * | | Include owner in ErrorNonExistentField messageAlexey Romanov2015-09-141-3/+3
| |/ / | | | | | | | | | This should be particularly helpful for synthetic field names like `evidence$21`.
* | | Merge remote-tracking branch 'origin/2.11.x' into 2.12.xSeth Tisue2015-09-087-14/+22
| | | | | | | | | | | | | | | | | | | | | | | | only trivial merge conflicts here. not dealing with PR #4333 in this merge because there is a substantial conflict there -- so that's why I stopped at 63daba33ae99471175e9d7b20792324615f5999b for now