summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/2.12.0' into merge/2.12.0-to-2.12.xJason Zaugg2016-10-1413-109/+146
|\
| * Detect clash of mixedin val and existing member.Adriaan Moors2016-10-122-14/+20
| | | | | | | | | | | | | | | | | | Before, we looked only at the result type, which was silly. This was originally motivated by a hack to get to the error about conflicting paramaccessors. The error detection for that can now be formulated more directly. Fixes scala/scala-dev#244
| * Merge pull request #5429 from lrytz/sd224Adriaan Moors2016-10-117-18/+41
| |\ | | | | | | Default -Xmixin-force-forwarders to true
| | * Default -Xmixin-force-forwarders to trueLukas Rytz2016-09-302-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also eliminates the warning when a mixin forwarder cannot be implemented because the target method is a java-defined default method in an interface that is not a direct parent of the class. The test t5148 is moved to neg, as expected: It was moved to pos when disabling mixin forwarders in 33e7106. Same for the changed error message in t4749.
| | * Explicit SerialVersionUID for all ClassTags / ManifestsLukas Rytz2016-09-304-10/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looking at the class hierarchy around ClassTag and Manifest, the only class that had a serialVersionUID is AnyValManifest, where the hierarchy is something like: trait ClassTag // extends Serializable |- class GenericClassTag |- trait Manifest |- class ClassTypeManifest |- class SingletonTypeManifest |- ... |- abstract class AnyValManifest // has SerialVersionUID |- class DoubleManifest |- ... Note that AnyValManifest is an abstract class, so the SerialVersionUID annotation does not help there. This commit adds explicit SerialVersionUID annotations to (hopefully) all subclasses of ClassTag, to make sure they are stable under compatible changes (such as changing -Xmixin-force-forwarders).
| | * Error message for super calls to indirect java parent interfacesLukas Rytz2016-09-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Super calls to indirect java parent interfaces cannot be emitted, an error message is emitted during SuperAccessors. The error message was missing if the super call was non-qualified, resulting in an assertion failure in the backend.
| * | Merge pull request #5442 from adriaanm/t9943Adriaan Moors2016-10-111-2/+2
| |\ \ | | | | | | | | SI-9943 sealed class does not yield SAM type
| | * | SI-9943 final/sealed class does not yield SAM typeAdriaan Moors2016-10-041-2/+2
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cannot subclass such a class. (Well, we could subclass a sealed class in the same compilation unit. We ignore this for simplicity.) This is a bit of a sneaky fix for this bug, but our hand is pretty much forced by other constraints, in this intersection of overload resolution involving built-in function types and SAMs, and type inference for higher-order function literals (#5307). Luckily, in this particular issue, the overloading clash seems accidental. The `sealed` `<:<` class is not a SAM type as it cannot be subclassed outside of `Predef`. For simplicity, we don't consider where the SAM conversion occurs and exclude all sealed classes from yielding SAM types. Thanks to Miles for pointing out that `final` was missing in my first iteration of this fix.
| * | Merge pull request #5452 from lrytz/sd242Adriaan Moors2016-10-101-2/+1
| |\ \ | | | | | | | | Fix the interface flag when re-writing a closure call to the body method
| | * | Fix the interface flag when re-writing a closure call to the body methodLukas Rytz2016-10-091-2/+1
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When re-writing a closure invocation to the body method, the `itf` flag of the invocation instruction was incorrect: it needs to be true if the method is defined in an interface (including static methdos), not if the method is invoked through `INVOKEINTERFACE`. JDK 8 doesn't flag this inconsistency and executes the bytecode, but the verifier in JDK 9 throws an `IncompatibleClassChangeError`. Similar fixes went into e619b03.
| * | SI-9946 don't null field in lazy accessors that turn out to be liveJason Zaugg2016-10-074-73/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a non-transient lazy val is the only user of a private field in a class, the field is nulled out at the end of the lazy initializer. This is tested in the existing test `run/lazy-leaks.scala`. The analysis of which fields could be nulled out was recently moved from `mixin` to the new `fields` phase. This introduced a regression as a reference from an inner- or companion-classes had not yet been processed by `explicitouter` to publicise private fields. This commit delays the analysis to mixin (after explicit outer has done its work.) Navigating from `foo$lzycompute()` to `foo()` to `foo` is a little dirty now. I'm not sure whether there is a more robust way to structure things.
| * | SI-9946 make nullification of lazy val dependencies module awareJason Zaugg2016-10-071-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a non-transient lazy val is the only user of a private field in a class, the field is nulled out at the end of the lazy initializer. This is tested in the existing test `run/lazy-leaks.scala`. The analysis of which fields could be nulled out was recently moved from `mixin` to the new `fields` phase. This introduced a regression as a it didn't account for the richer pallete of trees and symbols at that juncture. This commit excludes references to private member modules from collection of private fields, thus avoiding a later compiler crash in the backend due to a nonsense tree trying to null out the module symbol. It might make sense to null out the module var, but I've opted to limit the scope of this analysis to paramaccessors and regular fields.
* | Merge pull request #5416 from SethTisue/merge-2.12.0-to-2.12.x-sep-24Seth Tisue2016-10-0516-157/+204
|\| | | | | merge 2.12.0 onto 2.12.x [ci: last-only]
| * Merge pull request #5430 from adriaanm/dev235Adriaan Moors2016-09-293-48/+49
| |\ | | | | | | Emit local module like lazy val
| | * Clarify docs, variable nameAdriaan Moors2016-09-291-11/+12
| | | | | | | | | | | | A local lazy val and a local object are expanded in the same way.
| | * Emit local module like lazy valAdriaan Moors2016-09-291-22/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | The motivation is to use the new fine-grained lock scoping that local lazies have since #5294. Fixes scala/scala-dev#235 Co-Authored-By: Jason Zaugg <jzaugg@gmail.com>
| | * Make some name suffixes constantsAdriaan Moors2016-09-282-18/+20
| | | | | | | | | | | | | | | | | | There's still a lot of duplication, as well as plenty of opportunities for constant folding / simplification.
| * | don't deprecate Either.left and Either.right yetSeth Tisue2016-09-281-15/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for two reasons: * to facilitate warning-free cross-compilation between Scala 2.11 and 2.12 * because it's not clear that .swap is a good replacement for .left Either.right seems almost certain to be deprecated in 2.13. Either.left's future is uncertain; see discussion (and links to additional discussions) at https://github.com/scala/scala/pull/5135
| * | Merge pull request #5423 from lrytz/sd229Adriaan Moors2016-09-283-12/+35
| |\ \ | | | | | | | | | | | | | | | | Fixes for DelayedInit classes capturing values Fix scala/scala-dev#229
| | * | SI-4683 fix $outer accesses in class bodies extending DelayedInitLukas Rytz2016-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Constructors rewrites references to parameter accessor methods in the constructor to references to parameters. It avoids doing so for subclasses of DelayedInit. This commit makes sure the rewrite does not happen for the $outer paramter, a case that was simply forgotten.
| | * | SI-9697 / SD-229 Fix DelayedInit subclass capturing local valueLukas Rytz2016-09-282-11/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a class captures an outer value, a field for that value is created in the class. The class also gets a constructor parameter for the captured value, the constructor will assign the field. LambdaLift re-writes accesses to the local value (Ident trees) to the field. However, if the statement accessing the local value will end up inside the constructor, the access is re-written to the constructor parameter instead. This is the case for constructor statements: class C { { println(capturedLocal) } } If C extends DelayedInit, the statement does not end up in C's constructor, but into a new synthetic method. The access to `capturedLocal` needs to be re-written to the field instead of the constructor parameter. LambdaLift takes the decision (field or constructor parameter) based on the owner chain of `currentOwner`. For the constructor statement block, the owner is a local dummy, for which `logicallyEnclosingMember` returns the constructor symbol. This commit introduces a special case in LambdaLift for local dummies of DelayedInit subclasses: instead of the constructor, we use a temporary symbol representing the synthetic method holding the initializer statements.
| * | | Merge pull request #5397 from retronym/ticket/9920Adriaan Moors2016-09-282-2/+9
| |\ \ \ | | |_|/ | |/| | SI-9920 Avoid linkage errors with captured local objects + self types
| | * | SI-9920 Avoid linkage errors with captured local objects + self typesJason Zaugg2016-09-272-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An outer parameter of a nested class is typed with the self type of the enclosing class: ``` class C; trait T { _: C => def x = 42; class D { x } } ``` leads to: ``` class D extends Object { def <init>($outer: C): T.this.D = { D.super.<init>(); () }; D.this.$outer().$asInstanceOf[T]().x(); ``` Note that a cast is inserted before the call to `x`. If we modify that a little, to instead capture a local module: ``` class C; trait T { _: C => def y { object O; class D { O } } } ``` Scala 2.11 used to generate (after lambdalift): ``` class D$1 extends Object { def <init>($outer: C, O$module$1: runtime.VolatileObjectRef): C#D$1 = { D$1.super.<init>(); () }; D$1.this.$outer().O$1(O$module$1); ``` That isn't type correct, `D$1.this.$outer() : C` does not have a member `O$1`. However, the old trait encoding would rewrite this in mixin to: ``` T$class.O$1($outer, O$module$1); ``` Trait implementation methods also used to accept the self type: ``` trait T$class { final <stable> def O$1($this: C, O$module$1: runtime.VolatileObjectRef): T$O$2.type } ``` So the problem was hidden. This commit changes replaces manual typecheckin of the selection in LambdaLift with a use of the local (erasure) typer, which will add casts as needed. For `run/t9220.scala`, this changes the post LambdaLift AST as follows: ``` class C1$1 extends Object { def <init>($outer: C0, Local$module$1: runtime.VolatileObjectRef): T#C1$1 = { C1$1.super.<init>(); () }; - C1$1.this.$outer.Local$1(Local$module$1); + C1$1.this.$outer.$asInstanceOf[T]().Local$1(Local$module$1); <synthetic> <paramaccessor> <artifact> private[this] val $outer: C0 = _; <synthetic> <stable> <artifact> def $outer(): C0 = C1$1.this.$outer } ```
| * | | Merge pull request #5412 from retronym/ticket/SD-226Adriaan Moors2016-09-282-1/+19
| |\ \ \ | | | | | | | | | | | | | | | | | | | | Be lazier in Fields info transform for better performance Fix scala-dev#226
| | * | | Make isSeparateCompiled... robust against rogue phase time travelJason Zaugg2016-09-272-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't hit this code path during bootstrapping, but we could conceivably hit it with macros or compiler plugins peering into the future through atPhase before refchecks as run. Also rename a method to reflect the generality of the info transform (it does more than mixin, now.)
| | * | | SD-226 Be lazier in Fields info transform for better performanceJason Zaugg2016-09-212-1/+13
| | | |/ | | |/| | | | | | | | | | | | | | | | | | | | | | | | | Only mixin fields + accessors into class infos of classes that are either in the current run, or appear in a superclass chain of a class in the current run. This is analagous to what happens in the mixin phase.
| * | | Merge pull request #5388 from adriaanm/issue-219Adriaan Moors2016-09-281-42/+66
| |\ \ \ | | | | | | | | | | Avoid mismatched symbols in fields phase
| | * | | Cast more pro-actively in synthetic accessor trees.Adriaan Moors2016-09-261-51/+62
| | | | | | | | | | | | | | | | | | | | Also narrow scope of afterOwnPhase.
| | * | | Avoid mismatched symbols in fields phaseAdriaan Moors2016-09-261-2/+15
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The info of the var that stores a trait's lazy val's computed value is expressed in terms of symbols that exist before the fields phase. When we're implementing the lazy val in a subclass of that trait, we now see symbols created by the fields phase, which results in mismatches between the types of the lhs and rhs in the assignment of `lazyVar = super.lazyImpl`. So, type check the super-call to the trait's lazy accessor before our own phase. If the lazy var's info depends on a val that is now implemented by an accessor synthesize by our info transformer, we'll get a mismatch when assigning `rhs` to `lazyVarOf(getter)`, unless we also run before our own phase (like when we were creating the info for the lazy var). This was revealed by Hanns Holger Rutz's efforts in compiling scala-refactoring's test suite (reported on scala-internals). Fixes scala/scala-dev#219
| * | | Including Lightbend in `-version` message.Adriaan Moors2016-09-271-1/+1
| | | | | | | | | | | | | | | | Also consistently use "LAMP/EPFL" and not "EPFL LAMP".
| * | | Merge pull request #5417 from retronym/ticket/SD-233Jason Zaugg2016-09-271-1/+3
| |\ \ \ | | | | | | | | | | SD-233 synchronized blocks are JIT-friendly again
| | * | | SD-233 synchronized blocks are JIT-friendly againJason Zaugg2016-09-271-1/+3
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GenBCode, the new backend in Scala 2.12, subtly changed the way that synchronized blocks are emitted. It used `java/lang/Throwable` as an explicitly named exception type, rather than implying the same by omitting this in bytecode. This appears to confuse HotSpot JIT, which reports a error parsing the bytecode into its IR which leaves the enclosing method stuck in interpreted mode. This commit passes a `null` descriptor to restore the old pattern (the same one used by javac.) I've checked that the JIT warnings are gone and that the method can be compiled again.
| * / / Optimize javaBinaryName callersJason Zaugg2016-09-263-5/+5
| |/ / | | | | | | | | | | | | | | | | | | ... by calling javaBinaryNameString, instead. They all are happy with a throw away String, there is no advantage to interning this into the name table.
| * | Merge pull request #5380 from SethTisue/remove-outdated-ensime-stuffLukas Rytz2016-09-202-28/+0
| |\ \ | | |/ | |/| remove outdated ENSIME info
| | * remove outdated ENSIME infoSeth Tisue2016-09-072-28/+0
| | | | | | | | | | | | link to an external ENSIME page instead
| * | Merge pull request #5395 from retronym/pr/5394Jason Zaugg2016-09-151-1/+1
| |\ \ | | | | | | | | Avoid omitting constant typed vals in constructors
| | * | Avoid omitting constant typed vals in constructorsJason Zaugg2016-09-121-1/+1
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix for regression in 2.12.0-RC1 compiling shapeless tests. They were given the same treatment as vals that are members of classes on the definition side without the requisite transformation of references to the val to fold the constant into references. This commit limits the transform to members of classes. Co-Authored-By: Miles Sabin <miles@milessabin.com>
| * | Merge pull request #5398 from retronym/ticket/SD-225Jason Zaugg2016-09-151-2/+4
| |\ \ | | | | | | | | SD-225 Use a "lzycompute" method for module initialization
| | * | SD-225 Use a "lzycompute" method for module initializationJason Zaugg2016-09-141-2/+4
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The monitors and module instantation were inliuned into the module accessor method in b2e0911. However, this seems to have had a detrimental impact on performance. This might be because the module accessors are now above the "always inline" HotSpot threshold of 35 bytes, or perhaps because they contain monitor-entry/exit and exception handlers. This commit returns to the the 2.11.8 appraoch of factoring the the second check of the doublecheck locking into a method. I've done this by declaring a nested method within the accessor; this will be lifted out to the class level by lambdalift. This represents a slight deviation from the implementation strategy used for lazy accessors, which create a symbol for the slowpath method in the info transform and generate the corresponding DefDef as a class member. I don't believe this deviation is particular worrisome, though. I have bootstrapped the compiler through this commit and found that the drastic regression in compiling the shapeless test suite is solved.
| * / SI-9918 object in trait mixed into package objectAdriaan Moors2016-09-101-1/+1
| |/
* | Merge pull request #5420 from SethTisue/ah-sbaz-those-were-the-daysLukas Rytz2016-09-301-5/+2
|\ \ | | | | | | expunge a stray reference to sbaz in the Scala man page
| * | expunge a stray reference to sbaz in the Scala man pageSeth Tisue2016-09-261-5/+2
| |/ | | | | | | and fix a typo while we're at it
* / SI-9936 SeqLike.indexWhere starts at zeroSom Snytt2016-09-261-1/+1
|/ | | | | | | | | | | This follows the Scaladoc, and makes ``` "abcdef".indexOf('c', -1) ``` work like ``` "abcdef".toVector.indexOf('c', -1) ```
* Merge pull request #5368 from retronym/ticket/SD-208Adriaan Moors2016-09-062-32/+10
|\ | | | | | | | | SD-208 Restore 2.11 names for arrayOps implicits Fix scala/scala-dev#208
| * SD-208 Restore 2.11 names for arrayOps implicitsJason Zaugg2016-08-312-32/+10
| |
* | SD-143 allow super calls to methods defined in indirect super classesJason Zaugg2016-09-051-1/+7
| | | | | | | | | | | | | | | | The restriction for super calls to methods defined in indirect super classes introduced in a980fde was over-restrictive. In particular, it ruled out a valid code pattern to select a method from a superclass when an unqualified `super` would resolve to an override defined in a trait (example in the commit as a test).
* | Merge pull request #5311 from szeiger/wip/raidAdriaan Moors2016-09-0516-518/+0
|\ \ | | | | | | Remove ant
| * | Remove the ant buildStefan Zeiger2016-09-0216-518/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove ant scripts. - Remove shell scripts that were specific to the ant build or the old `*.desired.sha1` binary artifact management. - Remove `build.number`. - Remove `src/build/maven` and `src/build/bnd`. The POM and Manifest metadata is generated in a different way by sbt.
* | | More elegant holders for local lazy vals.Adriaan Moors2016-09-023-44/+144
|/ /
* | Merge pull request #5369 from lrytz/sd210Lukas Rytz2016-09-0212-68/+126
|\ \ | | | | | | Fixes to mixin forwarders