summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/reflect
Commit message (Collapse)AuthorAgeFilesLines
* SI-8040 Warn unused flagsSom Snytt2017-03-111-2/+1
| | | | | | | | | | | | | | | | 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-8040 Heeding -Ywarn-unusedSom Snytt2017-03-111-3/+3
| | | | | | | Polish notation, as in shoe-shine, as recommended by the warning. Minor clean-ups as advocated by `Ywarn-unused` and `Xlint`.
* Uncurry's info transform: non-static module --> methodAdriaan Moors2016-08-111-2/+1
| | | | | | | We do this during uncurry so we can insert the necessary applications to the empty argument list. Fields is too late. Refchecks is no longer an info transform.
* Add since arg to deprecationWarning and use itSimon Ochsenreither2016-05-291-1/+1
|
* Remove abstraction layer in classpath implementationLukas Rytz2016-05-021-2/+2
|
* Refactor flag juggling. Review feedback from Jason.Adriaan Moors2016-03-261-22/+27
| | | | Sometimes booleans and a little duplication go a long way.
* Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-183-6/+4
| | | | | | | | | | - 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 remote-tracking branch 'origin/2.11.x' into 2.12.xSeth Tisue2015-09-081-0/+16
| | | | | | | | 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
* Merge commit '32f520f' into merge/2.11-to-2.12-apr-1Lukas Rytz2015-04-011-1/+1
|\
| * Removed warningsEECOLOR2015-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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`
* | SI-7775 Exclude nulls when iterating sys propsSom Snytt2015-03-021-2/+3
|/ | | | | | | | | | | The previous fix to deal with concurrent modification of system properties doesn't handle null results introduced when a property is removed. This commit filters nulls for safety, and also adds a `names` method to `sys.SystemProperties`. The test is upgraded.
* Cleanup and refactoring - semicolons, unused or commented out codempociecha2014-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit contains some minor changes made by the way when implementing flat classpath. Sample JUnit test that shows that all pieces of JUnit infrastructure work correctly now uses assert method form JUnit as it should do from the beginning. I removed commented out lines which were obvious to me. In the case of less obvious commented out lines I added TODOs as someone should look at such places some day and clean them up. I removed also some unnecessary semicolons and unused imports. Many string concatenations using + have been changed to string interpolation. There's removed unused, private walkIterator method from ZipArchive. It seems that it was unused since this commit: https://github.com/scala/scala/commit/9d4994b96c77d914687433586eb6d1f9e49c520f However, I had to add an exception for the compatibility checker because it was complaining about this change. I made some trivial corrections/optimisations like use 'findClassFile' method instead of 'findClass' in combination with 'binary' to find the class file.
* Integrate flat classpath with the compilermpociecha2014-12-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit integrates with the compiler the whole flat classpath representation build next to the recursive one as an alternative. From now flat classpath really works and can be turned on. There's added flag -YclasspathImpl with two options: recursive (the default one) and flat. It was needed to make the dynamic dispatch to the particular classpath representation according to the chosen type of a classpath representation. There's added PathResolverFactory which is used instead of a concrete implementation of a path resolver. It turned out that only a small subset of path resolvers methods is used outside this class in Scala sources. Therefore, PathResolverFactory returns an instance of a base interface PathResolverResult providing only these used methods. PathResolverFactory in combination with matches in some other places ensures that in all places using classpath we create/get the proper representation. Also the classPath method in Global is modified to use the dynamic dispatch. This is very important change as a return type changed to the base ClassFileLookup providing subset of old ClassPath public methods. It can be problematic if someone was using in his project the explicit ClassPath type or public methods which are not provided via ClassFileLookup. I tested flat classpath with sbt and Scala IDE and there were no problems. Also was looking at sources of some other projects like e.g. Scala plugin for IntelliJ and there shouldn't be problems, I think, but it would be better to check these changes using the community build. Scalap's Main.scala is changed to be able to use both implementations and also to use flags related to the classpath implementation. The classpath invalidation is modified to work properly with the old (recursive) classpath representation after changes made in a Global. In the case of the attempt to use the invalidation for the flat cp it just throws exception with a message that the flat one currently doesn't support the invalidation. And also that's why the partest's test for the invalidation has been changed to use (always) the old implementation. There's added an adequate comment with TODO to this file. There's added partest test generating various dependencies (directories, zips and jars with sources and class files) and testing whether the compilation and further running an application works correctly, when there are these various types of entries specified as -classpath and -sourcepath. It should be a good approximation of real use cases.
* moves the impl of quasiquotes to scala.reflectEugene Burmako2014-09-116-1222/+1
| | | | | | | This brings consistency with scala.reflect.reify and scala.reflect.macros already existing in scala-compiler. To the contrast, scala.tools.reflect, the previous home of quasiquotes, is a grab bag of various stuff without any central theme.
* Restrict `contextMode` fiddling to `Context`Adriaan Moors2014-07-171-1/+1
| | | | Introduce `initRootContext` to set the relevant bits.
* Merge pull request #3858 from densh/si/8703Jason Zaugg2014-07-151-3/+10
|\ | | | | SI-8703 add support for blocks with just a single expression to quasiquotes
| * Address pull request feedbackDenys Shabalin2014-07-141-1/+3
| |
| * SI-8703 add support for blocks with just a single expression to quasiquotesDenys Shabalin2014-07-021-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 }".
* | SI-8608 f-interpolator inlines StringOpsSom Snytt2014-07-141-3/+11
| | | | | | | | | | | | | | | | | | | | | | Instead of "hi".format(), emit new _root_.s.c.i.StringOps("hi").format(), to clarify intent and avoid picking up some other implicit enhancement. A further optimization would be to use String.format directly when that is possible. The ticket says it is not possible for ``` f"${BigDecimal(3.4)}%e" ```
* | SI-8608 f interpolator emits constant stringsSom Snytt2014-07-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When invoking `format` is obviated by a lack of formatting fields, then just degenerate to an unenhanced constant string. This means it doesn't cost anything to use f"$$ordinary" in place of "$ordinary", which may cause warnings under -Xlint. Note that certain format literals, in particular for line separator %n, are not actually literals and can't be replaced at compile time.
* | Rip out reporting indirection from CompilationUnitAdriaan Moors2014-07-041-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inline the forwarders from CompilationUnit, which should not affect behavior. Since all forwarders lead to global.reporter, don't first navigate to a compilation unit, only to then forward back to global.reporter. The cleanup in the previous commits revealed a ton of confusion regarding how to report an error. This was a mechanical search/replace, which has low potential for messing things up, since the list of available methods are disjoint between `reporter` and `currentRun.reporting`. The changes involving `typer.context` were done previously. Essentially, there are three ways to report: - via typer.context, so that reporting can be silenced (buffered) - via global.currentRun.reporting, which summarizes (e.g., deprecation) - via global.reporter, which is (mostly) stateless and straightforward. Ideally, these should all just go through `global.currentRun.reporting`, with the typing context changing that reporter to buffer where necessary. After the refactor, these are the ways in which we report (outside of typer): - reporter.comment - reporter.echo - reporter.error - reporter.warning - currentRun.reporting.deprecationWarning - currentRun.reporting.incompleteHandled - currentRun.reporting.incompleteInputError - currentRun.reporting.inlinerWarning - currentRun.reporting.uncheckedWarning Before: - c.cunit.error - c.enclosingUnit.deprecationWarning - context.unit.error - context.unit.warning - csymCompUnit.warning - cunit.error - cunit.warning - currentClass.cunit.warning - currentIClazz.cunit.inlinerWarning - currentRun.currentUnit.error - currentRun.reporting - currentUnit.deprecationWarning - currentUnit.error - currentUnit.warning - getContext.unit.warning - getCurrentCUnit.error - global.currentUnit.uncheckedWarning - global.currentUnit.warning - global.reporter - icls.cunit.warning - item.cunit.warning - reporter.comment - reporter.echo - reporter.error - reporter.warning - reporting.deprecationWarning - reporting.incompleteHandled - reporting.incompleteInputError - reporting.inlinerWarning - reporting.uncheckedWarning - typer.context.unit.warning - unit.deprecationWarning - unit.echo - unit.error - unit.incompleteHandled - unit.incompleteInputError - unit.uncheckedWarning - unit.warning - v1.cunit.warning All these methods ended up calling a method on `global.reporter` or on `global.currentRun.reporting` (their interfaces are disjoint). Also clean up `TypeDiagnostics`: inline nearly-single-use private methods.
* SI-8637 fixes toolbox phase corruptionEugene Burmako2014-05-301-0/+1
| | | | | | | | | | It turns out, Toolbox.typecheck hasn't been properly re-initializing its state between requests. In particular, globalPhase was left untouched, which made the compiler think that it's past typer, and that in turn disabled implicits. This commit applies a symptomatic fix to this problem.
* Refactor FastTrack to use composition instead of inheritance.Grzegorz Kossakowski2014-05-071-3/+6
| | | | | | | | | | | | | | | | | | Instead of mixing in FastTrack into Macros trait just have a member with an instance of FastTrack. The motivation for this change is to reduce the overall use of inheritance is Scala compiler and FastTrack seems like a nice target for first step. It's an implementation detail of Scala compiler that we are free to modify. Previously, `fastTrack` method would be inherited from FastTrack trait and called from clients (sub classes). The `fastTrack` method returned Map. Now, the `fastTrack` viariable is of type `FastTrack`. In order for clients to continue to work we had to implement three operations called by clients: contains, apply, get. Alternatively, we could keep the `fastTrack` method and import it in clients. This approach is likely to be more common in the future when bigger pieces of code get refactored.
* SI-8466 fix quasiquote crash on recursively iterable unliftingDenys Shabalin2014-04-021-5/+5
| | | | | | | | | | | | | In order to handle unquoting quasiquotes needs to know if type is iterable and whats the depth of the iterable nesting which is called rank. (e.g. List[List[Tree]] is rank 2 iterable of Tree) The logic that checks depth of iterable nesting didn't take a situation where T is in fact Iterable[T] which caused infinite recursion in stripIterable function. In order to fix it stripIterable now always recurs no more than non-optional limit times.
* SI-8388 consistently match type trees by originalsDenys Shabalin2014-03-251-2/+14
| | | | | | | | | | | | Due to the fact that all TypTrees are transformed into TypeTrees during typechecking one couldn't treat typed type trees in the same way as they treat untyped type trees. This change implements support for pattern matching of TypeTrees as their corresponding TypTree equivalent using tree preserved in the original. The implementation itself is a trivial wrapping of regular TypTree extractors into MaybeTypeTreeOriginal.
* SI-8420 don't crash on unquoting of non-liftable native typeDenys Shabalin2014-03-171-2/+4
| | | | | | Previously quasiquote's type-based dispatch failed to handle situation where unquotee's type is native but non-liftable and was used to splice with non-zero cardinality.
* Merge pull request #3598 from som-snytt/issue/8266-amend-adviceAdriaan Moors2014-03-141-1/+2
|\ | | | | SI-8266 Amend advice for deprecated octal 042
| * SI-8266 Amend advice for deprecated octal 042Som Snytt2014-02-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve the advice for `f"\042"` to read: ``` use ${'"'} or a triple-quoted literal """with embedded " or \u0022""" instead. ``` as per the discussion on SI-6476. Knuth says that Charles XII came close to introducing octal arithmetic to Sweden, and Wikipedia doesn't deny it. I imagine an alternative history in which octal literals are deprecated in Scala but required by legislation in Akka. #octal-fan-fiction
* | SI-8366 make partial function and match trees disjointDenys Shabalin2014-03-101-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously one could match a partial function with match quasiquote: scala> val q"$scrutinee match { case ..$cases }" = q"{ case Foo => Bar }" scrutinee: universe.Tree = <empty> cases: List[universe.CaseDef] = List(case Foo => Bar) This was quite annoying as it leaked encoding of partial functions as Match trees with empty tree in place of scrutinee. This commit make sure that matches and partial functions are disjoint and don't match one another (while preserving original encoding under the hood out of sight of the end user.)
* | Merge pull request #3611 from densh/si/8385Adriaan Moors2014-03-102-1/+5
|\ \ | | | | | | SI-8385 make sure $quasiquote$tuple gets reified properly
| * | Move extra tuple placeholder case to reifyTreePlaceholderDenys Shabalin2014-03-101-4/+4
| | |
| * | Update quasiquote debug output minimization passDenys Shabalin2014-03-091-1/+1
| | |
| * | SI-8385 make sure $quasiquote$tuple gets reified properlyDenys Shabalin2014-03-091-0/+4
| | | | | | | | | | | | | | | | | | Previously due to greediness of SyntacticApplied there was a chance that quasiquote tuple placeholder got reified as its representation rather than its meaning.
* | | Address pull request feedbackDenys Shabalin2014-03-091-4/+2
| | | | | | | | | | | | | | | 1. Tighten up the if else to avoid duplication 2. Add doc comments
* | | SI-8331 make sure type select & applied type doesn't match termsDenys Shabalin2014-03-091-0/+7
|/ / | | | | | | | | | | Due to tree re-use it used to be the fact that type quasiquotes could match term trees. This commit makes sure selections and applied type and type applied are all non-overlapping between q and tq.
* | Merge pull request #3592 from densh/si/8281Eugene Burmako2014-03-031-1/+2
|\ \ | | | | | | SI-8281 check for unbound placeholder parameters in quasiquote parser
| * | SI-8281 check for unbound placeholder parameters in quasiquote parserDenys Shabalin2014-02-281-1/+2
| |/
* | SI-8332 implicit class param unquoting in quasiquotesDenys Shabalin2014-03-021-9/+14
| | | | | | | | | | | | A new api that simplifies handling of implicit parameters has been mistakingly supporting just methods parameters. This commit adds support for class parameters too.
* | Merge pull request #3596 from densh/si/8333Eugene Burmako2014-03-011-0/+2
|\ \ | | | | | | SI-8333 can't use modifiers if class is in a block
| * | SI-8333 can't use modifiers if class is in a blockDenys Shabalin2014-02-281-0/+2
| |/ | | | | | | | | | | Was caused by the ordering of parser cases. Need to check for definition first due to the fact that modifiers unquote looks like identifier from parser point of view.
* | Merge pull request #3593 from densh/si/8285Eugene Burmako2014-03-012-9/+7
|\ \ | | | | | | SI-8285 use correct kind of map for quasiquote positions
| * | SI-8285 use correct kind of map for quasiquote positionsDenys Shabalin2014-02-282-9/+7
| |/ | | | | | | | | | | | | Previously mutable.ListMap was used with assumption that it preserved order of inserted elements (but it doesn't). Surprisingly logic that assumed ordered elements worked mosly fine on unordered ones. I guess two bugs can cancel each other out.
* | Fix block construction/deconstruction asymmetryDenys Shabalin2014-02-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | SI-8275 allow to directly extract block contents of the case defDenys Shabalin2014-02-281-0/+2
|/ | | | | Due to the fact that blocks in cases are implicit one might expect to be able to extract its contents with `..$`.
* Fix quasiquote terminology to be consistent with SchemeDenys Shabalin2014-02-204-80/+80
| | | | | | | | | | | | | | | 1. Rename cardinality into rank. Shorter word, easier to understand, more appropriate in our context. 2. Previously we called any dollar substitution splicing but this is not consistent with Scheme where splicing is substitution with non-zero rank. So now $foo is unquoting and ..$foo and ...$foo is unquote splicing or just splicing. Correspondingly splicee becomes unquotee. 3. Rename si7980 test into t7980
* Merge remote-tracking branch 'origin/master' into topic/palladium0Eugene Burmako2014-02-165-99/+172
|\ | | | | | | | | | | | | | | 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
| * Merge pull request #3397 from xeno-by/ticket/5920Jason Zaugg2014-02-161-7/+10
| |\ | | | | | | SI-5920 enables default and named args in macros
| | * introduces -Yshow-symownersEugene Burmako2014-02-101-7/+10
| | | | | | | | | | | | | | | | | | This facility, along with -Yshow-syms, has proven to be very useful when debugging problems caused by corrupt owner chains when hacking on named/default argument transformation.
| * | Merge pull request #3513 from xeno-by/topic/typecheck-member-defsJason Zaugg2014-02-161-56/+48
| |\ \ | | | | | | | | typecheck(q"class C") no longer crashes
| | * | typecheck(q"class C") no longer crashesEugene Burmako2014-02-121-56/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MemberDefs alone can't be typechecked as is, because namer only names contents of PackageDefs, Templates and Blocks. And, if not named, a tree can't be typed. This commit solves this problem by wrapping typecheckees in a trivial block and then unwrapping the result when it returns back from the typechecker.