summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
Commit message (Collapse)AuthorAgeFilesLines
* 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-181-2/+1
| | | | | | | | | | - 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".
* 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`
* Restrict `contextMode` fiddling to `Context`Adriaan Moors2014-07-171-1/+1
| | | | Introduce `initRootContext` to set the relevant bits.
* 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.
* Merge remote-tracking branch 'origin/master' into topic/palladium0Eugene Burmako2014-02-161-65/+61
|\ | | | | | | | | | | | | | | 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.
| * | 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.
* | | addresses pull request feedbackEugene Burmako2014-02-151-0/+1
| | |
* | | some renamingsEugene Burmako2014-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It’s almost 1am, so I’m only scratching the surface, mechanistically applying the renames that I’ve written down in my notebook: * typeSignature => info * declarations => decls * nme/tpnme => termNames/typeNames * paramss => paramLists * allOverriddenSymbols => overrides Some explanation is in order so that I don’t get crucified :) 1) No information loss happens when abbreviating `typeSignature` and `declarations`. We already have contractions in a number of our public APIs (e.g. `typeParams`), and I think it’s fine to shorten words as long as people can understand the shortened versions without a background in scalac. 2) I agree with Simon that `nme` and `tpnme` are cryptic. I think it would be thoughtful of us to provide newcomers with better names. To offset the increase in mouthfulness, I’ve moved `MethodSymbol.isConstructor` to `Symbol.isConstructor`, which covers the most popular use case for nme’s. 3) I also agree that putting `paramss` is a lot to ask of our users. The double-“s” convention is very neat, but let’s admit that it’s just weird for the newcomers. I think `paramLists` is a good compromise here. 4) `allOverriddenSymbols` is my personal complaint. I think it’s a mouthful and a shorter name would be a much better fit for the public API.
* | | 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-6814 adds typechecker modes to c.typecheckEugene Burmako2014-02-141-4/+9
|/ / | | | | | | | | | | | | | | | | | | | | | | | | As per multiple user requests, this commit introduces a shortcut to typecheck trees under multiple different modes: terms (EXPRmode, was exposed in Scala 2.10) and types (TYPEmode). Looking into the rest of a dozen of internal typechecker modes, to the best of my knowledge, I can’t find other modes that we could expose. FUNmode is useful, but very situational. PATTERNmode is useful, but also situational, because we don’t expand macros inside patterns except for whitebox extractor macros. The rest (e.g. POLYmode or TAPPmode) are too low-level.
* | Merge pull request #3406 from xeno-by/ticket/7570Jason Zaugg2014-02-101-11/+36
|\ \ | |/ |/| SI-7570 top-level codegen for toolboxes
| * SI-7570 top-level codegen for toolboxesEugene Burmako2014-01-241-11/+36
| | | | | | | | | | | | | | | | | | Provides a way to inject top-level classes, traits and modules into toolbox universes. Previously that was impossible, because compile and eval both wrap their arguments into an enclosing method of a synthetic module, which makes it impossible to later on refer to any definitions from the outside.
* | renames resetLocalAttrs to resetAttrsEugene Burmako2014-02-071-2/+2
| | | | | | | | | | Now when resetAllAttrs is gone, we can use a shorter name for the one and only resetLocalAttrs.
* | further limits discoverability of resetAttrsEugene Burmako2014-02-071-8/+0
|/ | | | | | | | | | | | | | This commit removes resetAllAttrs from the public reflection API. This method was previously deprecated, but on a second thought that doesn't do it justice. People should be aware that resetAllAttrs is just wrong, and if they have code that uses it, this code should be rewritten immediately without beating around the bush with deprecations. There's a source-compatible way of achieving that (resetLocalAttrs), so that shouldn't bring much trouble. Secondly, resetAllAttrs in compiler internals becomes deprecated. In subsequent commits I'm going to rewrite the only two locations in the compiler that uses it, and then I think we can remove it from the compiler as well.
* deprecates resetAllAttrs and resetLocalAttrs in favor of the new APIEugene Burmako2014-01-211-0/+2
| | | | | | | | | | We now have c.untypecheck, which is supposed to be a counterpart of c.typecheck in the sense that it goes back from typed trees to untyped ones: http://stackoverflow.com/questions/20936509/scala-macros-what-is-the-difference-between-typed-aka-typechecked-an-untyped. Let’s hope that c.untypecheck will soon be able to solve our problems with partially/incorrectly attributed trees emitted by macros: https://groups.google.com/forum/#!topic/scala-internals/TtCTPlj_qcQ.
* typeCheck => typecheckEugene Burmako2013-12-101-3/+3
| | | | | This method has always been slightly bothering me, so I was really glad when Denys asked me to rename it. Let’s see how it pans out.
* Merge pull request #3007 from densh/pull/fresh-name-and-package-supportEugene Burmako2013-10-191-1/+1
|\ | | | | Add support for packages into quasiquotes and toolbox, improve handling of fresh names, unhardcode quasiquote expansion logic
| * SI-6841 SI-6657 add support for packages into quasiquotes and toolboxDen Shabalin2013-10-141-1/+1
| | | | | | | | | | | | In order to implement this a new parser entry point `parseStatsOrPackages` that augments current parseStats with ability to parse "package name { ... }" syntax.
* | synchronizes toolboxesEugene Burmako2013-10-181-1/+2
|/ | | | | We don't guarantee thread-safety of the front end, but everything else looks good now.
* Removing unused code.Paul Phillips2013-10-021-1/+3
| | | | | | | 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.
* Merge pull request #2991 from xeno-by/topic/unapply-copierEugene Burmako2013-09-301-36/+57
|\ | | | | transformers no longer ignore UnApply.fun
| * refactors ToolBoxGlobal wrappersEugene Burmako2013-09-271-64/+74
| | | | | | | | | | | | | | | | | | Centralizes wrappers in a single location and makes it impossible to use the compiler without going through that location. Also fixes the option string tokenization bug that was there for ages. This time I figured out that there's already an implementation of the tokenizer in our compiler, so I just used it :)
| * transformers no longer ignore UnApply.funEugene Burmako2013-09-261-25/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Second time's the charm. I remember trying to do exactly the same somewhen around 2.10.0-M4, but then some continuations tests were failing. Luckily, today everything went smoothly. Please note that this fix changes the way that SI-5465 manifests itself. Previously it produced type errors, now it simply crashes the compiler. Therefore I had to attach the try/catch FatalError clause to invocations of toolbox methods, so that compiler crashes get caught and translated to ToolBoxErrors. Also fixes SI-7871, and that clears the way for implementing quasiquotes with conventional macros rather than relying on a special case in typer.
* | SI-6762 rename emptyValDef to noSelfType.Paul Phillips2013-09-271-1/+1
|/ | | | | Looks like emptyValDef.isEmpty was already changed to return false, so now all that's left is a name which means something.
* Cull extraneous whitespace.Paul Phillips2013-09-181-2/+2
| | | | | | | | | | | | | | | | | | | | | One last flurry with the broom before I leave you slobs to code in your own filth. Eliminated all the trailing whitespace I could manage, with special prejudice reserved for the test cases which depended on the preservation of trailing whitespace. Was reminded I cannot figure out how to eliminate the trailing space on the "scala> " prompt in repl transcripts. At least reduced the number of such empty prompts by trimming transcript code on the way in. Routed ConsoleReporter's "printMessage" through a trailing whitespace stripping method which might help futureproof against the future of whitespace diseases. Deleted the up-to-40 lines of trailing whitespace found in various library files. It seems like only yesterday we performed whitespace surgery on the whole repo. Clearly it doesn't stick very well. I suggest it would work better to enforce a few requirements on the way in.
* refactor variable arity definitionsDen Shabalin2013-09-121-1/+2
| | | | | | Transform current arrays of symbols into function-like objects that return NoSymbol at all places where corresponding arity isn't available.
* SI-6489 parsing in macros should provide proper positionsDen Shabalin2013-09-121-8/+2
| | | | | | | | | | | | 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 remote-tracking branch 'scala/2.10.x'Grzegorz Kossakowski2013-08-291-1/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * currentRun.compiles now correctly works in toolboxesEugene Burmako2013-08-101-1/+4
| | | | | | | | Another random bug uncovered and extinguished when hacking macro annots.
| * SI-7331 tb.parse returns unpositioned treesDen Shabalin2013-08-081-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit gets rid off code wrapping that was previously used by toolbox to get into correct parsing mode. Instead combination of templateStats/accept(EOF) is used. This is the same solution as the one used in repl and built-in scriptRunner This pull request doesn't attempt to generalize this approach in any way and re-use it all over the place due to the caution of possible accidental compatibility breakage. I plan to do it separately against master. Additionally there are a few more changes that make importers be aware of positions and a test for that (via @jedesah).
| * Merge pull request #2506 from scalamacros/ticket/7461Eugene Burmako2013-05-201-1/+1
| |\ | | | | | | c.typeCheck(silent = true) now suppresses ambiguous errors
| | * c.typeCheck(silent = true) now suppresses ambiguous errorsEugene Burmako2013-05-091-1/+1
| | | | | | | | | | | | | | | | | | Otherwise use cases like the one shown in the attached test (trying to typecheck something, which leads to an ambiguous overload error) will mysteriously fail compilation.
| * | [nomaster] removes duplication in inferImplicitValueEugene Burmako2013-05-111-21/+1
| | | | | | | | | | | | Shame-driven development at its best.
| * | [nomaster] SI-7166 catches DivergentImplicit in c.inferImplicitXXXEugene Burmako2013-05-111-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | Despite inferImplicit usually being nice and buffering errors, apparently it can also throw DivergentImplicit exception. This patch catches it and only reports it if silent is set to false. NOTE: we no longer have the DivergentImplicit exception in master, so this commit only makes sense in 2.10.x.
| * | [nomaster] SI-7047 fixes silent for c.inferImplicitXXXEugene Burmako2013-05-111-1/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | silent = true now throws a TypecheckException even if we don't know why an implicit search has failed (i.e. if context.hasErrors is false). NOTE: this commit is a part of a pull request for 2.10.x, which makes sense of implicit macros. Everything in that pull request is [nomaster] due to one reason or another. This commit would work equally well in both 2.10.x and master, but I'm marking it as [nomaster] as well, because I'm anyway going to resubmit the whole pull request into master soon, so there's no reason to introduce additional confusion.
| * Revert SI-6240 synchronization for runtime reflectionAdriaan Moors2013-03-011-29/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit reverts #2083: - 387b2590db runtime reflection: death from thousand threads - 73d079fb38 removes the assertion in missingHook - f4dd56ca5d synchronizes names - dd148de5a8 synchronizes pendingVolatiles - 4cbb9357c5 synchronizes toolboxes - 07bcb6176a SI-7045 reflection now auto-initializes selfType - bebd62d566 optimizes Scala reflection GIL - 735634f1d6 initializes lazy vals and inner objects in advance - 5b37cfb19a introduces GIL to Scala reflection - 981da8edfc cleans up initialization of runtime reflection - b2c2493b22 reflection no longer uses atPhase and friends - a9dca512d8 synchronizes symbols - 0262941b3c removes the crazy extraneous log - 21d5d3820b moves Symbol#SymbolKind to Symbols
| * synchronizes toolboxesEugene Burmako2013-02-111-23/+29
| | | | | | | | | | We don't guarantee thread-safety of the front end, but everything else looks good now.
* | SI-7331 remove all the wrapping code from toolboxDen Shabalin2013-08-141-7/+3
| | | | | | | | | | | | | | | | Change toolbox parsing to use `parseStats` parser entry point instead of current code-wrappign technique that makes positions much less useful to end users. There is also no need to create a compiler `Run` for parsing.
* | moves template creation logic from nsc to reflectDen Shabalin2013-07-081-1/+1
| | | | | | | | | | This routine is going to be necessary in scala-reflect.jar to support ClassDef construction/deconstruction in the upcoming quasiquote patch.
* | SI-7461 c.typeCheck(silent = true) now suppresses ambiguous errorsEugene Burmako2013-05-271-1/+1
| | | | | | | | | | | | Otherwise use cases like the one shown in the attached test (trying to typecheck something, which leads to an ambiguous overload error) will mysteriously fail compilation.
* | Concision contribution.Paul Phillips2013-05-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have lots of core classes for which we need not go through the symbol to get the type: ObjectClass.tpe -> ObjectTpe AnyClass.tpe -> AnyTpe I updated everything to use the concise/direct version, and eliminated a bunch of noise where places were calling typeConstructor, erasedTypeRef, and other different-seeming methods only to always wind up with the same type they would have received from sym.tpe. There's only one Object type, before or after erasure, with or without type arguments. Calls to typeConstructor were especially damaging because (see previous commit) it had a tendency to cache a different type than the type one would find via other means. The two types would compare =:=, but possibly not == and definitely not eq. (I still don't understand what == is expected to do with types.)
* | Merge branch 'master' into HEADPaul Phillips2013-05-161-10/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: SI-7469 Remove @deprecated scala.util.logging SI-3943 Test case for already-fixed Java interop bug Fix formatting for couple of docs in the compiler SI-7476 Add documentation to GenericTraversableTemplate SI-7469 Remove @deprecated scala.util.parsing.ast SI-7469 Remove @deprecated MurmurHash elements SI-7469 Remove deprecated elements in s.u.parsing.combinator SI-7469 Make @deprecated elems in scala.concurrent private[scala] removes duplication in inferImplicitValue SI-7047 fixes silent for c.inferImplicitXXX SI-7167 implicit macros decide what is divergence macroExpandAll is now triggered in all invocations of typed SI-5923 instantiates targs in deferred macro applications SI-6406 Restore deprecated API SI-6039 Harden against irrelevant filesystem details Limit unnecessary calls to Type#toString. fix typo in comment SI-7432 add testcases SI-7432 Range.min should throw NoSuchElementException on empty range AbstractFile.getDirectory does not return null when outDir is "." Conflicts: src/compiler/scala/tools/nsc/typechecker/Typers.scala
| * | removes duplication in inferImplicitValueEugene Burmako2013-05-121-8/+1
| | | | | | | | | | | | This is a port of https://github.com/scala/scala/commit/4e64a2731d from 2.10.x.
| * | SI-7047 fixes silent for c.inferImplicitXXXEugene Burmako2013-05-121-6/+4
| | | | | | | | | | | | This is a port of https://github.com/scala/scala/commit/b4da864247 from 2.10.x.
* | | Started eliminating modes.Paul Phillips2013-05-111-2/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Consolidating the scattered typer state in Context, where it's relatively easy to keep an eye on, rather than threaded throughout the typer in sneaky/sticky bitmasks. The general pattern will be what was once an explicitly passed around bit in Mode becomes an implicitly propagated-as-appropriate bit in Context. In this commit: ALTmode becomes context mode "PatternAlternative" STARmode becomes context mode "StarPatterns" SUPERCONSTRmode becomes context mode "SuperInit"
* | Absolutized paths involving the scala package.Paul Phillips2013-05-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Confusing, now-it-happens now-it-doesn't mysteries lurk in the darkness. When scala packages are declared like this: package scala.collection.mutable Then paths relative to scala can easily be broken via the unlucky presence of an empty (or nonempty) directory. Example: // a.scala package scala.foo class Bar { new util.Random } % scalac ./a.scala % mkdir util % scalac ./a.scala ./a.scala:4: error: type Random is not a member of package util new util.Random ^ one error found There are two ways to play defense against this: - don't use relative paths; okay sometimes, less so others - don't "opt out" of the scala package This commit mostly pursues the latter, with occasional doses of the former. I created a scratch directory containing these empty directories: actors annotation ant api asm beans cmd collection compat concurrent control convert docutil dtd duration event factory forkjoin generic hashing immutable impl include internal io logging macros man1 matching math meta model mutable nsc parallel parsing partest persistent process pull ref reflect reify remote runtime scalap scheduler script swing sys text threadpool tools transform unchecked util xml I stopped when I could compile the main src directories even with all those empties on my classpath.
* | SI-7291: No exception throwing for diverging implicit expansionHubert Plociniczak2013-04-261-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we don't throw exceptions for normal errors it was a bit odd that we don't do that for DivergingImplicit. As SI-7291 shows, the logic behind catching/throwing exception was broken for divergence. Instead of patching it, I rewrote the mechanism so that we now another SearchFailure type related to diverging expansion, similar to ambiguous implicit scenario. The logic to prevent diverging expansion from stopping the search had to be slightly adapted but works as usual. The upside is that we don't have to catch diverging implicit for example in the presentation compiler which was again showing that something was utterly broken with the exception approach.