summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/TreeGen.scala
Commit message (Collapse)AuthorAgeFilesLines
* SI-8040 Warn unused flagsSom Snytt2017-03-111-2/+8
| | | | | | | | | | | | | | | | Introduce `-Ywarn-unused:x,y,z` and exploit `-Ywarn-unused:patvars`. Although the tree attachment for shielding patvars from warnings is not structural, sneaking the settings flag into the reflection internal TreeGen is awkward. Add test to ensure isolation of patvars warning from others. `-Ywarn-unused-import` is an alias for `-Ywarn-unused:imports`. `-Xlint:unused` is an alias for `-Ywarn-unused`, but not enabled yet. The help text advises to use `-Ywarn-unused`. The future can decide if `-Xlint:unused-imports` is warranted.
* SI-9158 No warn for comprehension patvarsSom Snytt2017-03-111-5/+12
| | | | | | | | | | | | | | | | | Midstream assignments should not cause unused warnings. Currently the encoding doesn't pass them along, but passes the value from which they were destructured. For for-comprehensions only, the patvar transform tags the binds so that they are not warned if they turn up in a valdef and are unused. Extractors are invoked multiple times if the patvar is used later, as noted on the ticket. In a yield, the valdef is emitted only if the patvar is referenced (possibly saving the extra extraction), so there is no warning there currently.
* Typo and spelling correctionsJanek Bogucki2016-11-111-1/+1
|
* Refactor. Extract mkLiteralUnit and mkUnitBlockAdriaan Moors2016-03-261-4/+7
|
* Improved outer ref checking in pattern matches:Adriaan Moors2016-03-071-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old algorithm omitted necessary outer ref checks in some places. This new one is more conservative. It only omits outer ref checks when the expected type and the scrutinee type match up, or when the expected type is defined in a static location. For this specific purpose the top level of a method or other code block (which is not a trait or class definition) is also considered static because it does not have a prefix. This change comes with a spec update to clarify the prefix rule for type patterns. The new wording makes it clear that the presence of a prefix is to be interpreted in a *semantic* way, i.e. the existence of a prefix determines the necessity for an outer ref check, no matter if the prefix is actually spelled out *syntactically*. Note that the old outer ref check implementation did not use the alternative interpretation of requiring prefixes to be given syntactically. It never created an outer ref check for a local class `C`, no matter if the pattern was `_: C` or `_: this.C`, thus violating both interpretations of the spec. There is now explicit support for unchecked matches (like `case _: (T @unchecked) =>`) to suppress warnings for unchecked outer refs. `@unchecked` worked before and was used for this purpose in `neg/t7721` but never actually existed as a feature. It was a result of a bug that prevented an outer ref check from being generated in the first place if *any* annotation was used on an expected type in a type pattern. This new version will still generate the outer ref check if an outer ref is available but suppress the warning otherwise. Other annotations on type patterns are ignored. New tests are in `neg/outer-ref-checks`. The expected results of tests `neg/t7171` and `neg/t7171b` have changed because the compiler now tries to generate additional outer ref checks that were not present before (which was a bug).
* 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 branch '2.11.x' into 2.12.xAdriaan Moors2015-08-051-4/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Transcript: ``` ➜ scala git:(2.12.x) export MB=$(git merge-base 2.12.x 2.11.x) ➜ scala git:(2.12.x) echo $MB 0e9525aa618a2eca143a1c7379ff1e6efd23b86e ➜ scala git:(2.12.x) g log --oneline --graph $MB...2.11.x ``` Read this upside down :-). The last merge comes first, with merge commands interspersed in the git log. ``` ➜ scala git:(2.12.x) g merge 2.11.x Auto-merging versions.properties Auto-merging src/reflect/scala/reflect/internal/pickling/UnPickler.scala Auto-merging src/reflect/scala/reflect/internal/Types.scala Auto-merging src/reflect/scala/reflect/internal/TreeGen.scala Auto-merging src/library/scala/collection/immutable/Stream.scala Auto-merging src/library/scala/collection/convert/Wrappers.scala Auto-merging build.xml CONFLICT (content): Merge conflict in build.xml Auto-merging README.md Automatic merge failed; fix conflicts and then commit the result. ``` ``` * 928e6892d4 (scala/2.11.x, 2.11.x) Merge pull request #4682 from adriaanm/jline-quick.bin |\ | * b763dbf368 (adriaanm/jline-quick.bin, jline-quick.bin) Include jline on quick.bin tool path * | ccded7d179 Merge pull request #4680 from janekdb/2.11.x-option |\ \ | |/ |/| | * 58ae3e51f7 Delegate null test to Option |/ * a745f06e35 Merge pull request #4670 from retronym/ticket/9422 |\ | * ec95e534a2 SI-9422 Fix incorrect constant propagation * 65fa73dff3 Merge pull request #4669 from janekdb/2.11.x-scaladoc-reflect |\ | * e206a1837d ScalaDoc fixes for reflect * | 8e7e3b4a5f Merge pull request #4667 from janekdb/2.11.x-scaladoc-library-library-aux |\ \ | |/ |/| | * 69c2c106fe ScalaDoc fixes for library and library-aux * | 7de4cbc5e5 Merge pull request #4665 from lrytz/asm-504-3 |\ \ | * | cdc55c29d0 Upgrade scala-asm to 5.0.4-scala-3 |/ / * | d8da39a197 Merge pull request #4661 from retronym/ticket/9365 |\ \ | * | 0c99742c51 SI-9365 Don't null out dependencies of transient lazy vals | / * | 2279d3f3d9 Merge pull request #4662 from janekdb/2.11.x-redundant-val-modifier |\ \ | * | 173a6fad95 Remove redundant 'val' from case class params. * | | e0d21432d6 Merge pull request #4664 from SethTisue/remove-dead-link-in-readme |\ \ \ | |_|/ |/| | | * | 600fc4e6e1 fix readme for death of typesafe.artifactoryonline.com | |/ * | 7492bda816 Merge pull request #4636 from SethTisue/contributor-stuff-from-github-wiki |\ \ | |/ |/| | * ed5098dbc4 merge two reviewers lists in readme | * e136e4ad47 tighten up CONTRIBUTING.md a little | * f9ca6863d4 readme/contributor's guide tweaks | * 80e98b03a1 tiny readme fix | * 197845620c merge in text from pull request policy from old wiki | * e93ca409ae drop in pull request policy from old wiki | * 951939d1b3 contributor guide: add a morsel salvaged from GitHub wiki * f682441f6f Merge pull request #4653 from lrytz/t9403 |\ | * 2678d349b2 SI-9403 fix ICodeReader for negative BIPUSH / SIPUSH values ``` ``` ➜ scala git:(2.12.x) g merge -s ours f2d7838d90 Merge made by the 'ours' strategy. ``` ``` * f2d7838d90 Merge pull request #4657 from lrytz/backports |\ | * 241bb9ac19 Rename the ENUM / DEFAULTMETHOD flags to include JAVA_ | * 7a7f9927c3 SI-9393 fix modifiers of ClassBTypes for Java annotations | * 8946d60bd2 [backport] Fix bytecode stability when running the closure optimizer | * 3b6b2bfe9f [backport] SI-9392 Clarify the workaround comment and introduce a devWarning | * 091c1e6ed8 [backport] SI-9392 Avoid crash in GenBCode for incoherent trees | * 6177cb4481 [backport] SI-9393 Temporarily disable two assertions in GenBCode | * a1d471f7ba [backport] Refactor the ClosureOptimizer, run ProdCons only once per method | * f5e72765f2 [backport] SI-9387 Fix VerifyError introduced by indylambda | * 41b99e2531 [backport] Integrate the LMFInvokeDynamic extractor into LambdaMetaFactoryCall | * fc1cda2118 [backport] Small refactoring to the closure optimizer | * 8f272c0ad2 [backport] Accessibility checks for methods with an InvokeDynamic instruction | * 1c1d8259b5 [backport] Fix bytecode stability | * ef9d845676 [backport] Support methodHandle / invokeDynamic constant pool entries in scalap | * 60747c7555 [backport] Skip mirror class when invoking deserializeLambda | * 404e86239e [backport] Prevent infinite recursion in ProdConsAnalyzer | * 1b0703e74d [backport] SI-9376 don't crash when inlining a closure body that throws. | * e511375a90 [backport] Fix superclass for Java interface symbols created in JavaMirrors | * 1b57723169 [backport] `deserializeLambda` should not use encoded class name | * 8bafa8ed88 [backport] Java parser: default methods in interfaces are not `DEFERRED` | * 44e2761a9b [backport] SI-6613 fixed in GenBCode ``` ``` ➜ scala git:(2.12.x) g merge 4c6dcfe934 Auto-merging src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala Auto-merging doc/License.rtf Auto-merging doc/LICENSE.md Auto-merging build.xml Auto-merging build.sbt Merge made by the 'recursive' strategy. Auto packing the repository in background for optimum performance. See "git help gc" for manual housekeeping. build.sbt | 2 +- build.xml | 2 +- doc/LICENSE.md | 4 ++-- doc/License.rtf | 4 ++-- src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala | 2 +- src/scalap/decoder.properties | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) ``` ``` * | 4c6dcfe934 Merge pull request #4656 from lrytz/filtersOpenJDK |\ \ | |/ |/| | * 0b35bc29aa Ignore OpenJDK warnings in partest filters * 6eb0812050 Merge pull request #4644 from SethTisue/copyright-2015 * e0aac7c9ef bump copyright year to 2015 ```
| * ScalaDoc fixes for reflectJanek Bogucki2015-07-281-4/+3
| |
* | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2015-05-011-1/+1
|\| | | | | | | merge/2.11.x-to-2.12.x-20150501
| * Fix many typosMichał Pociecha2015-04-211-1/+1
| | | | | | | | | | This commit corrects many typos found in scaladocs and comments. There's also fixed the name of a private method in ICodeCheckers.
* | Merge commit '32f520f' into merge/2.11-to-2.12-apr-1Lukas Rytz2015-04-011-2/+2
|\|
| * Removed warningsEECOLOR2015-03-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added `since` to deprecation statement - Added unit to parameter list - Removed usage of deprecated method polyType - Replaced deprecated `debugwarn` with `devWarning` - Changed switch statement to if else in order to remove a warning - Switched implementation of `init` and `processOptions` to prevent warning - Replaced deprecated `Console.readLine` with `scala.io.StdIn.readLine` - Replaced deprecated `startOrPoint` with `start` - Replaced deprecated `tpe_=` with `setType` - Replaced deprecated `typeCheck` with `typecheck` - Replaced deprecated `CompilationUnit.warning` with `typer.context.warning` - Replaced deprecated `scala.tools.nsc.util.ScalaClassLoader` with `scala.reflect.internal.util.ScalaClassLoader` - Replaced deprecated `scala.tools.ListOfNil` with `scala.reflect.internal.util.ListOfNil` - Replaced deprecated `scala.tools.utils.ScalaClassLoader` with `scala.reflect.internal.util.ScalaClassLoader` - Replaced deprecated `emptyValDef` with `noSelfType` - In `BoxesRunTime` removed unused method and commented out unused values. Did not delete to keep a reference to the values. If they are deleted people might wonder why `1` and `2` are not used. - Replaced deprecated `scala.tools.nsc.util.AbstractFileClassLoader` with `scala.reflect.internal.util.AbstractFileClassLoader`
* | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2015-01-291-1/+1
|\| | | | | | | | | | | | | | | | | merge/2.11.x-to-2.12.x-20150129 Conflicts: build.number src/library/scala/concurrent/Future.scala versions.properties
| * Fix many typos in docs and commentsmpociecha2014-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit corrects many typos found in scaladocs, comments and documentation. It should reduce a bit number of PRs which fix one typo. There are no changes in the 'real' code except one corrected name of a JUnit test method and some error messages in exceptions. In the case of typos in other method or field names etc., I just skipped them. Obviously this commit doesn't fix all existing typos. I just generated in IntelliJ the list of potential typos and looked through it quickly.
* | More uniform treatment of package objectsJason Zaugg2014-11-071-2/+2
|/ | | | | | | | | | | | | | | | | | | - Introduce `Symbol#packageObject` and `Type#packageObject` to lookup the member package object of a package class/module, and use this far and wide. - Replace the overly complicated (and still buggy) implementation of `Context#isInPackageObject` with a one liner. The simplifying insight is that if we select a symbol from a package prefix that does not own that symbol, it *must* have really been selected from the package object. - Change implicit search to use the cache in `ModuleSymbol#implicitMembers` via `Type#implicitMembers`, which lets the client code read more naturally. Fixes a bug with `adapt::insertApply` that Adriaan spotted in a feat of lateral thinking. This is tested in t8862b.scala. alladin763.scala adds the test case from the bug originally remedied by `insertApply` to check we haven't regressed.
* SI-8703 add support for blocks with just a single expression to quasiquotesDenys Shabalin2014-07-021-2/+2
| | | | | | | | | | | | | | | | | Previously it was impossible to match a block that was constructed as Block(Nil, term) Due to the fact that quasiquotes always flatten those into just term. This is a correct behaviour for construction (for sake of consistency with parser) but doing it in deconstruction mode make it impossible to match such blocks which could have been constructed manually somewhere. To fix this we just disable block flattening in deconstruction mode. Interestingly enough this doesn't break existing code due to the fact that quasiquote's block matcher also matches expressions as single-element blocks. This allows to match single-element blocks with patterns like q"{ $foo }".
* Fix block construction/deconstruction asymmetryDenys Shabalin2014-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Deconstruction of blocks in case clauses uncovered asymmetry between construction and deconstruction of blocks: tree match { case cq"$pat => ..$cases" => cq"$pat => ..$cases" } Such an identity-like transformation used to produce an incorrect tree due to the fact that zero-element block was mistakingly associated with empty tree. Such association was used as a solution to block flatenning: val ab = q"a; b" q"..$ab; c" // ==> q"a; b; c" val a = q"a" q"..$a; c" // ==> q"a; c" val empty = q"" q"..$empty; c" // ==> q"c" This commit changes meaning of zero-element block to a be a synthetic unit instead. This is consistent with parsing of `{}`, cases, ifs and non-abstract empty-bodied methods. A local tweak to block flattenning is used to flatten empty tree as empty list instead.
* Merge remote-tracking branch 'origin/master' into topic/palladium0Eugene Burmako2014-02-161-2/+2
|\ | | | | | | | | | | | | | | Conflicts: src/compiler/scala/reflect/macros/compiler/Resolvers.scala src/compiler/scala/reflect/macros/contexts/Typers.scala src/compiler/scala/tools/reflect/ToolBoxFactory.scala src/reflect/scala/reflect/api/BuildUtils.scala
| * Improve support for patterns in valsDenys Shabalin2014-02-091-2/+2
| | | | | | | | | | | | | | | | 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.
* | exposes additional TreeGen methodsEugene Burmako2014-02-151-0/+3
| | | | | | | | Agains, this is something that's needed for async.
* | establishes scala.reflect.api#internalEugene Burmako2014-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-6732 deprecates internal#Symbol.isPackageEugene Burmako2014-02-141-1/+1
|/ | | | | | | | This is the first step in disentangling api#Symbol.isPackage, which is supposed to return false for package classes, and internal#Symbol.isPackage, which has traditionally being used as a synonym for hasPackageFlag and hence returned true for package classes (unlike isModule which is false for module classes).
* SI-8030 Restore thread safety to the parserJason Zaugg2014-02-051-1/+1
| | | | | | | | | | | | | | | In addition to the invariant "parsing doesn’t enter new symbols", which was respected and tested in 760df9843a910d6, we also must ensure that "parsing doesn't call Symbol#info". That happend indirectly if we call `companionModule`. This commit just converts the name of `class TupleN` to a term name, rather than getting the name of its companion. No test is included. This is tested upstream in: https://jenkins.scala-ide.org:8496/jenkins/view/Memory%20Leak%20Tests/job/scalac-memory-leaks-test-2.11.0/
* Avoid generic collections operations hot pathsJason Zaugg2014-01-311-2/+2
| | | | | | | | | | | | | | - Use a specialized version of List#{map, collectFirst} These special case mapping over an empty list and avoid allocating. - Avoid nonEmpty in favor of `ne Nil` I see in the order of 2% speedup. Perhaps more useful is that these methods no longer dominate the YourKit profiles, even though profiler bias due to safepoints at allocation of the ListBuffer might have been overstating their significance.
* Addresses feedback from JasonDenys Shabalin2014-01-271-4/+14
| | | | | | | | | 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.
* Tag synthetic unit with attachmentDenys Shabalin2014-01-231-1/+1
| | | | | | | | 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.
* Merge pull request #3368 from retronym/ticket/8151Grzegorz Kossakowski2014-01-211-1/+1
|\ | | | | SI-8151 Remove -Yself-in-annots and associated implementation
| * SI-8151 Remove -Yself-in-annots and associated implementationJason Zaugg2014-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This experimental option typechecked arguments of annotations with an injected value in scope named `self`: @Foo(self.foo < 1) This has been slated for removal [1] for some time. This commit removes it in one fell swoop, without any attempt at source compatibility with code that constructs or pattern matches on AnnotatedType. [1] https://groups.google.com/d/msg/scala-internals/VdZ5UJwQFGI/C6tZ493Yxx4J
* | SI-8133 Fix regression with package objects, overloadingJason Zaugg2014-01-141-5/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | Regressed in f5c336d56, a refactoring of `typedIdent`. In that commit, an (ostensibly) accidental change arrived, equivalent to: - val pre1 = if (qual == EmptyTree) NoPrefix else if (sym.isTopLevel) sym.owner.thisType else qual.tpe + val pre1 = if (sym.isTopLevel) sym.owner.thisType else if (qual == EmptyTree) NoPrefix else qual.tpe Here, `qual` is a tree returned in the successful result of `Context#lookup`. This change itself looks innocuous (top level symbols can be prefixed with a qualifier or not, right?), but it exposed us to a bug in `makeAccessible`. It is responsible for rewriting, e.g, `scala.List` to `scala.package.List`. It has a few cases, but one of them relies relies on typechecking `Ident(nme.PACKAGE)`, and hoping that it will bind to the right place. That's fraught with danger, and breaks in the enclosed tests. This commit binds that Ident symbolically, and in the process factors a tiny bit of code in common with `TreeGen`. (More work is still needed here!) In the next commit, I'm going to revert the change to `pre1`. That would have also fixed the regression, albeit symptomatically.
* Merge pull request #3269 from dotta/issue/si-4287Jason Zaugg2014-01-091-6/+14
|\ | | | | Issue/si 4287
| * SI-4827 Corrected positions assigned to constructor's default argMirco Dotta2014-01-081-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Default arguments are always retained on the <init> method (i.e., the class' constructor). Therefore, when the <init> parameters are created, we need to use `duplicateAndKeepPositions` to make sure that if a default argument is present, its opaque position is retained as well. This is necessary because when parameter accessors (i.e., `fieldDefs`) are created, all default arguments are discared ( as you can see in the code, the right-hand-side of a `field` is always an `EmptyTree`) - see changes in TreeGen.scala * When constructing the `fieldDefs`, it is important to adapt their range position to avoid overlappings with the positions of default arguments. It is worth noting that updating the field's end position to `vd.rhs.pos.start` would be incorrect, because `askTypeAt(pos)` could return the incorrect tree when the position is equal to `vd.rhs.pos.start` (because two nodes including that point position would exist in the tree, and `CompilerControl.locateTree(pos)` would return the first tree that includes the passed `pos`). This is why `1` is subtracted to `vd.rhs.pos.start`. Alternatively, we could have used `vd.tpt.pos.end` with similar results. However the logic would have become slightly more complex as we would need to handle the case where `vd.tpt` doesn't have a range position (for instance, this can happen if `-Yinfer-argument-types` is enabled). Therefore, subtracting `1` from `vd.rhs.pos.start` seemed the cleanest solution at the moment. - see changes in TreeGen.scala. * If the synthetic constructor contains trees with an opaque range position (see point above), it must have a transparent position. This can only happen if the constructor's parameters' positions are considered, which is why we are now passing `vparamss1` to `wrappingPos` - see changes in TreeGen.scala. * The derived primary constructor should have a transparent position as it may contain trees with an opaque range position. Hence, the `primaryCtor` position is considered for computing the position of the derived constructor - see change in Typers.scala. Finally, below follows the printing of the tree for test t4287, which you should compare with the one attached with the previous commit message: ``` [[syntax trees at end of typer]] // Foo.scala [0:63]package [0:0]<empty> { [0:37]class Baz extends [9:37][39]scala.AnyRef { [10:20]<paramaccessor> private[this] val f: [14]Int = _; [14]<stable> <accessor> <paramaccessor> def f: [14]Int = [14][14]Baz.this.f; <10:31>def <init>(<10:31>f: [17]<type: [17]scala.Int> = [23:31]B.a): [9]Baz = <10:31>{ <10:31><10:31><10:31>Baz.super.<init>(); <10:31>() } }; [6]<synthetic> object Baz extends [6][6]AnyRef { [6]def <init>(): [9]Baz.type = [6]{ [6][6][6]Baz.super.<init>(); [9]() }; [14]<synthetic> def <init>$default$1: [14]Int = [30]B.a }; [39:63]object B extends [48:63][63]scala.AnyRef { [63]def <init>(): [48]B.type = [63]{ [63][63][63]B.super.<init>(); [48]() }; [52:61]private[this] val a: [56]Int = [60:61]2; [56]<stable> <accessor> def a: [56]Int = [56][56]B.this.a } } ``` You should notice that the default arg of `Baz` constructor now has a range position. And that explains why the associated test now returns the right tree when asking hyperlinking at the location of the default argument.
* | SI-8030 force symbols on presentation compiler initializationDen Shabalin2013-12-121-3/+2
|/ | | | | | | | | This commit forces a number of built-in symbols in presentation compiler to prevent them from being entered during parsing. The property “parsing doesn’t enter new symbols” is tested on a rich source file that contains significant number of variations of Scala syntax.
* add comments that explain new for loop enumerator encodingDen Shabalin2013-11-121-0/+28
|
* implement inverse transformation to mkForDen Shabalin2013-11-121-9/+17
| | | | | | | | | | | This effectively reconstructs a sequence of enumerators and body from the tree produced by mkFor. This lets to define bi-directional SyntacticFor and SyntacticForYield constructors/extractors to work with for loops. Correctness of the transformation is tested by a scalacheck test that generates a sequence of random enumerators, sugars them into maps/flatMaps/foreach/withFilter calls and reconstructs them back.
* move for loop desugaring into tree genDen Shabalin2013-11-121-0/+369
|
* change intermidiate representation of for loop enumeratorsDen Shabalin2013-11-121-7/+16
| | | | | | Encode values into real trees rather than non-tree case classes. This is needed for re-usability of desugaring code between quasiquotes and parser.
* deduplicate tuple tree creation codeDen Shabalin2013-11-121-5/+17
| | | | | | Previously tuple tree generation code has been implemented in three place: tree builder, tree gen, build utils. Now it's just defined once in tree gen.
* SI-6841 SI-6657 add support for packages into quasiquotes and toolboxDen Shabalin2013-10-141-0/+6
| | | | | | In order to implement this a new parser entry point `parseStatsOrPackages` that augments current parseStats with ability to parse "package name { ... }" syntax.
* clearly establishes what macro bundles areEugene Burmako2013-10-021-1/+2
| | | | | | | | | | | | | | | Previously it was enough to just extend scala.reflect.macros.Macro, which created some loopholes, but now scalac enforces that bundles: 1) Are static (not necessarily top-level, but just static) 2) Are traits (objects shouldn't be bundles anyway, and classes bring complications with their ctors which require special treatment in generated classes, so why support them if they don't bring anything new to the table?) 3) Are monomorphic (again, this brings unnecessary complications wrt auxiliary code generation, so I don't see merit in supporting polymorphic bundles, whatever that a polymorphic bundle could mean) 4) Don't provide concrete implementation for Macro.c (if they do then what is the point?)
* Removing unused code.Paul Phillips2013-10-021-7/+1
| | | | | | | Most of this was revealed via -Xlint with a flag which assumes closed world. I can't see how to check the assumes-closed-world code in without it being an ordeal. I'll leave it in a branch in case anyone wants to finish the long slog to the merge.
* Fix up DEFAULTPARAM semantics.Paul Phillips2013-09-271-1/+1
| | | | | | | | | | | | | | | | | | I foolishly believed the deprecation message on "hasDefaultFlag" which suggested I use "hasDefault" instead. After lots of head scratching, I hardened the semantics so it's like this: - A method parameter with a default value is PARAM | DEFAULTPARAM - A default getter for such a parameter is METHOD | DEFAULTPARAM - And "hasDefault" is has(DEFAULTPARAM) && has(PARAM | METHOD) Why all the bonus logic, why not just hasFlag(DEFAULTPARAM)? For some reason we have a handful of overloaded flags spanning uses which someone apparently thinks can never intersect but I have not been so lucky overall. So since DEFAULTPARAM is overloaded with TRAIT, unless we think it's fine that default getters and method parameters with defaults will pose as traits all the time, there has to be an anchor bit alongside it.
* Revert "Merge pull request #2957 from paulp/pr/parser-improvements"François Garillot2013-09-241-28/+39
| | | | | This reverts commit 884e1ce762d98b29594146d37b85384581d9ba96, reversing changes made to f6fcc4431f272c707d49de68add532c452dd4b0f.
* Merge pull request #2962 from densh/topic/syntactic-assignJason Zaugg2013-09-231-0/+8
|\ | | | | Quasiquotes: add syntactic extractor for assignment-like trees
| * add syntactic extractor for assignment-like treesDen Shabalin2013-09-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | There are three kinds of assign-like trees: 1. Assign(lhs, rhs) // $lhs = $rhs 3. AssignOrNamedArg(lhs, rhs) // $lhs = $rhs 2. Apply(Select(f, nme.update), args :+ rhs) // $f(..$args) = $rhs New syntactic combinator unifies all of them and lets users not to think about these implementations details.
* | SI-7854, SI-6768 better parsing/positioning in parserPaul Phillips2013-09-181-39/+28
| | | | | | | | | | | | | | | | | | | | | | | | The parser hole I found while working on the generated positions serves as the umbrella for a host of improvements. Upgraded positions assigned during some specific challenging situations mostly involving the creation of synthetic trees, e.g. for comprehensions and closures. While doing so improved some error messages. Eliminated some of the most glaring duplication in the parser. It's written like there is some payoff associated with being spectacularly imperative. Not so far.
* | Type housekeeping.Paul Phillips2013-09-181-3/+5
|/ | | | | | | | | | | Moved ListOfNil somewhere more generally accessible. No reason the compiler should hoard it for itself. Flitted to a few locations with constructs like ".head.head" and ".tail.head" looking for code which could be rewritten. Found some, admittedly not always making use of ListOfNil. Made overdue moves of ConstantType(Constant(true|false|null)) to vals in Definitions.
* SI-6489 parsing in macros should provide proper positionsDen Shabalin2013-09-121-0/+6
| | | | | | | | | | | | 1. macro parsing doesn't use toolbox any more but calls parser directly 2. in order for this to work parser has to be refactored to limit usage of currentUnit and rewire it into parser's local unit method which might use currentUnit for some parsers but will user proper unit for UnitParser 3. similar change has to be done to make compilation unit's reporter overridable
* Merge pull request #2910 from densh/topic/quasiquote-improvement-finalJason Zaugg2013-09-111-9/+68
|\ | | | | Various bugfixes and improvements for the quasiquotes
| * first-class early def splicing and extraction supportDen Shabalin2013-09-051-1/+13
| |
| * add support for function type splicing and extractionDen Shabalin2013-09-051-0/+4
| |