summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* 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
| * | Documentation for isModuleClassLukas Rytz2014-07-081-0/+3
| | |
| * | Clean up and document some usages of flags in the backendLukas Rytz2014-07-082-18/+68
| | |
| * | Minor cleanups and comments in GenBCodeLukas Rytz2014-07-081-6/+22
| | |
* | | SI-8743 Fix crasher with poly-methods annotated with @varargsJason Zaugg2014-07-231-7/+0
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | The code that generated the Java varargs forwarder was basing things on the `ValDef-s` of the parameters of the source method. But, their types refer to a type parameter skolems of the enclosing method, which led to a type mismatch when typechecking the forwarder. Instead, I've reworked the code to simply use the `DefDef`-s symbol's info, which *doesn't* refer to skolems. This actually simplifies the surrounding code somewhat; rather than repeated symbols in a map we can just time travel the pre-uncurry method signatures to figure out which params are releated.
* | Merge pull request #3817 from phaller/topic/typetagsLukas Rytz2014-07-154-28/+42
|\ \ | | | | | | SI-5919 TypeTags and Exprs should be serializable
| * | Add SerialVersionUID to SerializedTypeTag and SerializedExprPhilipp Haller2014-07-152-2/+2
| | | | | | | | | | | | | | | | | | | | | The reason for adding the SerialVersionUID annotations is to be able to provide serialization stability throughout the 2.11.x series. And since type tags (and exprs) have not been serializable before, this does not break serialization for existing code.
| * | SI-5919 TypeTags and Exprs should be serializablePhilipp Haller2014-07-154-28/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Make TypeCreator and TreeCreator extend Serializable. - When replacing a SerializedTypeTag with a TypeTag or WeakTypeTag, do not use scala.reflect.runtime.universe.rootMirror, since it is unlikely to find user classes; instead, create a runtime mirror using the context ClassLoader of the current thread. Use the same logic for SerializedExpr. - Remove writeObject/readObject methods from SerializedTypeTag and SerializedExpr since they are unused. - Add @throws annotation on writeReplace and readResolve methods. - Handle SecurityException if the current thread cannot access the context ClassLoader. - To make type tags of primitive value classes serializable, make PredefTypeCreator a top-level class. Otherwise, it would retain a reference to the enclosing Universe, rendering the TypeCreator non-serializable. Binary compatibility: - Keep nested PredefTypeCreator class to avoid backward binary incompatible change. - Keep `var` modifiers on the class parameters of SerializedTypeTag for backward binary compatibility. - Adds filter rules to forward binary compatibility whitelist: - `TypeCreator`, `PredefTypeCreator`, and `TreeCreator` must now extend from `Serializable`. - Must have new class `scala.reflect.api.PredefTypeCreator` to avoid problematic outer reference.
* | | Merge pull request #3858 from densh/si/8703Jason Zaugg2014-07-151-2/+2
|\ \ \ | | | | | | | | SI-8703 add support for blocks with just a single expression to quasiquotes
| * | | SI-8703 add support for blocks with just a single expression to quasiquotesDenys Shabalin2014-07-021-2/+2
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously it was impossible to match a block that was constructed as Block(Nil, term) Due to the fact that quasiquotes always flatten those into just term. This is a correct behaviour for construction (for sake of consistency with parser) but doing it in deconstruction mode make it impossible to match such blocks which could have been constructed manually somewhere. To fix this we just disable block flattening in deconstruction mode. Interestingly enough this doesn't break existing code due to the fact that quasiquote's block matcher also matches expressions as single-element blocks. This allows to match single-element blocks with patterns like q"{ $foo }".
* | | Merge pull request #3845 from xeno-by/topic/attachment-subclassingJason Zaugg2014-07-151-1/+1
|\ \ \ | | | | | | | | relaxes attachment-matching rules
| * | | relaxes attachment-matching rulesEugene Burmako2014-07-101-1/+1
| |/ / | | | | | | | | | | | | | | | It came as a surprise recently, but attachments.contains/get/update/remove require the class of the payload to match the provided tag exactly, not taking subclassing into account. This commit fixes the oversight.
* | | Merge pull request #3844 from xeno-by/topic/rangepos-subpatternsJason Zaugg2014-07-151-1/+1
|\ \ \ | |_|/ |/| | prevents c.internal.subpatterns from destroying rangeposes
| * | prevents some reflection APIs from destroying rangeposesEugene Burmako2014-07-101-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit continues the work started in fcb3932b32. As we've figured out the hard way, exposing internally maintained trees (e.g. macro application) to the user is dangerous, because they can mutate the trees in place using one of the public APIs, potentially corrupting our internal state. Therefore, at some point we started duplicating everything that comes from the user and goes back to the user. This was generally a good idea due to the reason described above, but there was a problem that we didn't foresee - the problem of corrupted positions. It turns out that Tree.duplicate focuses positions in the tree being processed, turning range positions into offset ones, and that makes it impossible for macro users to make use of precise position information. I also went through the calls to Tree.duplicate to see what can be done to them. In cases when corruptions could happen, I tried to replace duplicate with duplicateAndKeepPositions. Some notes: 1) Tree rehashing performed in TreeGen uses duplicates here and there (e.g. in mkTemplate or in mkFor), which means that if one deconstructs a macro argument and then constructs it back, some of the positions in synthetic trees might become inaccurate. That's a general problem with synthetic trees though, so I don't think it should be addressed here. 2) TypeTree.copyAttrs does duplication of originals, which means that even duplicateAndKeepPositions will adversely affect positions of certain publicly accessible parts of type trees. I'm really scared to change this though, because who knows who can use this invariant. 3) Some methods that can be reached from the public API (Tree.substituteXXX, c.reifyXXX, c.untypecheck, ...) do duplicate internally, but that shouldn't be a big problem for us, because nothing is irreversibly corrupted here. It's the user's choice to call those methods (unlike with TypeTree.copyAttrs) and, if necessary, they can fixup the positions themselves afterwards. 4) Macro engine internals (macro impl binding creation, exploratory typechecking in typedMacroBody) use duplicate, but these aren't supposed to be seen by the user, so this shouldn't be a problem. 5) Certain parser functions, member syntheses and typer desugarings also duplicate, but in those cases we aren't talking about taking user trees and screwing them up, but rather about emitting potentially imprecise positions in the first place. Hence this commit isn't the right place to address these potential issues.
* | Merge pull request #3867 from lrytz/t8708Lukas Rytz2014-07-091-5/+37
|\ \ | | | | | | SI-8708 Fix pickling of LOCAL_CHILD child of sealed classes
| * | SI-8708 Fix pickling of LOCAL_CHILD child of sealed classesLukas Rytz2014-07-071-5/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a sealed class or trait has local children, they are not pickled in as part of the children of the symbol (introduced in 12a2b3b to fix Aladdin bug 1055). Instead the compiler adds a single child class named LOCAL_CHILD. The parents of its ClassInfoType were wrong: the first parent should be a class. For sealed traits, we were using the trait itself. Also, the LOCAL_CHILD dummy class was entered as a member of its enclosing class, which is wrong: it represents a local (non-member) class, and it's a synthetic dummy anyway.
* | | Remove deprecationWarning, currentReporting from ReportingAdriaan Moors2014-07-043-6/+35
| | | | | | | | | | | | | | | | | | | | | | | | This moves us a bit closer to the goal of having a single entry point to reporting. Must modularize Reporting a bit so it can be used in Variances (need a reference to `currentRun` in `reflect.internal.Reporting`).
* | | Track symbol that caused a deprecation warning.Adriaan Moors2014-07-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So that we can filter deprecations based on defining package. Configurable error reporting will support a rule like: "In compilation unit X, escalate deprecation warnings that result from accessing members in package P that have been deprecated since version V. Report an error instead of a warning for those." TODO: remove deprecationWarning overload that doesn't take a `Symbol`? (Replace by a default value of `NoSymbol` for the deprecated symbol arg?)
* | | Uniformly route reporting through reporter.Adriaan Moors2014-07-042-7/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sharpen interfaces, reduce footprint of Reporting trait. Ideally, all reporting should indirect through reporter, and the `Reporting` trait itself should be restricted to a single method that retrieves the current `reporter`. Pull up some more reporting to reflect.internal. Would like to do more, but need to move partest to the reflect.internal interface first. (Its `errorCount` relies on `ERROR.count` in `tools.nsc.Reporter`.)
* | | Move reporting logic into Reporting traitAdriaan Moors2014-07-043-15/+37
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move code from Global/SymbolTable to separate Reporting traits to start carving out an interface in scala.reflect.internal.Reporting, with internals in scala.tools.nsc. Reporting is mixed into the cake. It contains a nested class PerRunReporting. Should do the same for debugging/logging. The idea is that CompilationUnit and Global forward all reporting to Reporter. The Reporting trait contains these forwarders, and PerRunReporting, which accumulates warning state during a run. In the process, I slightly changed the behavior of `globalError` in reflect.internal.SymbolTable: it used to abort, weirdly. I assume that was dummy behavior to avoid introducing an abstract method. It's immediately overridden in Global, and I couldn't find any other subclasses, so I don't think the behavior in SymbolTable was ever observed. Provide necessary hooks for scala.reflect.macros.Parsers#parse. See scala/reflect/macros/contexts/Parsers.scala's parse method, which overrides the reporter to detect when parsing goes wrong. This should be refactored, but that goes beyond the scope of this PR. Don't pop empty macro context stack. (Ran into this while reworking -Xfatal-warnings logic.) Fix -Xfatal-warnings behavior (and check files): it wasn't meant to influence warning reporting, except for emitting one final error; if necessary to fail the compile (when warnings but no errors were reported). Warnings should stay warnings. This was refactored in fbbbb22946, but we soon seem to have relapsed. An hour of gitfu did not lead to where it went wrong. Must've been a merge.
* | Merge pull request #3736 from VladimirNik/print-types-issue-2.11.xAdriaan Moors2014-07-031-14/+27
|\ \ | | | | | | SI-8447 fix TypeTree printing (2.11.x)
| * | TypeTree printing modified (SI-8447)VladimirNik2014-05-091-14/+27
| | |
* | | Merge pull request #3772 from densh/si/8609Adriaan Moors2014-07-031-0/+2
|\ \ \ | |_|/ |/| | SI-8609 Fix flattening of definitions and imports in quasiquotes
| * | SI-8609 Fix flattening of definitions and imports in quasiquotesDenys Shabalin2014-05-211-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quasiquotes allow to unquote trees with ..$ with block flattening semantics to simplify composition: val onetwo = q"1; 2" val onetwothree = q"..$onetwo; 3" // same as q"1; 2; 3" If there is no block it will be equivalent to $ unquoting: val one = q"1" val onetwo = q"..$one; 2" // same as q"1; 2" But the inconsistency here is that currently only terms support this single-element semantics. This commit extends this functionality to also support definitions and imports. So that following code works: val q1 = q"val x = 1" val q2 = q"..$q1; val y = 2" // same as q"val x = 1; val y = 2"
* | Merge pull request #3796 from som-snytt/issue/8630Adriaan Moors2014-06-031-1/+1
|\ \ | | | | | | SI-8630 lineToString no longer long by one at eof
| * | SI-8630 lineToString no longer long by one at eofSom Snytt2014-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One more EOL crasher, or lack-of-EOL crasher, when the text is at EOF. It was not caught by the last round of excellent and thorough tests because ``` // If non-whitespace tokens run all the way up to EOF, // positions go wrong because the correct end of the last // token cannot be used as an index into the char array. // The least painful way to address this was to add a // newline to the array. ```
* | | Merge pull request #3789 from clhodapp/fix/SI-6678Adriaan Moors2014-06-031-1/+2
|\ \ \ | | | | | | | | SI-6678 Make currentMirror macro hygenic
| * | | SI-6678 Make currentMirror macro hygenicclhodapp2014-05-231-1/+2
| | |/ | |/|
* | | Merge pull request #3774 from lrytz/opt/backendWipLukas Rytz2014-06-011-56/+50
|\ \ \ | |_|/ |/| | More type safe implementation of BType, cleanups in GenBCode
| * | Re-use the exsiting range of the name table when using subName.Lukas Rytz2014-05-211-4/+10
| | | | | | | | | | | | The sub-name can just point to a smaller range of the array.
| * | Cleanups in Names.scalaLukas Rytz2014-05-211-53/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enter only fully constructed Name objects into the hash table, this should make lookupTypeName thread-safe. Clean up lookupTypeName - the hash code for a type name is the same as for its correspondent term name. Going from a type name toTermName should never create a new TermName instance. Assert that.
| * | Minor cleanups and commenting around BType.Lukas Rytz2014-05-211-3/+6
| |/ | | | | | | Use `length` instead of `size` on arrays in `reflect/internal/Names`.