summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* SI-5744 evidence params are now SYNTHETICUladzimir Abramchuk2013-02-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The macro def <-> macro impl correspondence check compares names of the corresponding parameters in def and impl and reports an error if they don't match. This was originally designed to avoid confusion w.r.t named arguments (which ended up being never implemented as described in SI-5920). Sometimes parameter names are generated by the compiler, which puts the user in a tough position. Luckily, there's an escape hatch built it, which omits the name correspondence check if one of the parameters is SYNTHETIC. Everything went well until we realized that evidences generated by context bounds aren't SYNTHETIC, which led to the bug at hand. Marking auto-generated evidence parameters SYNTHETIC was only the first step, as the correspondence checker uses parameter symbols, not parameter trees. Why's that a problem? Because SYNTHETIC doesn't get propagated from def trees to their underlying symbols (see ValueParameterFlags). Unfortunately one cannot just change ValueParameterFlags, because that would break printouts generated in TypeDiagnostics, which is designed to not print synthetic symbols. Thus we modify methodTypeErrorString in TypeDiagnostics to always print synthetic symbols. Therefore now we propagate all paramSym.flags when doing correspondent sweeps to keep them in sync between def trees and their underlying symbols. This fixes the problem.
* Merge pull request #2094 from scalamacros/ticket/6591James Iry2013-02-083-6/+10
|\ | | | | SI-6591 Reify and path-dependent types
| * accommodates pull request feedbackEugene Burmako2013-02-081-9/+6
| | | | | | | | https://github.com/scala/scala/pull/2072
| * SI-6591 Reify and path-dependent typesDmitry Bushev2013-02-083-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reification scheme changed. Now Select an SelectFromTypeTree trees reified appropriately, as Select and SelectFromTypeTree accordingly. Packages and Predef object was excluded in order not to break the existing reification scheme and not to break tests which rely on it. Reified free terms can contain flag <stable> to make reified values become stable identifiers. For example in the case of reify_newimpl_15.scala class C { type T reify { val v: List[T] = List(2) } } class C reified as free term C$value, and List[C.T] becomes List[C$value().T], so C$value.apply() need to pass stability test isExprSafeToInline at scala.reflect.internal.TreeInfo. For this purpose special case for reified free terms was added to isExprSafeToInline function. test run/reify_newipl_30 disabled due to SI-7082 test t6591_4 moved to pending due to SI-7083
* | Merge pull request #2092 from lrytz/t7096James Iry2013-02-081-13/+29
|\ \ | | | | | | SI-7096 SubstSymMap copies trees before modifying their symbols
| * | SI-7096 SubstSymMap copies trees before modifying their symbolsLukas Rytz2013-02-081-13/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | I removed some strange code in a06d31f6a2 and replaced it by something incorrect: SubstSymMap should never have side-effects: otherwise, calling 'tpe1 <: tpe2' for instance would modify the symbols in annotations of tpe2. SubstSymMap now always creates new trees before changing them.
* | | Merge pull request #2017 from retronym/ticket/6666James Iry2013-02-081-0/+1
|\ \ \ | |_|/ |/| | Booking more progress on SI-6666
| * | Class symbols can't be contravariant.Jason Zaugg2013-02-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During development of the fix for SI-6666, I encountered: % test/files/pos/t4842.scala test/files/pos/t4842.scala:10: error: contravariant class Bar occurs in covariant position in type ()this.Bar of constructor Bar this(new { class Bar { println(Bar.this); new { println(Bar.this) } }; new Bar } ) // okay I had incorrectly set the INCONSTRUCTOR flag on the class symbol `Bar`. (It isn't directly in the self constructor call, as it is nested an intervening anonymous class.) But, this flag shares a slot with CONTRAVARIANT, and the variance validation intepreted it as such. ClassSymbol already has this code to resolve the ambiguous flags for display purposes: override def resolveOverloadedFlag(flag: Long) = flag match { case INCONSTRUCTOR => "<inconstructor>" // INCONSTRUCTOR / CONTRAVARIANT / LABEL case EXISTENTIAL => "<existential>" // EXISTENTIAL / MIXEDIN case IMPLCLASS => "<implclass>" // IMPLCLASS / PRESUPER case _ => super.resolveOverloadedFlag(flag) } This commit overrides `isContravariant` to reflect the same logic.
* | | Merge pull request #2035 from scalamacros/ticket/6989Eugene Burmako2013-02-083-0/+29
|\ \ \ | | | | | | | | SI-6989 privateWithin is now populated in reflect
| * | | SI-6989 privateWithin is now populated in reflectEugene Burmako2013-02-043-0/+29
| | | | | | | | | | | | | | | | | | | | Runtime reflection in JavaMirrors previously forgot to fill in privateWithin when importing Java reflection artifacts. Now this is fixed.
* | | | Merge pull request #2085 from scalamacros/ticket/5824Eugene Burmako2013-02-081-0/+7
|\ \ \ \ | | | | | | | | | | SI-5824 Fix crashes in reify with _*
| * | | | SI-5824 Fix crashes in reify with _*Evgeny Kotelnikov2013-02-071-0/+7
| | | | | | | | | | | | | | | | | | | | Reification crashes if "foo: _*" construct is used. This happens besause type tree is represented either with TypeTree, or with Ident (present case), and `toPreTyperTypedOrAnnotated' only matches of the former. The fix is to cover the latter too. A test is included.
* | | | | Merge pull request #2090 from adriaanm/rebase-pr-2011James Iry2013-02-073-1/+25
|\ \ \ \ \ | | | | | | | | | | | | SI-6187 Make partial functions re-typable
| * | | | | SI-6187 Make partial functions re-typableJason Zaugg2013-02-073-1/+25
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - `New(tpe)` doesn't survive a `resetAttrs` / typecheck; use a name instead. - Abandon the tree attachment that passed the default case from `typer` to `patmat`; this tree eluded the attribute reset performed in the macro. Instead, add it to the match. Apart from making the tree re-typable, it also exposes the true code structure to macros, which is important if they need to perform other code transformations. - Install original trees on the declared types of the parameters of the `applyOrElse` method to ensure that references to them within the method pick up the correct type parameter skolems upon retypechecking. - Propagate `TypeTree#original` through `copyAttrs`, which is called during tree duplication / `TreeCopiers`. Without this, the original trees that we installed were not visible anymore during `ResetAttrs`. We are not able to reify partial functions yet -- the particular sticking point is reification of the parentage which is only available in the `ClassInfoType`.
* | | | | Merge pull request #2088 from retronym/ticket/6146James Iry2013-02-071-3/+48
|\ \ \ \ \ | | | | | | | | | | | | SI-6146 More accurate prefixes for sealed subtypes.
| * | | | | SI-6146 More accurate prefixes for sealed subtypes.Jason Zaugg2013-02-071-3/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When analysing exhaustivity/reachability of type tests and equality tests, the pattern matcher must construct a set of sealed subtypes based on the prefix of the static type of and the set of sealed descendent symbols of that type. Previously, it was using `memberType` for this purpose. In simple cases, this is sufficient: scala> class C { class I1; object O { class I2 } }; object D extends C defined class C defined module D scala> typeOf[D.type] memberType typeOf[C#I1].typeSymbol res0: u.Type = D.I1 But, as reported in this bug, it fails when there is an additional level of nesting: scala> typeOf[D.type] memberType typeOf[c.O.I2 forSome { val c: C }].typeSymbol res5: u.Type = C.O.I2 This commit introduces `nestedMemberType`, which uses `memberType` recursively up the prefix chain prefix chain. scala> nestedMemberType(typeOf[c.O.I2 forSome { val c: C }].typeSymbol, typeOf[D.type], typeOf[C].typeSymbol) res6: u.Type = D.O.Id
* | | | | | Merge pull request #2079 from JamesIry/2.10.x_SI-7070James Iry2013-02-072-3/+0
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-7070 Turn restriction on companions in pkg objs into warning
| * | | | | | SI-7070 Turn restriction on companions in pkg objs into warningJames Iry2013-02-062-3/+0
| | |_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation restriction created from SI-5954 in 3ef487ecb6733bfe3c13d89780ebcfc81f9a5ea0 has two problems. 1) The problematic code works fine if compile with sbt. That means the restriction is breaking some people needlessly. 2) It's not binary compatible. To fix all that this commit changes the error into a warning and removes the setting used to get around the restriction.
* | | | | | Merge pull request #2069 from retronym/ticket/6888James Iry2013-02-071-1/+3
|\ \ \ \ \ \ | |_|_|/ / / |/| | | | | SI-6888 Loosen criteria for $outer search.
| * | | | | SI-6888 Loosen criteria for $outer search.Jason Zaugg2013-02-051-1/+3
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to cater for nested classes with names that end with '$', which lead to ambiguity when unmangling expanded names. In: class X { object $ } We end up with: orginalName(X$$$$$outer) = $$$outer This change modifies `outerSource` to consider that to be and outer accessor name. It is a piecemeal fix, and no doubt there are other nasty surprises in store for those inclined to flash their $$$ in identifier names, but the method changed is not used widely and this solves the reported problem. SI-2806 remains open to address the deeper problem.
* | | | | Merge pull request #2068 from scalamacros/ticket/7064Adriaan Moors2013-02-0710-61/+22
|\ \ \ \ \ | |/ / / / |/| | | | [nomaster] SI-7064 Reflection: forward compat for 2.10.1
| * | | | [nomaster] Revert "refactors handling of parent types"Eugene Burmako2013-02-052-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 40063b0009d55ed527bf1625d99a168a8faa4124. Conflicts: src/compiler/scala/tools/nsc/ast/parser/Parsers.scala src/compiler/scala/tools/nsc/typechecker/Typers.scala
| * | | | [nomaster] Revert "introduces global.pendingSuperCall"Eugene Burmako2013-02-056-32/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 0ebf72b9498108e67c2133c6522c436af50a18e8. Conflicts: src/compiler/scala/tools/nsc/typechecker/Typers.scala src/reflect/scala/reflect/internal/Trees.scala
| * | | | [nomaster] Revert "DummyTree => CannotHaveAttrs"Eugene Burmako2013-02-054-18/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 838cbe623c142b7005446793948097f679219fe3. Conflicts: src/reflect/scala/reflect/api/Trees.scala
| * | | | [nomaster] revives BuildUtils.emptyValDefEugene Burmako2013-02-052-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That method was unnecessary in the first place, because we already had emptyValDef in scala.reflect.api.Trees: https://github.com/scala/scala/blob/v2.10.0/src/reflect/scala/reflect/api/Trees.scala#L2367. That's a rudiment from the times when we were unsure what to put into scala.reflect.base and what goes into scala.reflect.api. Unfortunately, it's not just a harmless extraneous method. Reifier v2.10.0 emits `u.build.emptyValDef` when it needs to reify `emptyValDef`. Therefore we need to restore it to be forward compatible. However we don't need to rollback the changes to the reifier v2.10.1, which now simply calls `u.emptyValDef`, because, as mentioned above, that `emptyValDef` was already there in v2.10.0.
| * | | | [nomaster] removes Tree.canHaveAttrsEugene Burmako2013-02-051-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | This forward compatibility fix is very easy. Have a new method in 2.10.1? Don't expose it in the public API, and you won't have any problems.
| * | | | [nomaster] doesn't touch NonemptyAttachmentsEugene Burmako2013-02-051-0/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | NonemptyAttachments in macro API used to be Attachments$NonemptyAttachments. However it's private, so noone outside scala.reflect.macros can access it, making it ineligible for the incompatibility criterion.
* | | | Merge pull request #2062 from JamesIry/2.10.x_SI-5833Adriaan Moors2013-02-041-2/+2
|\ \ \ \ | | | | | | | | | | SI-5833 Fixes tail-of-Nil problem in RefinedType#normalizeImpl
| * | | | SI-5833 Fixes tail-of-Nil problem in RefinedType#normalizeImplJames Iry2013-02-041-2/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | RefinedType#normalizeImpl was checking to see if the flattened list of parents had an empty tail then pulling the head if so. But if the list was empty then boom. This fix makes it check if the whole list has length 1 instead. Empty lists will flow through to the rest the logic which has no problems with Nil.
* | | | Merge pull request #2040 from scalamacros/ticket/7008Adriaan Moors2013-02-042-3/+22
|\ \ \ \ | |/ / / |/| | | SI-7008 @throws annotations are now populated in reflect
| * | | pullrequest feedbackEugene Burmako2013-02-042-6/+6
| | | | | | | | | | | | | | | | https://github.com/scala/scala/pull/2040
| * | | SI-7008 @throws annotations are now populated in reflectEugene Burmako2013-02-012-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Runtime reflection in JavaMirrors previously forgot to fill in @throws when importing Java reflection artifacts. Now this is fixed. Note that generic exception types used in `throws` specifications will be garbled (i.e. erased), because we don't use `getGenericExceptionTypes` in favor of just `getExceptionTypes` to stay compatible with the behavior of ClassfileParser. That's a bug, but a separate one and should be fixed separately. Also note that this commit updated javac-artifacts.jar, because we need to test how reflection works with javac-produced classfiles. The sources that were used to produce those classfiles can be found in the jar next to the classfiles.
* | | | Merge pull request #2039 from scalamacros/ticket/7046Eugene Burmako2013-02-041-1/+5
|\ \ \ \ | | | | | | | | | | SI-7046 reflection now auto-initializes knownDirectSubclasses
| * | | | SI-7046 reflection now auto-initializes knownDirectSubclassesEugene Burmako2013-01-311-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | knownDirectSubclasses joins the happy family of flags, annotations and privateWithin, which automatically trigger initialization, when used within runtime reflection.
* | | | | Merge pull request #2022 from lrytz/analyzerPlugins210Lukas Rytz2013-02-035-127/+106
|\ \ \ \ \ | | | | | | | | | | | | Analyzer Plugins
| * | | | | Analyzer PluginsLukas Rytz2013-02-031-91/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AnnotationCheckers are insufficient because they live outside the compiler cake and it's not possible to pass a Typer into an annotation checker. Analyzer plugins hook into important places of the compiler: - when the namer assigns a type to a symbol (plus a special hook for accessors) - before typing a tree, to modify the expected type - after typing a tree, to modify the type assigned to the tree Analyzer plugins and annotation checker can be activated only during selected phases of the compiler. Refactored the CPS plugin to use an analyzer plugin (since adaptToAnnotations is now part of analyzer plugins, no longer annotation checkers).
| * | | | | SI-1803, plus documentation and cleanups in Namers, mainly in typeSigLukas Rytz2013-02-032-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - when typing (and naming) a ValDef, tpt and rhs are now type checked in the same context (the inner / ValDef context). this does not change any behavior, but is more uniform (same as for DefDef). martin told me (offline) that this change is desirable if it doesn't break anything. (it doesn't). - typeSig is now more uniform with a separate method for each case (methodSig, valDefSig, etc). methodSig was cleaned up (no more variables) and documented. the type returned by methodSig no longer contains / refers to type skolems, but to the actual type parameters (so we don't need to replace the skolems lateron). - documentation on constructor contexts, type skolems - more tests for SI-5543
| * | | | | Keep annotations when computing lubsLukas Rytz2013-02-031-17/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Integrates annotationsLub into lub. Also fixes SubstSymMap when mapping over annotaion trees. I don't understand what the previous code was supposed to achieve, but it crashed in some of my examples.
| * | | | | Allow for Function treess with refined types in UnCurry.Lukas Rytz2013-02-031-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also removes an unnecessary condition in UnCurry, isFunctionType(fun.tpe) is always true.
| * | | | | replace symbols correctly when subtyping dependent typesLukas Rytz2013-02-031-1/+1
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as discussed in [1], this change has no impact on the scala type system, but it can fix subtyping for annotation checkers if the pluggable type system supports annotations that can refer to method parameters. [1] https://groups.google.com/forum/#!topic/scala-internals/kSJLzYkmif0/discussion
* | | | | Merge pull request #1976 from retronym/backport/1468James Iry2013-02-031-0/+11
|\ \ \ \ \ | | | | | | | | | | | | [backport] SI-6428 / SI-7022 Value class with bounds
| * | | | | [backport] SI-6482, lost bounds in extension methods.Jason Zaugg2013-02-021-0/+11
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Squashed commit of the following: commit 5c156185306ba797c0443d9dccae0ae7ce462a1f Author: Paul Phillips <paulp@improving.org> Date: Sat Oct 6 15:42:50 2012 -0700 A little more housecleaning in ExtensionMethods. The only real contribution is readability. (cherry picked from commit 61f12faacaaccf366f9211ba6493fb042a91f1d2) Conflicts: src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala commit 79f443edf584745d614e24fb9ca6644c6b18d439 Author: Paul Phillips <paulp@improving.org> Date: Sat Oct 6 14:22:19 2012 -0700 Incorporated pull request feedback. (cherry picked from commit 153ccb4757718cceb219988f30381f73362e6075) commit 707f580b0cdcb01e27ca4c76991dea427945b5bd Author: Paul Phillips <paulp@improving.org> Date: Sat Oct 6 10:20:45 2012 -0700 Fix for SI-6482, lost bounds in extension methods. That was a good one. How to create a new method with type parameters from multiple sources, herein. (cherry picked from commit ff9f60f420c090b6716c927ab0359b082f2299de) commit 8889c7a13f74bc175e48aa2209549089a974c2af Author: Paul Phillips <paulp@improving.org> Date: Fri Oct 5 22:19:52 2012 -0700 Responded to comment about how many isCoercibles there are. I make the case that there is only one. (cherry picked from commit 883f1ac88dd7cec5882d42d6b48d7f267d1f6e00)
* | | | | Merge pull request #2019 from scalamacros/ticket/6539Eugene Burmako2013-02-014-17/+34
|\ \ \ \ \ | |/ / / / |/| | | | SI-6539 moves @compileTimeOnly away from scala-reflect
| * | | | SI-6539 moves @compileTimeOnly away from scala-reflectEugene Burmako2013-01-314-17/+34
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | The move is done to provide forward compatibility with 2.10.0. The annotation isn't replaced with one of the macro-based solutions right away (see comments for more information about those), because we lack necessary tech in 2.10.x.
* | | | Merge pull request #2015 from paulp/rc1-backportsPaul Phillips2013-01-312-12/+45
|\ \ \ \ | | | | | | | | | | 10 backports
| * | | | SI-5604, selections on package objects.Paul Phillips2013-01-301-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [backport] mkAttributedSelect, which creates a Select tree based on a symbol, has been a major source of package object bugs, because it has not been accurately identifying selections on package objects. When selecting foo.bar, if foo turns out to be a package object, the created Select tree must be foo.`package`.bar However mkAttributedSelect was only examining the owner of the symbol, which means it would work if the package object defined bar directly, but not if it inherited it.
| * | | | SI-5859, inapplicable varargs.Paul Phillips2013-01-301-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | [backport] And other polishing related to varargs handling.
| * | | | SI-5130, precision disappearing from refinement.Paul Phillips2013-01-301-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | [backport] Remove some code, win a prize.
| * | | | SI-4729, overriding java varargs in scala.Paul Phillips2013-01-301-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [backport] This was a bad interaction between anonymous subclasses and bridge methods. new Foo { override def bar = 5 } Scala figures it can mark "bar" private since hey, what's the difference. The problem is that if it was overriding a java-defined varargs method in scala, the bridge method logic says "Oh, it's private? Then you don't need a varargs bridge." Hey scalac, you're the one that made me private! You made me like this! You! Conflicts: src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
* | | | | Merge pull request #2021 from gkossakowski/issue/SI-7009Grzegorz Kossakowski2013-01-311-1/+14
|\ \ \ \ \ | |_|_|/ / |/| | | | SI-7009: `@throws` annotation synthesized incorrectly