summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
...
| * | SI-8388 consistently match type trees by originalsDenys Shabalin2014-03-253-48/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #3656 from densh/si/8387-8350Jason Zaugg2014-03-271-7/+14
|\ \ \ | | | | | | | | SI-8350 SI-8387 tweak handling of new trees
| * | | SI-8387 don't match new as a function applicationDenys Shabalin2014-03-251-4/+9
| | | |
| * | | SI-8350 treat single parens equivalently to no-parens in newDenys Shabalin2014-03-251-3/+5
| | | | | | | | | | | | | | | | | | | | q"new C" and q"new C()" have identical trees after parsing. This commit adds knowledge of this invariant to SyntacticNew.
* | | | SI-8451 quasiquotes now handle quirks of secondary constructorsEugene Burmako2014-03-271-1/+11
| |/ / |/| | | | | | | | | | | | | | Apparently even though the rhs of a secondary constructor looks like an expr, it always gets wrapped in a block by the parser. This works just fine with the typer, but crashes in uncurry. This commit brings quasiquotes in line with the parser.
* | | Merge pull request #3647 from densh/si/8411Jason Zaugg2014-03-252-4/+20
|\ \ \ | | | | | | | | SI-8411 match desugared partial functions
| * | | SI-8411 match desugared partial functionsDenys Shabalin2014-03-222-4/+20
| |/ /
* | | introduces Mirror.typeOfEugene Burmako2014-03-252-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | I just realized that our tag-based shortcuts were incomplete, because they only work with root mirrors (doing just u.typeTag[T].tpe means that the type is going to be resolved in u.rootMirror because that's the default). This commit fixes this oversight. I'm hoping for 2.11.0-RC3, but also feel free to reschedule to 2.12.0-M1 if it becomes clear that RC3 isn't happening.
* | | SI-8200 provide an identity liftable for treesDenys Shabalin2014-03-241-0/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This liftable hasn't been originally included in the set of standard liftables due to following contradiction: 1. On one hand we can have identity lifting that seems to be quite consistent with regular unquoting: q"..${List(1,2)}" <==> q"1; 2" q"${List(1,2)}" <==> q"s.c.i.List(1, 2)" q"..${List(q"a", q"b")}” <==> q"a; b" q"${List(q"a", q"b")}" <==> q"s.c.i.List(a, b)" This is also consistent with how lisp unquoting works although they get lifting for free thanks to homoiconicity: // scala scala> val x = List(q"a", q"b); q"f($x)" q"f(s.c.i.List(a, b))" // scheme > (let [(x (list a b))] `(f ,x)) '(f (list a b)) 2. On the other hand lifting is an operation that converts a value into a code that when evaluated turns into the same value. In this sense Liftable[Tree] means reification of a tree into a tree that represents it, i.e.: q"${List(q"a", q"b")}" <==> q"""s.c.i.List(Ident(TermName("a")), Ident(TermName("b")))""" But I belive that such lifting will be very confusing for everyone other than a few very advanced users. This commit introduces the first option as a default Liftable for trees.
* | Merge pull request #3631 from adriaanm/t4492Adriaan Moors2014-03-161-4/+19
|\ \ | | | | | | SI-4492 More informative error when class not found on classpath
| * | SI-4492 More informative error when class not found on classpathAdriaan Moors2014-03-141-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Position the error based on Select tree that failed to type check, presumably due to an underlying MissingRequirementError, which has no position. There are lots of other ways we could rewrap a MRE and supplement position info, but that remains TODO. Jason's review comment is recorded in the code. Also try to detect the case of a missing module and provide some advice, as well as linking to the forthcoming 2.11 guide at http://docs.scala-lang.org/overviews/core/scala-2.11.html.
* | | Merge pull request #3617 from VladimirNik/typedTreesPrinter-2.11.0-SI-8386Adriaan Moors2014-03-141-2/+3
|\ \ \ | | | | | | | | SI-8386 showCode fails to pretty print application to assign
| * | | SI-8386 fixedVladimirNik2014-03-111-2/+3
| | | |
* | | | Merge pull request #3629 from xeno-by/topic/setter-conflictAdriaan Moors2014-03-141-0/+4
|\ \ \ \ | | | | | | | | | | SI-8086 follow-up that fixes the problem with `setter`
| * | | | SI-8086 follow-up that fixes the problem with `setter`Eugene Burmako2014-03-131-0/+4
| | |/ / | |/| | | | | | | | | | | | | | This is a super-low risk follow-up for 47dba05 that fixes the same problem with a neighboring method.
* / | | SI-8265 Restore 2.10 variance behavior under -Xsource:2.10Paul Phillips2014-03-122-1/+9
|/ / / | | | | | | | | | | | | | | | | | | Issue deprecation warning under -Xsource:2.10 so time travelers can have an authentic deprecation experience before finding that their unsound code no longer compiles in 2.11. The relevant ticket to the soundness issue is SI-6566.
* | | Merge pull request #3615 from retronym/ticket/8376Adriaan Moors2014-03-122-2/+3
|\ \ \ | | | | | | | | SI-8376 Fix overload resolution with Java varargs
| * | | SI-8376 Better type printing for Java varargsJason Zaugg2014-03-101-1/+1
| | | | | | | | | | | | | | | | | | | | `T*` rather than `<repeated>[T]`, as we alreday do for Scala repeated parameters.
| * | | SI-8376 Fix overload resolution with Java varargsJason Zaugg2014-03-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When comparing specificity of two vararg `MethodTypes`, `isAsSpecific` gets to: ``` case mt @ MethodType(_, _) if bothAreVarargs => checkIsApplicable(mt.paramTypes mapConserve repeatedToSingle) ``` The formal parameter type of a Java varargs parameter is represented as `tq"${defintions.JavaRepeatedParamClass}[$elemTp]"`. For a Scala repeated parameter, we instead use `defintions.RepeatedParamClass`. `bothAreVarargs` detects `JavaRepeatedParamClass`, by virtue of: ``` def isRepeatedParamType(tp: Type) = isScalaRepeatedParamType(tp) || isJavaRepeatedParamType(tp) ``` But, `repeatedToSingle` only considers `RepeatedParamClass`. This bug was ostensibly masked in 2.10.3, but became apparent after a not-quite-refactoring in 0fe56b9770. It would be good to pin that change down to a particular line, but I haven't managed that yet.
* | | | Merge pull request #3619 from huitseeker/issue/SI-8392Adriaan Moors2014-03-111-1/+3
|\ \ \ \ | | | | | | | | | | SI-8392 Guards QuasiquoteClass against non-availability in scala-reflect
| * | | | SI-8392 Guards QuasiquoteClass against non-availability in scala-reflectFrançois Garillot2014-03-111-1/+3
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This assimilates behavior on Quasiquotes to the one on Reflection : if we don't have the right resource on classpath, we do without rather than throwing. See the bug report for more on rationale (-Xsource flag, early quasiquote loading in Analyzer through FastTrack, etc). Review by @gkossakowski or @xeno-by
* / | | SI-8366 make partial function and match trees disjointDenys Shabalin2014-03-103-3/+25
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #3594 from densh/si/8331Adriaan Moors2014-03-103-9/+62
|\ \ \ | | | | | | | | SI-8331 make sure type select & applied type doesn't match terms
| * | | Address pull request feedbackDenys Shabalin2014-03-091-4/+10
| | | | | | | | | | | | | | | | | | | | 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-093-9/+56
| |/ / | | | | | | | | | | | | | | | 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.
* / / SI-8367 revert SI-8192's change to primaryConstructor when isJavaDefinedAdriaan Moors2014-03-072-2/+10
|/ / | | | | | | this is some weird stuff
* | SI-8332 implicit class param unquoting in quasiquotesDenys Shabalin2014-03-022-9/+9
| | | | | | | | | | | | A new api that simplifies handling of implicit parameters has been mistakingly supporting just methods parameters. This commit adds support for class parameters too.
* | Fix block construction/deconstruction asymmetryDenys Shabalin2014-02-282-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | Due to the fact that blocks in cases are implicit one might expect to be able to extract its contents with `..$`.
* | Address pull request feedbackDenys Shabalin2014-02-242-3/+3
| |
* | Add ScalaDoc to Quasiquotes and Liftables parts of apiDenys Shabalin2014-02-242-7/+58
| |
* | Merge pull request #3571 from xeno-by/ticket/8321Adriaan Moors2014-02-231-4/+9
|\ \ | | | | | | SI-8321 bundles can't be whitebox
| * | more helpful bundle error messagesEugene Burmako2014-02-211-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment, bundle selection mechanism is pretty picky. If a candidate bundle's parameter isn't either blackbox.Context, whitebox.Context or PrefixType refinement thereof, then it's not a bundle and the user will get a generic error. However we can be a bit more helpful and admit classes that are almost like bundles (looksLikeMacroBundleType), have them fail isMacroBundleType, and then emit a much prettier error message to the user that would tell them that bundles must be monomorphic and their sole parameter should not just be any subtype of blackbox.Context or whitebox.Context.
| * | prohibits polymorphic bundlesEugene Burmako2014-02-211-1/+2
| | | | | | | | | | | | | | | | | | It's not like they were inducing bugs, but I can't see how polymorphism can be useful for macro bundles, hence imho it's better to reduce the number of degrees of freedom of the system.
| * | bundles now reject invalid context typesEugene Burmako2014-02-211-9/+5
| | | | | | | | | | | | | | | Vanilla macros only allow blackbox.Context, whitebox.Context and PrefixType refinements thereof. Bundles should behave in the same way.
| * | SI-8321 whitebox bundles are now recognized as suchEugene Burmako2014-02-211-2/+6
| | | | | | | | | | | | | | | whitebox.Context <: blackbox.Context, so in order to check for blackboxity it's not enough to check whether the context used is <: blackbox.Context.
* | | SI-8324 Fix regression in override checks for sealed classesJason Zaugg2014-02-221-1/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | adeffda25 changed `Symbol#isEffectivelyFinal` to help the optimizer by inferring finality within sealed class hierarchies. However, this change wasn't neccesarily welcome for other clients of that method. In the enclosed test case, we see that overriding checks in `RefChecks` regressed. This commit moves the enhanced version into a new method and selectively uses it in the optimizer (and the tail call optimizer).
* | Merge pull request #3557 from adriaanm/t8224Jason Zaugg2014-02-213-37/+34
|\ \ | | | | | | SI-8224 Fix regression in f-bound aware LUBs
| * | SI-8224 Fix regression in f-bound aware LUBsJason Zaugg2014-02-183-37/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Disable the heuristic approach to recursive bounds unless the compiler is running under `-Xstrict-inference`. [the above was not authored by the original author] In db46c71e88, steps were taken to avoid blowing up in the pathological LUB calculation needed for: def trav = List(List(), Stream()) This skipped a level in the base class sequence when f-bounds were detected at the current level. In that example, when `lublist` was about to: mergePrefixAndArgs( typeOf[LinearSeqOptimized[A, List[A]]], typeOf[LinearSeqOptimized[A, Stream[A]]], ) If it proceeded (as in 2.10.3), the LUB is invalid: error: type arguments [B[_ >: D with C <: B[_ >: D with C <: A]],s.c.immutable.LinearSeq[B[_ >: D with C <: A]] with s.c.AbstractSeq[B[_ >: D with C <: A]] with s.c.LinearSeqOptimized[B[_ >: D with C <: A],s.c.immutable.LinearSeq[A] with s.c.AbstractSeq[A] with s.c.LinearSeqOptimized[A,Immutable with Equals with java.io.Serializable] with java.io.Serializable] with java.io.Serializable] do not conform to trait LinearSeqOptimized's type parameter bounds [+A,+Repr <: s.c.LinearSeqOptimized[A,Repr]] To avoid this, the added code would skip to the first non-F-bounded base type of the same arity of each element in the list. This would get to: LinearSeqLike[D, Stream[D]] LinearSeqLike[C, List[C]] which are lubbable without violating the type constraints. I don't think this was the right remedy. For starters, as seen in this bug report, SI-8224, if the list of types are identical we have let a perfectly good lub slip through our fingers, and end up calculating too general a type. More generally, if the type arguments in f-bounded positions coincide, we don't risk calculating a ill-bounded LUB. Furthermore, the code was widening each of the types separately; this isn't something we want to do within `if (isUniformFrontier)`. AFAICT this was just wasteful and as all `ts0` start with the same type symbol, so `typeConstructorList` should be uniform. This commit restricts this base-class skipping to situations where the argument inferred for an type argument that is used as an f-bound is not: a) an existential (as created by `mergePrefixAndArgs` in invariant positions.), or b) equivalent to one of the corresponding input type arguments (this is the case that fixes the regression in pos/8224.scala)
* | | Merge pull request #3546 from VladimirNik/typedTreesPrinter-2.11.0Jason Zaugg2014-02-215-58/+217
|\ \ \ | | | | | | | | CodePrinter added to Printers 2.11.0
| * | | fixes for wrappingIntoTermVladimirNik2014-02-201-1/+0
| | | |
| * | | block wrapping for trees modifiedVladimirNik2014-02-201-5/+7
| | | |
| * | | block processing fixed for syntactics in typechecked treesVladimirNik2014-02-203-4/+5
| | | |
| * | | printOwners support added to Printers; whitespaces removedVladimirNik2014-02-204-29/+32
| | | |
| * | | move methods for typechecked trees processing to TreeInfoVladimirNik2014-02-203-62/+65
| | | |
| * | | CodePrinter: TypedTreePrinter merged with ParsedTreePrinterVladimirNik2014-02-201-123/+89
| | | |
| * | | lazy vals printing fixed for typechecked treesVladimirNik2014-02-202-14/+20
| | | |
| * | | printers flag processing improvements: printRootPkg flag fixed, comments to ↵VladimirNik2014-02-201-12/+23
| | | | | | | | | | | | | | | | flags metadata printing added
| * | | Attributed val/var processing for syntactics (SI-8180)VladimirNik2014-02-203-33/+201
| | | | | | | | | | | | | | | | | | | | | | | | TypedTreesPrinter added changes based on pull request comments: print root packages flag; tests for syntactics; SyntacticEmptyTypeTree added to Printers
* | | | Merge pull request #3555 from adriaanm/rebase-3553Jason Zaugg2014-02-212-2/+3
|\ \ \ \ | | | | | | | | | | Small Predef cleanup