summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #4097 from retronym/ticket/7602Jason Zaugg2014-11-071-1/+3
|\ | | | | SI-7602 Avoid crash in LUBs with erroneous code
| * SI-7602 Avoid crash in LUBs with erroneous codeJason Zaugg2014-11-071-1/+3
| | | | | | | | | | | | | | | | | | If a class contains a double defintion of a method that overrides an interface method, LUBs could run into a spot where filtering overloaded alternatives to those that match the interface method fails to resolve to a single overload, which crashes the compiler. This commit uses `filter` rather than `suchThat` to avoid the crash.
* | Merge pull request #4083 from retronym/ticket/8947Jason Zaugg2014-11-071-0/+8
|\ \ | | | | | | SI-8947 Avoid cross talk between tag materializers and reify
| * | SI-8947 Additional layers of defence against EmptyTree mutationJason Zaugg2014-11-061-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As suggested in review: - Use `abort` rather than `{error; EmptyTree} when we hit an error in reification or tag materialization. - Explicitly avoid adding the `MacroExpansionAttachment` to the macro expansion if it an `EmptyTree` - Emit a `-Xdev` warning if any other code paths find a way to mutate attachments in places they shouldn't.
| * | SI-8947 Avoid cross talk between tag materializers and reifyJason Zaugg2014-10-301-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a macro has been expanded, the expandee are expansion are bidirectionally linked with tree attachments. Reify uses the back reference to replace the expansion with the expandee in the reified tree. It also has some special cases to replace calls to macros defined in scala-compiler.jar with `Predef.implicitly[XxxTag[T]]`. This logic lives in `Reshape`. However, the expansion of a macro may be `EmptyTree`. This is the case when a tag materializer macro fails. User defined macros could do the also expand to `EmptyTree`. In the enclosed test case, the error message that the tag materializer issued ("cannot materialize class tag for unsplicable type") is not displayed as the typechecker finds another means of making the surrounding expression typecheck. However, the macro engine attaches a backreference to the materializer macro on `EmpytyTree`! Later, when `reify` reshapes a tree, every occurance of `EmptyTree` will be replaced by a call to `implicitly`. This commit expands the domain of `CannotHaveAttrs`, which is mixed in to `EmptyTree`. It silently ignores all attempts to mutate attachments. Unlike similar code that discards mutations of its type and position, I have refrained from issuing a developer warning in this case, as to silence this I would need to go and add a special case at any places adding attachments.
* | | Merge pull request #4093 from lrytz/t8960Lukas Rytz2014-11-061-1/+1
|\ \ \ | |_|/ |/| | SI-8960 Bring back the SerialVersionUID to anonymous function classes
| * | SI-8960 Bring back the SerialVersionUID to anonymous function classesLukas Rytz2014-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In PR #1673 / 4267444, the annotation `SerialVersionId` was changed from a `StaticAnnotation` to `ClassFileAnnotation` in order to enforce annotation arguments to be constants. That was 2.11.0. The ID value in the AnnotationInfo moved from `args` to `assocs`, but the backend was not adjusted. This was fixed in PR #3711 / ecbc9d0 for 2.11.1. Unfortunately, the synthetic AnnotationInfo that is added to anonymous function classes still used the old constructor (`args` instead of `assocs`), so extracting the value failed, and no field was added to the classfile.
* | | Merge pull request #4089 from gourlaysama/wip/t6626-scaladoc-throws-linksVlad Ureche2014-11-053-5/+5
|\ \ \ | | | | | | | | SI-6626 make @throws tags create links to exceptions
| * | | cleanup @throws tags in library and reflectAntoine Gourlay2014-11-053-5/+5
| |/ / | | | | | | | | | | | | - there is no need for explicit links with [[ and ]] - there is no need for explicit backquoting
* | | Merge pull request #4017 from lrytz/t6541Lukas Rytz2014-11-051-0/+1
|\ \ \ | | | | | | | | SI-6541 valid wildcard existentials for case-module-unapply
| * | | SI-6541 valid wildcard existentials for case-module-unapplyLukas Rytz2014-11-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of letting the compiler infer the return type of case module unapply methods, provide them explicitly. This is enabled only under -Xsource:2.12, because the change is not source compatible.
* | | | Merge pull request #4054 from soc/SI-8916Lukas Rytz2014-11-0410-13/+2
|\ \ \ \ | |_|/ / |/| | | SI-8916 Clean up unused imports, values and variables
| * | | SI-8916 Fix -Ywarn-unused-import warningsSimon Ochsenreither2014-10-2410-13/+2
| | |/ | |/|
* | | Merge pull request #4036 from retronym/topic/opt-tail-callsJason Zaugg2014-11-041-0/+4
|\ \ \ | | | | | | | | SI-8893 Restore linear perf in TailCalls with nested matches
| * | | Optimize tail calls to avoid findMember callsJason Zaugg2014-10-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cache the member symbols for `Boolean.{||, &&}` per-run, rather than look them up repeatedly. Based on profiling the tail calls phase in the program below, which was distilled by @rmacleod2 from the code generated by macros in https://github.com/paytronix/utils-open/tree/release/2014/ernststavrosgrouper Wall clock time went from 12s to 6.5s. ```scala object Test { def a(): Option[String] = Some("a") def main(args: Array[String]) { a() match { case Some(b1) => a() match { case Some(b2) => a() match { case Some(b3) => a() match { case Some(b4) => a() match { case Some(b5) => a() match { case Some(b6) => a() match { case Some(b7) => a() match { case Some(b8) => a() match { case Some(b9) => a() match { case Some(b10) => a() match { case Some(b11) => a() match { case Some(b12) => a() match { case Some(b13) => a() match { case Some(b14) => a() match { case Some(b15) => a() match { case Some(b16) => a() match { case Some(b17) => a() match { case Some(b18) => a() match { case Some(b19) => a() match { case Some(b20) => println("yay") case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } case None => None } } } ```
* | | | Merge pull request #4045 from gourlaysama/wip/t8875-show-codeJason Zaugg2014-11-041-1/+1
|\ \ \ \ | | | | | | | | | | SI-8875 showCode should print all class constructor modifiers.
| * | | | SI-8875 showCode should print all class constructor modifiers.Antoine Gourlay2014-10-241-1/+1
| |/ / / | | | | | | | | | | | | | | | | showCode used to print nothing when the only modifier was a change in visibility scope (i.e. no flags but privateWithin is set).
* | | | Merge pull request #4064 from xuwei-k/typo-representationJason Zaugg2014-11-041-1/+1
|\ \ \ \ | |_|_|/ |/| | | fix typo. s/represenation/representation
| * | | fix typo. s/represenation/representationxuwei-k2014-10-201-1/+1
| |/ /
* | | Merge pull request #4043 from retronym/ticket/3439-2Jason Zaugg2014-11-021-0/+7
|\ \ \ | | | | | | | | SI-3439 Fix use of implicit constructor params in super call
| * | | SI-3439 Fix use of implicit constructor params in super callJason Zaugg2014-10-101-0/+7
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When typechecking the primary constructor body, the symbols of constructor parameters of a class are owned by the class's owner. This is done make scoping work; you shouldn't be able to refer to class members in that position. However, other parts of the compiler weren't so happy about this arrangement. The enclosed test case shows that our checks for invalid, top-level implicits was spuriously triggered, and implicit search itself would fail. Furthermore, we had to hack `Run#compiles` to special case top-level early-initialized symbols. See SI-7264 / 86e6e9290. This commit: - introduces an intermediate local dummy term symbol which will act as the owner for constructor parameters and early initialized members - adds this to the `Run#symSource` map if it is top level - simplifies `Run#compiles` accordingly - tests this all in a top-level class, and one nested in another class.
* | | Merge pull request #4040 from retronym/ticket/8871Jason Zaugg2014-11-022-10/+9
|\ \ \ | |_|/ |/| | FSC / REPL Bug Bonanza
| * | SI-6613 Make Java enums work in FSC / REPLJason Zaugg2014-10-091-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We needed to hop from the enum's owner to its companion module in an early phase of the compiler. The enclosed test used to fail when this lookup returned NoSymbol on the second run of the resident compiler when triggered from `MixinTransformer`: the lookup didn't work after the flatten info transform. This is related to the fact that module classes are flattened into the enclosing package, but module accessors remain in the enclosing class.
| * | SI-8871 Fix specialization under REPL / FSCJason Zaugg2014-10-091-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The transformation of applications to specialized methods relies on the owner of said method having had the specialization info transform run which stashes a bunch of related data into per-run caches such as `SpecializeTypes#{typeEnv}`. Recently, we found that per-run caches didn't quite live up to there name, and in fact weren't being cleaned up before a new run. This was remedied in 00e11ff. However, no good deed goes unpunished, and this led to a regression in specialization in the REPL and FSC. This commit makes two changes: - change the specialization info tranformer to no longer directly enter specialized methods into the `info` of whatever the current phase happens to be. This stops them showing up `enteringTyper` of the following run. - change `adaptInfos` to simply discard all but the oldest entry in the type history when bringing a symbol from one run into the next. This generalizes the approach taken to fix SI-7801. The specialization info transformer will now execute in each run, and repopulate `typeEnv` and friends. I see that we have a seemingly related bandaid for this sort of problem since 08505bd4ec. In a followup, I'll try to revert that.
* | | SI-8907 Don't force symbol info in isModuleNotMethodLukas Rytz2014-10-151-22/+22
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | Test case by Jason. RefChecks adds the lateMETHOD flag lazily in its info transformer. This means that forcing the `sym.info` may change the value of `sym.isMethod`. 0ccdb151f introduced a check to force the info in isModuleNotMethod, but it turns out this leads to errors on stub symbols (SI-8907). The responsibility to force info is transferred to callers, which is the case for other operations on symbols, too.
* | SI-8894 dealias when looking at tuple componentsAdriaan Moors2014-10-081-1/+2
| | | | | | | | | | | | | | Classic bait-and-switch: `isTupleType` dealiases, but `typeArgs` does not. When deciding with `isTupleType`, process using `tupleComponents`. Similar for other combos. We should really enforce this using extractors, and only decouple when performance is actually impacted.
* | SI-4788/SI-5948 Respect RetentionPolicy of Java annotationsSimon Ochsenreither2014-10-072-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note that I removed the check to ignore @deprecated: - @deprecated extends StaticAnnotation, so they aren't supposed to show up in the RuntimeInvisibleAnnotation attribute anyway, and the earlier check for "extends ClassfileAnnotationClass" makes this check superflous anyway. - Otherwise, if @deprecated was extending ClassfileAnnotationClass it would seem inconsistent that we don't emit @deprecated, but would do so for @deprecatedOverriding, @deprecatedInheritance, etc. Anyway, due to ClassfileAnnotation not working in Scala, and the additional check which only allows Java-defined annotations, this is pretty pointless from every perspective.
* | SI-8843 AbsFileCL acts like a CLSom Snytt2014-10-062-41/+31
|/ | | | | | | | | | | | | | | | | | | | | | Let the AbstractFileClassLoader override just the usual suspects. Normal delegation behavior should ensue. That's instead of overriding `getResourceAsStream`, which was intended that "The repl classloader now works more like you'd expect a classloader to." (Workaround for "Don't know how to construct an URL for something which exists only in memory.") Also override `findResources` so that `getResources` does the obvious thing, namely, return one iff `getResource` does. The translating class loader for REPL only special-cases `foo.class`: as a fallback, take `foo` as `$line42.$read$something$foo` and try that class file. That's the use case for "works like you'd expect it to." There was a previous fix to ensure `getResource` doesn't take a class name. The convenience behavior, that `classBytes` takes either a class name or a resource path ending in ".class", has been promoted to `ScalaClassLoader`.
* Merge pull request #4010 from lrytz/t8087Jason Zaugg2014-10-011-5/+12
|\ | | | | SI-8087 keep annotations on mixed-in private[this] fields
| * SI-8087 keep annotations on mixed-in private[this] fieldsLukas Rytz2014-09-301-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related to SI-2511 / eea7956, which fixed the same issue for non `private[this]` fields. If you have trait T { private[this] val f = 0 } class C extends T Mixin geneartes an accessor method `T.f` with owner `T`. When generating the field in `C`, the Mixin.mixinTraitMembers calls `fAccessor.accessed`. The implementation of `accessed` does a lookup for a member named `"f "` (note the space). The bug is that `private[this]` fields are not renamed to have space (`LOCAL_SUFFIX_STRING`) in their name, so the accessed was not found, and no annotations were copied from it.
* | SI-8868 Fix unpickling of local dummy symbolsJason Zaugg2014-09-301-2/+10
|/ | | | | | | | | | | | These pop up as the owner of symbols in annotation arguments, such as the ones introduced by the names/defaults desugaring. The first two test cases here motivate the two patches to Unpicker. The third requires both fixes, but exploits the problem directly, without using `@deprecated` and named arguments. See also 14fa7be / SI-8708 for a recently remedied kindred bug.
* Merge pull request #3980 from retronym/ticket/8844Lukas Rytz2014-09-171-1/+1
|\ | | | | SI-8844 Fix regression with existentials + type aliases
| * SI-8844 Fix regression with existentials + type aliasesJason Zaugg2014-09-131-1/+1
| | | | | | | | | | | | Regressed in 2a1b15e / SI-8283. Another specimen of an archetypal bug: unwanted dealising by using `typeSymbol`, rather than `typeSymbolDirect`.
* | isAnonymousClass/Function for delambdafy classes is not trueLukas Rytz2014-09-122-11/+13
|/ | | | | | | | | | | | | Ydelambdafy:method lambda classes are not anonymous classes, and not anonymous function classes either. They are somethig new, so there's a new predicate isDelambdafyFunction. They are not anonymous classes (or functions) because anonymous classes in Java speak are nested. Delambdafy classes are always top-level, they are just synthetic. Before this patch, isAnonymous was sometimes accidentailly true: if the lambda is nested in an anonymous class. Now it's always false.
* Merge pull request #3935 from lrytz/t8803Jason Zaugg2014-09-051-1/+1
|\ | | | | SI-8803 generate super accessor for super[A], if A is outer superclass
| * SI-8803 generate super accessor for super[A], if A is outer superclassLukas Rytz2014-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | class C extends A with T { class I { C.super[T] C.super[A] } } A super call in a nested class of the form super[T] where T is a parent trait of the outer class doesn't need an accessor: mixin can directly re-route the call to the correct implementation class - it's statically known to be T$class. However, if a nested class accesses super[A] and A is the superclass of the outer class (not a trait), then we need a super accessor in the outer class. We need to add the mixin name to the super accessor name, otherwise it clashes with non-qualified super accessors.
* | Merge pull request #3956 from gourlaysama/wip/interp-warnGrzegorz Kossakowski2014-09-022-3/+3
|\ \ | | | | | | fix a few string interpolation typos
| * | SI-7931 fix Dscala.repl.vids and some string interpolation typosAntoine Gourlay2014-09-022-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | That nice little `-Dscala.repl.vids` feature regressed in f56f9a3c when a string.format was replaced by string interpolation. The ones in scala-reflect were caught by Xlint (who knew building with Xlint was actually useful...), the other was just luck.
* | | Merge pull request #3948 from retronym/ticket/8823Grzegorz Kossakowski2014-09-021-1/+1
|\ \ \ | | | | | | | | SI-8823 Exclude specialized methods from extension method rewrite
| * | | SI-8823 Exclude specialized methods from extension method rewriteJason Zaugg2014-08-271-1/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a value class extends a specialized class, it can sprout specialized members after the specialization info transformer has run. However, we only install extension methods for class members we know about at the extmethods phase. This commit simply disables rewiring calls to these methods in erasure to an extention method. This follows the approach taken from super accessors. Note: value class type parameters themselves currently are not allowed to be specialized.
* | | Merge pull request #3931 from lrytz/opt/tracked-finalLukas Rytz2014-09-012-35/+10
|\ \ \ | |/ / |/| | GenBCode refactoring (remove Tracked) and fix InnerClass / EnclosingMethod attributes
| * | Fix InnerClass / EnclosingMethod attributesLukas Rytz2014-09-012-35/+10
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit seems bigger than it is. Most of it is tests, and moving some code around. The actual changes are small, but a bit subtle. The InnerClass and EnclosingMethod attributes should now be close to the JVM spec (which is summarized in BTypes.scala). New tests make sure that changes to these attributes, and changes to the way Java reflection sees Scala classfiles, don't go unnoticed. A new file, BCodeAsmCommon, holds code that's shared between the two backend (it could hold more, future work). In general, the difficulty with emitting InnerClass / EnclosingMethod is that we need to find out source-level properties. We need to make sure to do enough phase-travelling, and work around destructive changes to the ownerchain in lambdalift (we use originalOwner a lot). The change to JavaMirrors is prompted by the change to the EnclosingMethod attribute, which changes Java reflection's answer to getEnclosingMethod and getEnclosingConstructor. Classes defined in field initializers no longer have an enclosing method, just an enclosing class, which broke an assumption in JavaMirrors. There's one change in erasure. Before this change, when an object declaration implements / overrides a method, and a bridge is required, then the bridge method was actually a ModuleSymbol (it would get the lateMETHOD flag and be emitted as a method anyway). This is confusing, when iterating through the members of a class, you can find two modules with the same name, and one of them doesn't have a module class. Now, such bridge methods will be MethodSymbols. Removed Symbol.originalEnclosingMethod, that is a backend thing and doesn't need to live in the symbol API.
* | Merge pull request #3929 from retronym/ticket/8793Lukas Rytz2014-08-261-2/+8
|\ \ | | | | | | SI-8793 Fix patmat regression with extractors, existentials
| * | SI-8793 Fix patmat regression with extractors, existentialsJason Zaugg2014-08-151-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the same vein as SI-8128 / 3e9e2c65a, revert to the 2.10.x style of determining the types of the product elements of an extractor when using `TupleN`. I believe we can discard the special casing for Option/Tuple/Seq altogether with judicious application of `repackExistential` in `unapplyMethodTypes`. That ought to also fix fix SI-8149. But I'll target that work at 2.12.x.
* | | Merge pull request #3886 from adriaanm/report-filterGrzegorz Kossakowski2014-08-261-0/+3
|\ \ \ | |_|/ |/| | part 2 of the big error reporting refactoring
| * | Add errorCount to wean partest off Reporter$SeverityAdriaan Moors2014-07-171-0/+3
| | | | | | | | | | | | | | | | | | Once a release with this method is out, move partest to use errorCount and cut ties with the Severity nested class, so we can move it to the right enclosing class.
* | | SI-8512 Infer Any for the qSom Snytt2014-08-121-1/+1
| |/ |/| | | | | | | | | | | | | | | Avoid the widening bug for q. This resolution also suffers from the inference of Any, which can trigger a warning and an anxiety attack. But that's still better than doing the wrong thing. Right?
* | Merge pull request #3894 from adriaanm/depmsgGrzegorz Kossakowski2014-07-251-5/+6
|\ \ | | | | | | Better error message than 'bad symbolic reference'.
| * | Better error message than 'bad symbolic reference'.Adriaan Moors2014-07-221-5/+6
| |/ | | | | | | | | | | Let's not scare people, and try to give them some advice. PS: we should really come up with a better mechanism for testing errors/warnings
* | Merge pull request #3826 from lrytz/opt/refactorTrackedGrzegorz Kossakowski2014-07-253-23/+92
|\ \ | | | | | | Assortiment of cleanups and comments around the backend