summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into patmatPaul Phillips2013-08-206-25/+38
|\ | | | | | | | | | | Conflicts: src/compiler/scala/tools/nsc/Global.scala src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
| * No longer crash on NoSymbol.owner.Paul Phillips2013-08-196-25/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Historically calling NoSymbol.owner has crashed the compiler. With this commit, NoSymbol owns itself. This is consistent with the way ownership chains are handled elsewhere in the compiler (e.g. NoContext.owner is NoContext, NoSymbol.enclClass is NoSymbol, and so on) and frees every call site which handles symbols from having to perform precondition tests against NoSymbol. Since calling NoSymbol.owner sometimes (not always) indicates a bug which we'd like to catch sooner than later, I have introduced a couple more methods for selected call sites. def owner: Symbol // NoSymbol.owner is self, log if -Xdev def safeOwner: Symbol // NoSymbol.owner is self, ignore def assertOwner: Symbol // NoSymbol.owner is fatal The idea is that everyone can call sym.owner without undue anxiety or paranoid null-like tests. When compiling under -Xdev calls to `owner` are logged with a stack trace, so any call sites for which that is an expected occurrence should call safeOwner instead to communicate the intention and stay out of the log. Conversely, any call site where crashing on the owner call was a desirable behavior can opt into calling assertOwner. This commit also includes all the safeOwner calls necessary to give us a silent log when compiling scala.
* | An unapplySeq-via-String test.Paul Phillips2013-08-181-1/+2
| | | | | | | | | | | | There are a lot of details yet to be ironed out when it comes to sequences, but at least here's a little evidence that the basic mechanisms work.
* | Refined name-based patmat methods.Paul Phillips2013-08-181-28/+51
| | | | | | | | | | | | | | | | This fleshes out some of the slightly unfinished corners of the adventure, especially for unapplySeq. There's still an unhealthy amount of duplication and a paucity of specification, but I think it's in eminently good shape for a milestone.
* | An Unapplied extractor.Paul Phillips2013-08-171-0/+11
| | | | | | | | | | This makes it a lot less error prone and redundant to find the part you need when unwrapping an UnApply tree.
* | Cleanups in Unapplies.Paul Phillips2013-08-171-0/+8
| |
* | Pushed some noisy logging down to debuglog.Paul Phillips2013-08-172-1/+8
| |
* | Some general purpose methods.Paul Phillips2013-08-173-6/+75
| | | | | | | | Motivated by pattern matcher work, also useful elsewhere.
* | Add some standard names used in pattern matcher.Paul Phillips2013-08-171-0/+3
| |
* | Make memberType less crashy.Paul Phillips2013-08-171-1/+1
| | | | | | | | | | | | | | | | It's a source of constant peril that sym.tpe on NoSymbol is fine (it's NoType) but tpe memberType sym on NoSymbol throws a NSDNHO. The last thing we should be doing is discouraging people from using memberType in favor of sym.tpe, the latter being almost always the wrong thing.
* | Repair NPE in -Ytyper-debug output.Paul Phillips2013-08-171-1/+1
| |
* | Crasher in symbol tracer.Paul Phillips2013-08-171-1/+1
|/
* Merge pull request #2843 from xeno-by/topic/kill-introduce-top-levelAdriaan Moors2013-08-162-109/+1
|\ | | | | kills introduceTopLevel
| * kills introduceTopLevelEugene Burmako2013-08-162-109/+1
| | | | | | | | | | | | | | | | | | | | | | As we've figured out from the practice, introduceTopLevel is seductively useful but unfortunately not robust, potentially bringing compilation order problems. Therefore, as discussed, I'm removing it from the public macro API. Alternatives are either: 1) delving into internals, or 2) using macro paradise and experimenting with macro annotations: http://docs.scala-lang.org/overviews/macros/annotations.html.
* | Merge pull request #2830 from densh/topic/stats-parsing-2Adriaan Moors2013-08-161-4/+6
|\ \ | |/ |/| updated SI-7331, SI-6843, SI-7731, parser entry point refactoring, assertThrows utility function
| * SI-7731 make CannotHaveAttrs more consistentDen Shabalin2013-08-141-4/+6
| | | | | | | | | | | | | | | | | | | | | | Previously setPos, pos_=, setType, tpe_= all behaved inconsistently between each other even though they all represent similar attributes that cannot be changed on CannotHaveAttrs trees. In order to simplify handling of such trees in compiler code each of these fields now supports assignment to its current default value: NoType for tpe and NoPosition for pos. Such assignments don't mutate underlying trees.
* | SI-7624 Replace new{Term,Type}Name with {Term,Type}NameSimon Ochsenreither2013-08-152-8/+8
| |
* | SI-7624 Fix a few remaining -Xlint warnings ...Simon Ochsenreither2013-08-153-17/+18
| | | | | | | | | | in various places. This includes actors, compiler (mostly some new macro parts) continuations, partest, scaladoc, scalap.
* | SI-7624 Fix -feature warnings and build with -featureSimon Ochsenreither2013-08-154-13/+15
|/ | | | | | | | | | | | | | | I added a language.existential import to LazyCombiner.scala which should not be necessary, but causes a spurious warning otherwise: scala/src/library/scala/collection/parallel/mutable/LazyCombiner.scala:33: warning: the existential type scala.collection.parallel.mutable.LazyCombiner[_$1,_$2,_$3] forSome { type _$1; type _$2; type _$3 <: scala.collection.generic.Growable[_$1] with scala.collection.generic.Sizing }, which cannot be expressed by wildcards, should be enabled by making the implicit value scala.language.existentials visible. if (other.isInstanceOf[LazyCombiner[_, _, _]]) { ^ I created ticket SI-7750 to track this issue.
* Merge pull request #2764 from folone/masterGrzegorz Kossakowski2013-08-122-13/+38
|\ | | | | Making map2Conserve occupy constant stack space in spirit of SI-2411.
| * Make map2Conserve occupy constant stack space in spirit of SI-2411George Leontiev2013-08-081-7/+31
| | | | | | | | | | | | | | | | | | | | | | I recently discovered a StackOverflowError, caused by this function: https://gist.github.com/folone/7b2f2e2a16314ab28109 The circumstances are pretty extreme, still having a tail-recursive function seems to be a good idea. The function behaves the same way old function did (supported by tests), which is not really how map2 behaves. I did not change this behavior to not introduce any regression. I actually tried to make it behave like map2, and it does introduce regression.
| * Move map2Conserve to a new home, next to map2.George Leontiev2013-08-082-13/+14
| |
* | DefDef.name is now TermName againEugene Burmako2013-08-102-4/+4
|/ | | | | Now when there's no hope left for type macros, it's reasonable to provide a more specific type for DefDef.name.
* Merge pull request #2776 from gkossakowski/symbolTable-refactoringsGrzegorz Kossakowski2013-08-063-3/+9
|\ | | | | Refactor the cake so SymbolTable does not depend on Global
| * Refactor the cake so SymbolTable does not depend on GlobalGrzegorz Kossakowski2013-07-273-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is rather large commit so I'll first explain the motivation behind it and then go through all changes in detail explaining the choices I made. The motivation behind this refactoring was to make SymbolTable unit testable. I wanted a lightweight way of initializing SymbolTable and then writing unit tests for subtyping algorithm, various functionality related to Symbols, etc. All of that should be possible by precisely controlling what we test, e.g., create types and symbols by hand and not have them defined in source code as we normally do in partest (functional) tests. The other motivation was to reduce and clarify dependencies we have in the compiler. Explicit dependencies lead to cleaner design. Also, explicit and reduces dependencies help incremental compilation which is a big problem for us in compiler's code base at the moment. One of the challenges I faced during that refactoring was cyclic dependency between Platform and SymbolLoaders. Platform depended on `SymbolLoaders.SymbolLoader` because it would define a root loader. SymbolLoaders depended on Platform for numerous reasons like deferring decision how to load a given symbol based on some Platform-specific hooks. I decided to break that cycle by removing methods related to symbol loading from Platform interface. One could argue, that better fix would be to make SymbolLoaders to not depend on Platform (backend) concept but that would be much bigger refactoring. Also, we have a new concept for dealing with symbol loading: Mirrors. For those reasons both `newClassLoader` and `rootLoader` were dropped from Platform interface. Note that JavaPlatform still depends on Global so it can access phases defined in Global to implement `platformPhases` method. Both GenICode and BCodeBodyBuilder have some Platform specific logic that requires casting because pattern matcher doesn't narrow types to give them a proper refinement. Check the changes for details. Some logging utilities has been moved from Global to SymbolTable because they are accessed by SymbolTable. Since Global inherits from SymbolTable this should be a source compatible change. The SymbolLoaders has dependency on `compileLate` method defined in Global. The purpose behind `compileLate` is not clear to me but the dependency looks a little bit dubious. At least we made that dependency explicit. ScaladocGlobal and Global defined in interactive has been adapted in a way that makes them compile both with quick.comp and 2.11.0-M4 so my refactorings are not blocking the modularization effort.
* | Merge pull request #2746 from soc/topic/paulp-typer-debug-outputAdriaan Moors2013-07-294-96/+179
|\ \ | | | | | | Improve type printing (toString/debugging)
| * | Make -Ytyper-debug output readable.Paul Phillips2013-07-172-20/+117
| | |
| * | Cleanups in type printing.Paul Phillips2013-07-172-76/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | More consistency as to how to understand aliases, singletons, specialized symbols, subclasses. Fewer weird special casings, like normalizing tuples and functions during type printing, but nothing else. I avoid "normalize" entirely now, and do not make special cases for dealiasing, which is already well handled when printing error messages. Look at the change to test/files/neg/t2641.check to get a sense of why we should resist calling normalize during the early days of a compilation run. Anonymous and refinement classes can be printed far more usefully by revealing their parents, and that too is here. Hardened toString against undesirable side effects. Make toString final to discourage any further rogue toString overriders. Make safeToString a little safer.
* | | Merge pull request #2758 from soc/SI-7681-dead-code-phasesGrzegorz Kossakowski2013-07-271-11/+8
|\ \ \ | | | | | | | | SI-7681 Remove Phases, clean up TableDef
| * | | SI-7681 Clean up scala.reflect.internal.util.TableDefSimon Ochsenreither2013-07-201-11/+8
| | |/ | |/| | | | | | | ... now that scala.tools.nsc.Phases is gone.
* / | fix typo. s/Universes/Universexuwei-k2013-07-271-2/+2
|/ /
* / Fixing exhaustiveness warnings.Paul Phillips2013-07-171-0/+2
|/ | | | | ClassfileAnnotArg becoming sealed brought tidings of not being exhaustive.
* macro impls can now return subtypes of c.TreeEugene Burmako2013-07-101-4/+2
| | | | | | | | 10229316db allowed macro impls to take and return values of type c.Tree in addition to the usual c.Expr. However it didn't take into account that it is often useful to return subtypes of trees (e.g. with quasiquotes that expand into expressions typed as precisely as possible). This patch fixes that oversight.
* precise return type for FlagsAsBits.unapplyDen Shabalin2013-07-101-1/+1
| | | | | This will help the pattern matcher to emit better code for this kind of extractor that does nothing but wrap the extractee.
* implements quasiquotesDen Shabalin2013-07-088-0/+335
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Additions to the reflection API: - The Quasiquotes implicit class that defines `q`, `tq`, `pq` and `cq` interpolators which now become a part of the `scala.reflect.api. Universe`. - Implementations of the interpolators are macro-based and are hardwired through `FastTrack`. - The `Liftable` class and the `StandardLiftables` slice of the cake that provide a type class and a bunch of its instances that allow to easily splice user-defined types into quasiquotes. - Additional methods in `BuildUtils` that are used by the quasiquote macro to generate trees, notably: - `SyntacticClassDef`. An extractor/constructor that allows to construct and deconstruct classes using arguments that mirror syntactic form of ClassDefs (e.g. constructor outside of the body). - `TupleN`, `TupleTypeN`. Extractor/constructor for easy construction of ast that represents a tuple term or type with given amount of elements. - Actual implementation of quasiquotes in the `scala.tools.reflect. quasiquotes` package which is organized into a cake called `Quasiquotes` with slices introducing core abstractions necessary to splice into Scala syntax, routines for interfacing with the parser, and customized reifiers for tree construction and deconstruction.
* moves template creation logic from nsc to reflectDen Shabalin2013-07-081-0/+76
| | | | | This routine is going to be necessary in scala-reflect.jar to support ClassDef construction/deconstruction in the upcoming quasiquote patch.
* Merge pull request #2693 from lexspoon/semmle-lintAdriaan Moors2013-07-013-2/+14
|\ | | | | Lint-like fixes found by Semmle
| * Adds equals and hashCode to three classes that implement Ordered.Lex Spoon2013-06-261-0/+12
| |
| * Seals some case class hierarchies.Lex Spoon2013-06-261-1/+1
| |
| * Unseal a uselessly sealed case class.Lex Spoon2013-06-261-1/+1
| |
* | Merge pull request #2620 from magarciaEPFL/backendish33Adriaan Moors2013-07-012-0/+41
|\ \ | | | | | | new bytecode emitter, GenBCode (11th attempt)
| * | new bytecode emitter, GenBCode, for now under a flagMiguel Garcia2013-06-012-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GenBCode is a drop-in replacement for GenASM with several advantages: - faster: ICode isn't necessary anymore. Instead, the ASTs delivered by CleanUp (an expression language) are translated directly into a stack-language (ASM Tree nodes) - future-proofing for Java 8 (MethodHandles, invokedynamic). - documentation included, shared mutable state kept to a minimum, all contributing to making GenBCode more maintainable than its counterpart (its counterpart being GenICode + GenASM). A few tests are modified in this commit, for reasons given below. (1) files/neg/case-collision Just like GenASM, GenBCode also detects output classfiles differing only in case. However the error message differs from that of GenASM (collisions may be show in different order). Thus the original test now has a flags file containing -neo:GenASM and a new test (files/neg/case-collision2) has been added for GenBCode. The .check files in each case show expected output. (2) files/pos/t5031_3 Currently the test above doesn't work with GenBCode (try with -neo:GenBCode in the flags file) The root cause lies in the fix to https://issues.scala-lang.org/browse/SI-5031 which weakened an assertion in GenASM (GenBCode keeps the original assertion). Actually that ticket mentions the fix is a "workaround" (3) files/run/t7008-scala-defined This test also passes only under GenASM and not GenBCode, thus the flags file. GenASM turns a bling eye to: An AbstractTypeSymbol (SI-7122) has reached the bytecode emitter, for which no JVM-level internal name can be found: ScalaClassWithCheckedExceptions_1.E1 The error message above (shown by GenBCode) highlights there's no ScalaClassWithCheckedExceptions_1.E1 class, thus shouldn't show up in the emitted bytecode (GenASM emits bytecode that mentions the inexistent class).
* | | Merge pull request #2659 from retronym/ticket/7584Adriaan Moors2013-06-251-2/+9
|\ \ \ | | | | | | | | SI-7584 Fix typer regression with by-name parameter types
| * | | SI-7584 Test and spurious warning fix for by-name closuresJason Zaugg2013-06-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The enclosed test case exercises by-name closures, which were the subject of the previous commit. In the process, a spurious warning was eliminated.
| * | | SI-7584 Fix typer regression with by-name parameter typesJason Zaugg2013-06-161-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It regressed in fada1ef6b#L4L614. Partially reverting just this change restores the correct behaviour: ``` - if (sym.isStable && pre.isStable && !isByNameParamType(tree.tpe) && + if (treeInfo.admitsTypeSelection(tree) && ``` This patch embeds the check for by-name parameter types into `TreeInfo.isStableIdentifier`. That code already checks for `Symbol#isStable`, which exludes direct references to by-name parameters. But the additional check is required to deal with by-name parameters in function types, e.g `(=> Int) => Any`. Open question: should we go further and embed this check in `isStable`? Currently: final def isStable = isTerm && !isMutable && !(hasFlag(BYNAMEPARAM)) && (!isMethod || hasStableFlag) Such function types are an underspecified corner of the language, albeit one that is pretty useful writing, for example, in the signature of a lazy foldRight that can operate over infinite structures: def foldRight[A, B](fa: F[A], z: => B)(f: (A, => B) => B): B The next commit subjects them to a little testing.
* | | | Merge pull request #2667 from adriaanm/modularize-xmlAdriaan Moors2013-06-244-2/+11
|\ \ \ \ | |_|_|/ |/| | | Spin off xml library as scala-library-xml.
| * | | Set scene for Predef.$scope's demise.Jason Zaugg2013-06-204-2/+11
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When there's no Predef.$scope but xml is being used, the compiler aliases scala.xml.TopScope to $scope. There must be a scala.xml package when xml literals were parsed. For compatibility with the old library, which relied on $scope being in scope, synthesize a `import scala.xml.{TopScope => $scope}` when xml is needed, but there's no Predef.$scope and the old library is detected (scala.xml.TopScope exists).
* | | Merge pull request #2653 from retronym/ticket/7433Grzegorz Kossakowski2013-06-231-0/+6
|\ \ \ | | | | | | | | SI-7433 Fix spurious warning about catching control throwable
| * | | SI-7433 Fix spurious warning about catching control throwableJason Zaugg2013-06-231-0/+6
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the same vein as SI-6994, we have to be careful not to warn about synthetic code. In that case, the spurious warnings came because we warned in the typechecker, which was also called in erasure. In this case, we are issuing the warning in Uncurry, so we must be mindful of the pattern matchers translations of non-trivial catch patterns, which look like: case (ex8 @ _) => { <synthetic> val x5: Throwable = ex8; case11(){ if ({ case14(){ if (x5.$isInstanceOf[NullPointerException]()) matchEnd13(true) else case15() }; case15(){ if (x5.$isInstanceOf[RuntimeException]()) matchEnd13(true) else case16() }; case16(){ matchEnd13(false) }; matchEnd13(x: Boolean){ x } }) This commit detects that `ex8` is synthetic and disables the warning.
* | | Merge pull request #2637 from retronym/ticket/7439Paul Phillips2013-06-231-1/+3
|\ \ \ | |/ / |/| | SI-7439 Avoid NPE in `isMonomorphicType` with stub symbols. …