summaryrefslogtreecommitdiff
path: root/test/files/run
Commit message (Collapse)AuthorAgeFilesLines
* SI-6178 reflective invocation of magic symbolsEugene Burmako2012-08-064-0/+226
| | | | | | | | | | | | | | | | | | | | | In Scala there are some methods that only exist in symbol tables, but don't have corresponding method entries in Java class files. To the best of my knowledge, these methods can be subdivided into five groups: 1) stuff weaved onto Any, AnyVal and AnyRef (aka Object), 2) magic methods that Scala exposes to fix Java arrays, 3) magic methods declared on Scala primitive value classes, 4) compile-time methods (such as classOf and all kinds of macros), 5) miscellaneous stuff (currently only String_+). To support these magic symbols, I've modified the `checkMemberOf` validator to special case Any/AnyVal/AnyRef methods and adjusted MethodMirror and ConstructorMirror classes to use special invokers for those instead of relying on Java reflection. Support for value classes will arrive in the subsequent commit, because it requires some unrelated changes to the mirror API (currently mirrors only support AnyRefs as their targets).
* Merge pull request #1059 from magarciaEPFL/ticket-SI-6188Josh Suereth2012-08-064-1/+15
|\ | | | | SI-6188
| * SI-6157 don't inline callee with exception-handler(s) if potentially unsafeMiguel Garcia2012-08-061-1/+1
| |
| * SI-6188 ICodeReader notes exception handlers, Inliner takes them into accountMiguel Garcia2012-08-063-0/+14
| |
* | Merge pull request #1045 from scalamacros/ticket/6175Josh Suereth2012-08-061-0/+5
|\ \ | |/ |/| SI-6175 reflect over classes with symbolic names
| * SI-6175 reflect over classes with symbolic namesEugene Burmako2012-08-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Top-level classes with symbolic names (having binary names like $colon$colon) have previously been incorrectly treated as local classes by Scala reflection. As a result they were loaded as if they weren't pickled (i.e. as Java classes). Moreover this bug also had a more subtle, but more dangerous manifestation. If such a class has already been loaded indirectly by unpickling another class (which refers to it in its pickle) and then someone tried to load it explicitly via classToScala, then it would be loaded twice (once as a Scala artifact and once as a Java artifact). This is a short route to ambiguities and crashes. The fix first checks whether a class with a suspicious name (having dollars) can be loaded as a Scala artifact (by looking it up in a symbol table). If this fails, the class is then loaded in Java style (as it was done before). Ambiguous names that can be interpreted both ways (e.g. foo_$colon$colon) are first resolved as Scala and then as Java. This prioritization cannot lead to errors, because Scala and Java artifacts with the same name cannot coexist, therefore loading a Scala artifact won't shadow a homonymous Java artifact.
* | staticTpe => staticType, actualTpe => actualTypeEugene Burmako2012-08-041-1/+1
|/
* first stab at serialization of exprs and tagsEugene Burmako2012-08-0210-20/+94
| | | | | | | | | | | | | | Instead of trying to serialize the entire universe and failing miserably (which happens now), exprs and type tags will now serialize their creators and deserialize into scala.reflect.basis. Since creators produced by reification are not serializable right now, serialization will crash. That's a small improvement over state of the art functionality-wise, but it's a step forward robustness-wise. Next step in this direction is generation of serialization code for creators. Related issues: SI-5919 and SI-5908. Also see the discussion at scala-internals http://groups.google.com/group/scala-internals/browse_thread/thread/ef63f8b5bd194c7c
* evicts last traces of makro from our codebaseEugene Burmako2012-08-0291-95/+95
| | | | Removes the stubs left out to appease the old starr, fixes macro tests.
* more refinements of reflection APIEugene Burmako2012-08-026-62/+30
| | | | | | | | | | | | | | Added a bunch of test methods to symbols to cover public flags: (e.g. isPrivate, isFinal, isOverride, isImplicit, etc). I'd argue that the API duplication w.r.t flag sets is trumped by unified interface to tests and better encapsulation. Also updated the API to be easier to understand after prior exposure to Java or .NET reflection APIs: 1) Added typeParams to TypeSymbol and ClassSymbol. 2) Renamed MethodSymbol.resultType to returnType. 3) Removed the distinction between MethodSymbol.params vs MethodSymbol.allParams now we just have MethodSymbol.params: List[List[Symbol]].
* SI-5888 Mirrors now have sane toStringsEugene Burmako2012-08-022-0/+57
| | | | | | | | Adds informative toString for InstanceMirror, FieldMirror, MethodMirror (for methods and constructors), ClassMirror and ModuleMirror. Universe mirrors (e.g. JavaMirrors or compiler mirrors) already have good toString methods that show their affiliation and/or classpaths.
* renames asType to toType and asXXXSymbol to asXXXEugene Burmako2012-08-0224-65/+65
| | | | | | | This renaming arguably makes the intent of `asType` more clear, but more importantly it shaves 6 symbols off pervasive casts that are required to anything meaningful with reflection API (as in mirror.reflectMethod(tpe.member(newTermName("x")).asMethodSymbol)).
* miscellaneous refinements of reflection APIEugene Burmako2012-08-028-0/+128
| | | | | | | 1) Removed unnecessary (i.e. implementable with pattern matching) type APIs. 2) Renamed isHigherKinded to takesTypeArgs making it easier to understand. 2) typeParams and resultType have been moved from MethodType to MethodSymbol Strictly speaking they are superfluous, but they are used very often.
* navigation between fields and accessorsEugene Burmako2012-08-022-0/+21
| | | | | | This works around SI-5736 that's been deemed too risky to be fixed in 2.10.0. A reflection newbie will be unlikely to acquire a field symbol from its name, but the `accessed` method provides an easy way to navigate to it from a getter.
* SI-5732 members and derivatives now return ScopeEugene Burmako2012-08-025-57/+60
| | | | | | | | | | | | | Firstly this unifies the reflection API - now both decls and members return Scope (not Scope and List[Symbol] as it were before). Secondly this fixes SI-5732 without having to sort the result of members. Type.members now returns Scope, a distinguished type, which has the `sorted` method, which does the required sorting if necessary. Also removes nonPrivateMembers and nonPrivateDeclarations to keep the API minimalistic (as can be seen from their implementation in internal.Types they are just members and decls with bridges and private members removed).
* Merge pull request #1030 from scalamacros/ticket/5751Josh Suereth2012-08-023-1/+16
|\ | | | | SI-5751 cleans up toolboxes for the release
| * SI-5751 cleans up toolboxes for the releaseEugene Burmako2012-07-313-1/+16
| | | | | | | | | | | | | | | | Removes the `freeTypes` parameters on `typeCheckExpr` and `runExpr`, since we now have public `substituteTypes` on both trees and types. Also implements long-awaited `inferImplicitValue` and `inferImplicitView` (thanks to Miles Sabin for nudging me!)
* | Merge pull request #1024 from paulp/topic/type-printingJosh Suereth2012-07-311-10/+10
|\ \ | |/ |/| Fixed maddening "..." lately in printed types.
| * Checkfile update.Paul Phillips2012-07-301-10/+10
| | | | | | | | | | | | I screwed around with type printing for a long time and now I have to be done, so I suggest we accept the imperfection in here for now because it's still way ahead of "..." as types go.
* | Merge pull request #1020 from odersky/ticket/5866Josh Suereth2012-07-302-0/+13
|\ \ | | | | | | SI-5866 Support casting null to value classes
| * | SI-5866 Support casting null to value classesMartin Odersky2012-07-302-0/+13
| | | | | | | | | | | | The fix now supports null.asInstanceOf[C] where C is a value class that wraps a primitive type.
* | | Merge pull request #1018 from scalamacros/topic/classtag-of-nothingJosh Suereth2012-07-301-30/+30
|\ \ \ | | | | | | | | ClassTag.Nothing now throws an exception
| * | | ClassTag.Nothing now throws an exceptionEugene Burmako2012-07-301-30/+30
| |/ / | | | | | | | | | | | | Nothing is a bottom type, so it doesn't make much sense for it to have a meaningful erasure (ClassTag.Nothing.runtimeClass).
* | | Merge pull request #960 from clhodapp/remove-resolve-overloadedJosh Suereth2012-07-309-347/+0
|\ \ \ | | | | | | | | Remove resolveOverloaded
| * | | Removed resolveOverloadedclhodapp2012-07-309-347/+0
| | |/ | |/| | | | | | | It was decided to remove it until the next release
* | | Merge pull request #1015 from hubertp/2.10.x-issue/5603Josh Suereth2012-07-302-0/+71
|\ \ \ | |/ / |/| | Fixed SI-5603. Early definitions now get transparent positions.
| * | Fixed SI-5603. Early definitions now get transparent positions.Hubert Plociniczak2012-07-302-0/+71
| |/ | | | | | | | | | | This includes a fix for a minor problem described in #594 - ensureNonOverlapping still focuses on default position when outside of early defs. Review by @dragos, @odersky.
* | Merge pull request #1005 from odersky/topic/worksheetodersky2012-07-302-0/+4
|\ \ | |/ |/| IDE improvements, with particular focus on making worksheets work.
| * Raw string interpolatorMartin Odersky2012-07-272-0/+4
| | | | | | | | Adds a raw string interpolator raw"..." which does not do any escape sequence processing.
* | SI-4560 - improved testJohannes Rudolph2012-07-242-21/+52
| | | | | | | | | | | | Added all the known cases of failing self-types. Added tests for symbol access (SI-4601) as well which should now be fixed for all of the same cases as well.
* | Fix SI-4560, NoSuchMethodErrors involving self types.Paul Phillips2012-07-242-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Following this commit are reversions of three prior commits which introduced difficulties of their own, plus extra tests for this issue and SI-4601, all of which I pinched from jrudolph. Maybe there was a good reason for some of the complicated code related to this ticket. I took the naive position that if we avoided generating a method call to a particular receiver if the receiver has no such method, we would encounter fewer NoSuchMethodErrors. I would believe one can construct a scenario which this doesn't handle correctly, but it's hard to believe this isn't a big improvement. Review by @jrudolph, @odersky.
* | SI-6111 accept single-subpattern unapply patternAdriaan Moors2012-07-232-0/+28
|/ | | | | | | | | | | | | | | | | | | | | | | | An extractor pattern `X(p)` should type check for any `X.unapply`/`X.unapplySeq` that returns an `Option[_]` -- previously we were confused about the case where it was an `Option[(T1, ... , Tn)]`. In this case, the expected type for the pattern `p` is simply `(T1, ... , Tn)`. While I was at it, tried to clean up unapplyTypeList and friends (by replacing them by extractorFormalTypes). From the spec: 8.1.8 ExtractorPatterns An extractor pattern x(p1, ..., pn) where n ≥ 0 is of the same syntactic form as a constructor pattern. However, instead of a case class, the stable identifier x denotes an object which has a member method named unapply or unapplySeq that matches the pattern. An unapply method in an object x matches the pattern x(p1, ..., pn) if it takes exactly one argument and one of the following applies: n = 0 and unapply’s result type is Boolean. n = 1 and unapply’s result type is Option[T], for some type T. the (only) argument pattern p1 is typed in turn with expected type T n > 1 and unapply’s result type is Option[(T1, ..., Tn)], for some types T1, ..., Tn. the argument patterns p1, ..., pn are typed in turn with expected types T1, ..., Tn
* SI-6090Martin Odersky2012-07-211-0/+6
| | | | Sharpens the test so that only Object_== and Object_!= methods on valueclasses may be rewritten in posterasure, whereas user-defined methods are not rewritten.
* Merge pull request #954 from odersky/optimize/outerAdriaan Moors2012-07-201-0/+26
|\ | | | | Removes redundant outers
| * Removes redundant outersMartin Odersky2012-07-201-0/+26
| | | | | | | | | | | | Widens the criterion when outer fields can be omitted. It used to be that sub- and superclass had to be enclosed by the same outer class. Only in that case was the outer field of the class omitted. We now omit if subclass is contained in an outer class that is itself a subclass of the superclasses outer class. See test case "outertest.scala" for an example.
* | Merge pull request #924 from hubertp/2.10.x-issue/5385Adriaan Moors2012-07-202-0/+24
|\ \ | | | | | | Fix for SI-5385.
| * | Fix for SI-5385.Paul Phillips2012-07-172-0/+24
| | | | | | | | | | | | | | | Nodes which hit EOF with no whitespace afterward had wrong position.
* | | Merge pull request #894 from axel22/topic/static-annot-cherry-2.10.xLukas Rytz2012-07-201-0/+243
|\ \ \ | | | | | | | | Implement @static annotation on singleton object fields.
| * | | WIP add private/lazy checks and a few tests.Aleksandar2012-07-191-0/+38
| | | |
| * | | Implement @static annotation on singleton object fields.Aleksandar Prokopec2012-07-181-0/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces the `@static` annotation on fields of static singleton objects. A static singleton object is a top-level singleton object or an object nested within a static singleton object. The field annotated with `@static` is generated as a true static field in the companion class of the object. The initialization of the field is done in the static initializer of the companion class, instead of the object itself. Here's an example. This: object Foo { @static val FIELD = 123 } class Foo generates : object Foo { def FIELD(): Int = Foo.FIELD } class Foo { <static> val FIELD = 123 } The accessor in `object Foo` is changed to return the static field in `class Foo` (the companion class is generated if it is not already present, and the same is done for getters if `FIELD` is a `var`). Furthermore, all the callsites to accessor `Foo.FIELD` are rewritten to access the static field directly. It is illegal to annotate a field in the singleton object as `@static` if there is already a member of the same name in `class Foo`. This allows better Java interoperability with frameworks which rely on static fields being present in the class. The `AtomicReferenceFieldUpdater`s are one such example. Instead of having a Java base class holding the `volatile` mutable field `f` and a static field containing a reference to the `AtomicReferenceFieldUpdater` that mutates `f` atomically, and extending this Java base class from Scala, we can now simply do: object Foo { @static val arfu = AtomicReferenceUpdater.newUpdater( classOf[Foo], classOf[String], "f" ) } class Foo { @volatile var f = null import Foo._ def CAS(ov: String, nv: String) = arfu.compareAndSet(this, null, "") } In summary, this commit introduces the following: - adds the `@static` annotation - for objects without a companion class and `@static` members, creates a companion class (this is done in `CleanUp`) - checks for conflicting names and if `@static` is used on static singleton object member - creates the `static` field in the companion class for `@static` members - moves the field initialization from the companion object to the static initializer of the class (the initialization of `@static` members is bypassed in the `Constructors` phase, and added to static ctors in `CleanUp`) - all callsites to the accessors of `@static` are rewritten to access the static fields directly (this is done in `GenICode`) - getters and setters to `@static` fields access the static field directly, and the field in the singleton object is not emitted (this is done in `GenICode`) - changes in `GenJVM`, `GenASM` - now computing local var indices in static initializers as well - this was an oversight before, now is necessary Future work: allow the `@static` annotation on methods as well - this will be added in a future commit. Review by @odersky, @dragos, @paulp, @heathermiller.
* | | | Merge pull request #941 from adriaanm/ticket-6104Adriaan Moors2012-07-202-0/+9
|\ \ \ \ | | | | | | | | | | SI-6104 support This pattern
| * | | | SI-6104 support This patternAdriaan Moors2012-07-182-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This(name) is treated just like Ident(name) apparently this pattern was used in 2.9 code, though I'm not sure it's spec'ed
* | | | | Merge pull request #936 from scalamacros/ticket/5999Adriaan Moors2012-07-2025-25/+170
|\ \ \ \ \ | | | | | | | | | | | | SI-5999 consistent behavior for c.reify and c.universe.reify
| * | | | | SI-5999 a real fix to the packageless problemEugene Burmako2012-07-209-5/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a discussion on a reflection meeting on Jul 17 we concluded that we should split staticModule into staticModule and staticPackage to remove the ambiguity between packageless objects and packageless packages (more in the comments in the body of the commit). The motivation is verbosely outlined in the comments, but the bottom line is that Scala allows packages and packageless objects to have the same name within the same program. Therefore at times we need to disambiguate, hence the introduction of the staticPackage method. As of such staticModule no longer works for packages. In the same fashion staticPackage doesn't work for modules. This is done to ensure robustness of reification. I would like to do the same for getModule in Definitions, but we have to maintain backward compatibility. That's why I retained the old behavior, but replaced getModule invocations with getPackage where appropriate to be in line with staticModule and staticPackage. Another important thing that follows from the discussion is that both staticClass and staticModule prefer parent packages over parent objects in cases of ambiguity. Say, if we have the following snippet of code: object B { class C } next to package B { class C } then staticClass("B.C") will never even consider a C inside the object B. This is how scalac operates, so we decided to be consistent here. Finally reification logic got changed to distinguish between staticModule and staticPackage, and to allow for the fact that staticClass and staticModule prefer parent packages to parent objects.
| * | | | | SI-5999 removes Context.reifyEugene Burmako2012-07-2016-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently there are discrepancies between the behavior of c.reify and c.universe.reify. First step in fixing these problems is removing the duplication in the API. That's why I'm cutting away the Context.reify shortcut. Context.reify is a magic macro, hardwired in the fast track mechanism, so removing it requires redeploying the starr (because an old starr will crash if launched on sources that don't contain Context.reify). To cleanly redeploy a starr I've left a Context.reify stub in sources, but hidden it behind a `protected` modifier. When starr is redeployed (in a subsequent commit) the stub will be removed. I've also updated the tests to use c.universe.reify instead of c.reify. This will break some of them, because c.universe.reify uses a standard compiler mirror, which unlike a macro mirror doesn't like packageless classes. That's an annoyance, but I think having clean separation of commits is more important that being 100% consistent.
* | | | | | Merge pull request #927 from dgruntz/issue/5856Adriaan Moors2012-07-201-0/+10
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-5856 enables use of $this in string interpolation
| * | | | | | SI-5856 enables use of $this in string interpolationDominik Gruntz2012-07-171-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pull request fixes SI-5856. The scanner has been modified to return the correct token if keywords appear in $-expressions. The parser has been modified to issue an error and to only accept $<identifier>, $this and $block.
* | | | | | | Merge pull request #937 from adriaanm/ticket-5739Adriaan Moors2012-07-205-40/+95
|\ \ \ \ \ \ \ | |_|/ / / / / |/| | | | | | SI-5739 store sub-patterns in local vals
| * | | | | | SI-5739 store sub-patterns in local valsAdriaan Moors2012-07-175-40/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also closes SI-5158 (debuggability), SI-6070 (soundness). To improve both debuggability and soundness, we now store the result of an extractor (user-defined and synthetic) in local variables. For the case class case, this also fixes the soundness bug SI-6070, as this prevents post-match mutation of bound variables. The core of the refactoring consisted of introducing the PreserveSubPatBinders trait, which introduces local variables instead of substituting symbols for the RHS of those variables (so this can be seen as reverting the premature optimization of inline the case-class getters into the case body). Since TreeMakerToCond fuses the substitutions performed in a match to find out which symbolic values binders evaluate to, masquerade PreserveSubPatBinders's binding of subPatBinders and subPatRefs as the corresponding substitution. Consider `case class Foo(bar: Int)`, then `case y@Foo(x) => println(x)` gives rise to `{val x = y.bar; println(x)}` (instead of `println(y.bar)`), and `subPatternsAsSubstitution` pretends we still replace `x` by `y.bar`, instead of storing it in a local variable so that the rest of the analysis need not be modified. Misc notes: - correct type for seq-subpattern - more error resilience (ill-typed patterns sometimes slip past the typechecker -- reopened SI-4425) TODO: come up with a more abstract framework for expressing bound symbols and their values
* | | | | | | Merge pull request #929 from scalamacros/ticket/5895Adriaan Moors2012-07-2014-39/+86
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | fixes field mirrors and also improves docs and exceptions for all mirrors