summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/Constructors.scala
Commit message (Collapse)AuthorAgeFilesLines
* SI-10093 don't move member traits to constructor body in constructorsLukas Rytz2016-12-061-5/+5
| | | | | | | | | | | | | | | | Fixes a regression introduced in c8e6050. Member traits with only abstract definitions (`isInterface`) were moved into the primary constructor by mistake. (Flatten moved the classes back.) The member trait was duplicated into the constructor of specialized subclasses, causing it to be generated multiple times. Also removes some unnecessary `isMixinConstructor` checks: the mixin constructor is always the primary constructor. This commit also clarifies (and tests) what `isInterface` means: for scala-defined traits, it means there are only abstract members. For java-defined interfaces, it is always true.
* Detect clash of mixedin val and existing member.Adriaan Moors2016-10-121-7/+13
| | | | | | | | | 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
* 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.
* Fields does bitmaps & synch for lazy vals & modulesAdriaan Moors2016-08-291-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Essentially, we fuse mixin and lazyvals into the fields phase. With fields mixing in trait members into subclasses, we have all info needed to compute bitmaps, and thus we can synthesize the synchronisation logic as well. By doing this before erasure we get better signatures, and before specialized means specialized lazy vals work now. Mixins is now almost reduced to its essence: implementing super accessors and forwarders. It still synthesizes accessors for param accessors and early init trait vals. Concretely, trait lazy vals are mixed into subclasses with the needed synchronization logic in place, as do lazy vals in classes and methods. Similarly, modules are initialized using double checked locking. Since the code to initialize a module is short, we do not emit compute methods for modules (anymore). For simplicity, local lazy vals do not get a compute method either. The strange corner case of constant-typed final lazy vals is resolved in favor of laziness, by no longer assigning a constant type to a lazy val (see widenIfNecessary in namers). If you explicitly ask for something lazy, you get laziness; with the constant-typedness implicit, it yields to the conflicting `lazy` modifier because it is explicit. Co-Authored-By: Lukas Rytz <lukas@lightbend.com> Fixes scala/scala-dev#133 Inspired by dotc, desugar a local `lazy val x = rhs` into ``` val x$lzy = new scala.runtime.LazyInt() def x(): Int = { x$lzy.synchronized { if (!x$lzy.initialized) { x$lzy.initialized = true x$lzy.value = rhs } x$lzy.value } } ``` Note that the 2.11 decoding (into a local variable and a bitmap) also creates boxes for local lazy vals, in fact two for each lazy val: ``` def f = { lazy val x = 0 x } ``` desugars to ``` public int f() { IntRef x$lzy = IntRef.zero(); VolatileByteRef bitmap$0 = VolatileByteRef.create((byte)0); return this.x$1(x$lzy, bitmap$0); } private final int x$lzycompute$1(IntRef x$lzy$1, VolatileByteRef bitmap$0$1) { C c = this; synchronized (c) { if ((byte)(bitmap$0$1.elem & 1) == 0) { x$lzy$1.elem = 0; bitmap$0$1.elem = (byte)(bitmap$0$1.elem | 1); } return x$lzy$1.elem; } } private final int x$1(IntRef x$lzy$1, VolatileByteRef bitmap$0$1) { return (byte)(bitmap$0$1.elem & 1) == 0 ? this.x$lzycompute$1(x$lzy$1, bitmap$0$1) : x$lzy$1.elem; } ``` An additional problem with the above encoding is that the `lzycompute` method synchronizes on `this`. In connection with the new lambda encoding that no longer generates anonymous classes, captured lazy vals no longer synchronize on the lambda object. The new encoding solves this problem (scala/scala-dev#133) by synchronizing on the lazy holder. Currently, we don't exploit the fact that the initialized field is `@volatile`, because it's not clear the performance is needed for local lazy vals (as they are not contended, and as soon as the VM warms up, biased locking should deal with that) Note, be very very careful when moving to double-checked locking, as this needs a different variation than the one we use for class-member lazy vals. A read of a volatile field of a class does not necessarily impart any knowledge about a "subsequent" read of another non-volatile field of the same object. A pair of volatile reads and write can be used to implement a lock, but it's not clear if the complexity is worth an unproven performance gain. (Once the performance gain is proven, let's change the encoding.) - don't explicitly init bitmap in bytecode - must apply method to () explicitly after uncurry
* LambdaLift emits paramaccessor syms and defdefsAdriaan Moors2016-08-111-6/+14
| | | | | | | | | | | ... instead of emitting ValDefs and field symbols, which are then promptly unlinked and transformed by the "late trait methods" logic in mixins... Mixins still synthesizes implementations for these accessors in subclasses. A paramaccessor in a trait is a method without an underlying field.
* Fields phaseAdriaan Moors2016-08-111-82/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One step towards teasing apart the mixin phase, making each phase that adds members to traits responsible for mixing in those members into subclasses of said traits. Another design tenet is to not emit symbols or trees only to later remove them. Therefore, we model a val in a trait as its accessor. The underlying field is an implementation detail. It must be mixed into subclasses, but has no business in a trait (an interface). Also trying to reduce tree creation by changing less in subtrees during tree transforms. A lot of nice fixes fall out from this rework: - Correct bridges and more precise generic signatures for mixed in accessors, since they are now created before erasure. - Correct enclosing method attribute for classes nested in trait fields. Trait fields are now created as MethodSymbol (no longer TermSymbol). This symbol shows up in the `originalOwner` chain of a class declared within the field initializer. This promoted the field getter to being the enclosing method of the nested class, which it is not (the EnclosingMethod attribute is a source-level property). - Signature inference is now more similar between vals and defs - No more field for constant-typed vals, or mixed in accessors for subclasses. A constant val can be fully implemented in a trait. TODO: - give same treatment to trait lazy vals (only accessors, no fields) - remove support for presuper vals in traits (they don't have the right init semantics in traits anyway) - lambdalift should emit accessors for captured vals in traits, not a field Assorted notes from the full git history before squashing below. Unit-typed vals: don't suppress field it affects the memory model -- even a write of unit to a field is relevant... unit-typed lazy vals should never receive a field this need was unmasked by test/files/run/t7843-jsr223-service.scala, which no longer printed the output expected from the `0 to 10 foreach` Use getter.referenced to track traitsetter reify's toolbox compiler changes the name of the trait that owns the accessor between fields and constructors (`$` suffix), so that the trait setter cannot be found when doing mkAssign in constructors this could be solved by creating the mkAssign tree immediately during fields anyway, first experiment: use `referenced` now that fields runs closer to the constructors phase (I tried this before and something broke) Infer result type for `val`s, like we do for `def`s The lack of result type inference caused pos/t6780 to fail in the new field encoding for traits, as there is no separate accessor, and method synthesis computes the type signature based on the ValDef tree. This caused a cyclic error in implicit search, because now the implicit val's result type was not inferred from the super member, and inferring it from the RHS would cause implicit search to consider the member in question, so that a cycle is detected and type checking fails... Regardless of the new encoding, we should consistently infer result types for `def`s and `val`s. Removed test/files/run/t4287inferredMethodTypes.scala and test/files/presentation/t4287c, since they were relying on inferring argument types from "overridden" constructors in a test for range positions of default arguments. Constructors don't override, so that was a mis-feature of -Yinfer-argument-types. Had to slightly refactor test/files/presentation/doc, as it was relying on scalac inferring a big intersection type to approximate the anonymous class that's instantiated for `override lazy val analyzer`. Now that we infer `Global` as the expected type based on the overridden val, we make `getComment` private in navigating between good old Skylla and Charybdis. I'm not sure why we need this restriction for anonymous classes though; only structural calls are restricted in the way that we're trying to avoid. The old behavior is maintained nder -Xsource:2.11. Tests: - test/files/{pos,neg}/val_infer.scala - test/files/neg/val_sig_infer_match.scala - test/files/neg/val_sig_infer_struct.scala need NMT when inferring sig for accessor Q: why are we calling valDefSig and not methodSig? A: traits use defs for vals, but still use valDefSig... keep accessor and field info in synch
* SI-9390 Avoid needless outer capture with local classesJason Zaugg2016-06-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An existing optimization in `Constructors` elides the outer field in member and local classes, if the class doesn't use the outer reference. (Member classes also need to be final, which is a secret handshake to say we're also happy to weaken prefix matching in the pattern matcher.) That optimization leaves the constructor signature as is: the constructor still accepts the outer instance, but does not store it. For member classes, this means that we can separately compile code that calls the constructor. Local classes need not be hampered by this constraint, we could remove the outer instance from the constructor call too. Why would we want to do this? Let's look at the case before and after this commit. Before: ``` class C extends Object { def foo(): Function1 = $anonfun(); final <static> <artifact> def $anonfun$foo$1($this: C, x: Object): Object = new <$anon: Object>($this); def <init>(): C = { C.super.<init>(); () } }; final class anon$1 extends Object { def <init>($outer: C): <$anon: Object> = { anon$1.super.<init>(); () } } ``` After: ``` class C extends Object { def foo(): Function1 = $anonfun(); final <static> <artifact> def $anonfun$foo$1(x: Object): Object = new <$anon: Object>(null); def <init>(): C = { C.super.<init>(); () } }; final class anon$1 extends Object { def <init>($outer: C): <$anon: Object> = { anon$1.super.<init>(); () } } ``` However, the status quo means that a lambda that This in turn makes lambdas that refer to such classes serializable even when the outer class is not itself serialiable. I have not attempted to extend this to calls to secondary constructors.
* Specialization precludes use of LambdaMetaFactory for SAMAdriaan Moors2016-03-291-4/+2
| | | | | | | | | | | | | When a SAM type is specialized (i.e., a specialized type parameter receives a specialized type argument), do not use LambdaMetaFactory (expand during Uncurry instead). This is an implementation restriction -- the current specialization scheme is not amenable to using LambdaMetaFactory to spin up subclasses. Since the generic method is abstract, and the specialized ones are concrete, specialization is rendered moot because we cannot implement the specialized method with the lambda using LMF.
* Merge pull request #5043 from dongjoon-hyun/fix_typos_in_spec_and_commentsJason Zaugg2016-03-211-1/+1
|\ | | | | Fix some typos in `spec` documents and comments.
| * Fix some typos in `spec` documents and comments.Dongjoon Hyun2016-03-151-1/+1
| |
* | Remove manual mixins in JFunctionN.v2.12.0-M3-dc9effeJason Zaugg2016-03-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These manual mixins were forwarding to the impl classes have just been removed. We can now rely on default methods instead. Update Tests: - Fix test/files/pos/t1237.scala, we can't have an outer field in an interface, always use the outer method. - Don't crash on meaningless trait early init fields test/files/neg/t2796.scala - Remove impl class relate parts of inner class test - Remove impl class relate parts of elidable test - Remove impl class related reflection test. - Remove test solely about trait impl classes renaming - Update check file with additional stub symbol error - Disable unstable parts of serialization test. - TODO explain, and reset the expectation
* | New trait encoding: use default methods, jettison impl classesJason Zaugg2016-03-181-7/+9
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, concrete methods in traits were encoded with "trait implementation classes". - Such a trait would compile to two class files - the trait interface, a Java interface, and - the implementation class, containing "trait implementation methods" - trait implementation methods are static methods has an explicit self parameter. - some methods don't require addition of an interface method, such as private methods. Calls to these directly call the implementation method - classes that mixin a trait install "trait forwarders", which implement the abstract method in the interface by forwarding to the trait implementation method. The new encoding: - no longer emits trait implementation classes or trait implementation methods. - instead, concrete methods are simply retained in the interface, as JVM 8 default interface methods (the JVM spec changes in [JSR-335](http://download.oracle.com/otndocs/jcp/lambda-0_9_3-fr-eval-spec/index.html) pave the way) - use `invokespecial` to call private or particular super implementations of a method (rather `invokestatic`) - in cases when we `invokespecial` to a method in an indirect ancestor, we add that ancestor redundantly as a direct parent. We are investigating alternatives approaches here. - we still emit trait fowrarders, although we are [investigating](https://github.com/scala/scala-dev/issues/98) ways to only do this when the JVM would be unable to resolve the correct method using its rules for default method resolution. Here's an example: ``` trait T { println("T") def m1 = m2 private def m2 = "m2" } trait U extends T { println("T") override def m1 = super[T].m1 } class C extends U { println("C") def test = m1 } ``` The old and new encodings are displayed and diffed here: https://gist.github.com/retronym/f174d23f859f0e053580 Some notes in the implementation: - No need to filter members from class decls at all in AddInterfaces (although we do have to trigger side effecting info transformers) - We can now emit an EnclosingMethod attribute for classes nested in private trait methods - Created a factory method for an AST shape that is used in a number of places to symbolically bind to a particular super method without needed to specify the qualifier of the `Super` tree (which is too limiting, as it only allows you to refer to direct parents.) - I also found a similar tree shape created in Delambdafy, that is better expressed with an existing tree creation factory method, mkSuperInit.
* Fix some small warnings that pop up on every compileSimon Ochsenreither2015-11-191-1/+1
|
* Clean up a bit more in Constructors.Adriaan Moors2015-11-121-12/+12
| | | | | | Comment about my poor naming choice in Types. NullaryMethodType sounds like the method has one empty argument list, whereas it really has no argument lists at all.
* Review feedback from lrytz: better commentsAdriaan Moors2015-11-111-12/+12
|
* Constructors: encapsulate whether to memoize a valAdriaan Moors2015-11-111-10/+14
| | | | | | | Triggered by sjrd's review, it turns out that we forgot to unlink the symbol for omittable ValDefs. I left the fix in a comment in the margin, since this commit is meant to be bytecode-compatible.
* Constructors: further clarify which defs are added & whenAdriaan Moors2015-11-111-1/+5
| | | | | Move conditions and template derivation back to the call sites of `staticConstructor` (formerly `addStaticInits`).
* Constructors: mutate lessAdriaan Moors2015-11-111-112/+98
| | | | | Codify the scope of mutability for various buffers, inline one-time methods, further reduce spooky action at a distance.
* Constructors: consolidate `ValDef` cases in `transformed`Adriaan Moors2015-11-111-19/+27
| | | | | When we change the encoding of fields in traits, this will come in handy...
* Constructors: narrow interfaces of its componentsAdriaan Moors2015-11-111-150/+161
| | | | | | Limit communication between traits using ConstructorTransformerBase interface. Make Constructors a bit less of a test case for itself, by making a bunch of fields local variables of the `transformed` method.
* Merge remote-tracking branch 'origin/2.11.x' into 2.12.xSeth Tisue2015-09-081-1/+1
| | | | | | | | only trivial merge conflicts here. not dealing with PR #4333 in this merge because there is a substantial conflict there -- so that's why I stopped at 63daba33ae99471175e9d7b20792324615f5999b for now
* Uncurry does Literal RHS for ConstantType def, not ConstructorsAdriaan Moors2015-08-241-13/+3
| | | | | | | | | Uncurry seems more logical to me. Ideally, Erasure would erase ConstantTypes, since they do not exist in bytecode. In any case, doing this earlier, when we're rewriting method anyway, simplifies constructors, which should be focussing on, well, constructors (& fields).
* Clean up Constructors a bit.Adriaan Moors2015-08-241-96/+90
| | | | | | | Shouldn't change behavior, sets stage for moving the transform of ConstantType methods to Uncurry. Constructors still needs a much more thorough overhaul...
* SI-9408 Avoid capturing outer class in local classes.Jason Zaugg2015-07-231-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, only local classes declared final would be candidates for outer pointer elision in the constructor phase. This commit infers finality of local classes to expand the scope of this optimization. == Background == This was brought to our attention when shapeless enabled indylambda and found that a hitherto serializable data structure started to capture the enclosing class and hence lost its serializability. class NotSerializable { def test = () => { class C; assertSerializable(new C) } } Under `-Ydelambdafy:inline`, it used to capture the enclosing anon function class as its outer, which, being final, didn't in turn capture the enclosing class. class NotSerializable { def test = new anonFun$1 } class anonFun$1 { def apply = assertSerializable(new C(this)) } class ...$C(outer$: anonFun) indylambda perturbs the enclosing structure of the function body. class NotSerializable { def anonFun$1 = {class C; assertSerializable(new C())) def test = lambdaMetaFactory(<<anonFun$1>>) } Which leads to: class NotSerializable$C(outer$: NotSerializable)
* Refactor to avoid duplicated work in ConstructorsJason Zaugg2015-07-231-3/+5
| | | | | | - Check if the clazz that owns all the decls we're filtering is effectively final once, rather than for each decl. - Query the full set of decls once.
* Fix many typosMichał Pociecha2015-04-211-1/+1
| | | | | This commit corrects many typos found in scaladocs and comments. There's also fixed the name of a private method in ICodeCheckers.
* Removed warningsEECOLOR2015-03-261-0/+1
| | | | | | | | | | | | | | | | | | | | | - Added `since` to deprecation statement - Added unit to parameter list - Removed usage of deprecated method polyType - Replaced deprecated `debugwarn` with `devWarning` - Changed switch statement to if else in order to remove a warning - Switched implementation of `init` and `processOptions` to prevent warning - Replaced deprecated `Console.readLine` with `scala.io.StdIn.readLine` - Replaced deprecated `startOrPoint` with `start` - Replaced deprecated `tpe_=` with `setType` - Replaced deprecated `typeCheck` with `typecheck` - Replaced deprecated `CompilationUnit.warning` with `typer.context.warning` - Replaced deprecated `scala.tools.nsc.util.ScalaClassLoader` with `scala.reflect.internal.util.ScalaClassLoader` - Replaced deprecated `scala.tools.ListOfNil` with `scala.reflect.internal.util.ListOfNil` - Replaced deprecated `scala.tools.utils.ScalaClassLoader` with `scala.reflect.internal.util.ScalaClassLoader` - Replaced deprecated `emptyValDef` with `noSelfType` - In `BoxesRunTime` removed unused method and commented out unused values. Did not delete to keep a reference to the values. If they are deleted people might wonder why `1` and `2` are not used. - Replaced deprecated `scala.tools.nsc.util.AbstractFileClassLoader` with `scala.reflect.internal.util.AbstractFileClassLoader`
* Fix many typos in docs and commentsmpociecha2014-12-141-1/+1
| | | | | | | | | | | | | This commit corrects many typos found in scaladocs, comments and documentation. It should reduce a bit number of PRs which fix one typo. There are no changes in the 'real' code except one corrected name of a JUnit test method and some error messages in exceptions. In the case of typos in other method or field names etc., I just skipped them. Obviously this commit doesn't fix all existing typos. I just generated in IntelliJ the list of potential typos and looked through it quickly.
* Rip out reporting indirection from CompilationUnitAdriaan Moors2014-07-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inline the forwarders from CompilationUnit, which should not affect behavior. Since all forwarders lead to global.reporter, don't first navigate to a compilation unit, only to then forward back to global.reporter. The cleanup in the previous commits revealed a ton of confusion regarding how to report an error. This was a mechanical search/replace, which has low potential for messing things up, since the list of available methods are disjoint between `reporter` and `currentRun.reporting`. The changes involving `typer.context` were done previously. Essentially, there are three ways to report: - via typer.context, so that reporting can be silenced (buffered) - via global.currentRun.reporting, which summarizes (e.g., deprecation) - via global.reporter, which is (mostly) stateless and straightforward. Ideally, these should all just go through `global.currentRun.reporting`, with the typing context changing that reporter to buffer where necessary. After the refactor, these are the ways in which we report (outside of typer): - reporter.comment - reporter.echo - reporter.error - reporter.warning - currentRun.reporting.deprecationWarning - currentRun.reporting.incompleteHandled - currentRun.reporting.incompleteInputError - currentRun.reporting.inlinerWarning - currentRun.reporting.uncheckedWarning Before: - c.cunit.error - c.enclosingUnit.deprecationWarning - context.unit.error - context.unit.warning - csymCompUnit.warning - cunit.error - cunit.warning - currentClass.cunit.warning - currentIClazz.cunit.inlinerWarning - currentRun.currentUnit.error - currentRun.reporting - currentUnit.deprecationWarning - currentUnit.error - currentUnit.warning - getContext.unit.warning - getCurrentCUnit.error - global.currentUnit.uncheckedWarning - global.currentUnit.warning - global.reporter - icls.cunit.warning - item.cunit.warning - reporter.comment - reporter.echo - reporter.error - reporter.warning - reporting.deprecationWarning - reporting.incompleteHandled - reporting.incompleteInputError - reporting.inlinerWarning - reporting.uncheckedWarning - typer.context.unit.warning - unit.deprecationWarning - unit.echo - unit.error - unit.incompleteHandled - unit.incompleteInputError - unit.uncheckedWarning - unit.warning - v1.cunit.warning All these methods ended up calling a method on `global.reporter` or on `global.currentRun.reporting` (their interfaces are disjoint). Also clean up `TypeDiagnostics`: inline nearly-single-use private methods.
* SI-7971 Handle static field initializers correctlySimon Ochsenreither2013-12-141-8/+18
| | | | | | | | | | | Before this fix, static fields where erroneously treated like instance fields and the initialization was moved into the constructor. With this fix, the static initializer statements go into the static initializer of the class (called “<STATIC> def init” in Scala, <clinit> in Java). The statements are added to an existing static initializer method or, if no such method exists, a new static initializer method is created and added to the class.
* SI-7678 Don't cache member symbols of TypeTags in Definitions.Jason Zaugg2013-11-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | It we can only safely use vals in Definitions for top-level symbols. Otherwise, when the IDE switches to loading the symbol from source, we can hold on to a stale symbol, which in turn impedes implicit materialization of TypeTags. This commit moves (most) of the accessors for member symbols into RunDefinitions, and changes calling code accordingly. This is a win for presentation compiler correctness, and might even shave of a few cycles. In a few cases, I have had to leave a `def` to a member symbol in Definitions so we can get to it from the SymbolTable cake, which doesn't see RunDefinitions. The macro FastTrack facility now correctly recreates the mapping from Symbol to macro implementation each run, using a new facility in perRunCaches to create a run-indexed cache. The enclosed test recreates the situation reported in the ticket, in which TypeTags.scala is loaded from source.
* make the postfixOps warning go awayDen Shabalin2013-09-051-1/+1
|
* Logging cleanup.Paul Phillips2013-08-251-2/+2
| | | | | | | | | | | | | | Reduced the amount of extraneous logging noise at the default logging level. Was brought to my usual crashing halt by the discovery of identical logging statements throughout GenASM and elsewhere. I'm supposing the reason people so grossly underestimate the cost of such duplication is that most of the effects are in things which don't happen, aka "silent evidence". An example of a thing which isn't happening is the remainder of this commit, which exists only in parallel universes.
* Golfed about 20 lines into the sand trap.Paul Phillips2013-08-081-37/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And it's a nice golf clinic and all, but let's remove our golf gloves and take in some film. for (stat <- defBuf.iterator ++ auxConstructorBuf.iterator) A quick count: - defBuf is a ListBuffer (1 mutant) - auxConstructorBuf is a ListBuffer (2 mutants) - two mutable iterators over mutable sequences (3, 4 mutants) - Iterator.++ joins them and is BY-NAME (4 mutants, 1 tragedy in waiting) - the joined Iterator is a new mutable structure (5 mutants, now 3 deep) - omittables is a mutable Set (6 mutants) - the 5-layer-3-deep iterator mutates omittables as it walks [The following is a public service breakdown. The letter sequence y-o-u is a local variable which should be replaced with your name, whoever "you" are, if you commit any code in these parts.] Hear my plea! YOU DON'T HAVE TO DO IT THIS WAY! It isn't simpler, faster, easier, more satisfying, shorter, more pixelated, there just isn't any advantage to it, even if you're lazy! Especially if you're lazy! Whatever combination of virtues and vices exist in your personal petri dish, this will never be a hilltop! PLEASE COME ENJOY A DRINK WITH ME AND MY FRIEND 'VAL' !! I'LL INTRODUCE YOU! I THINK YOU WILL REALLY LIKE HER! I HOPE YOU WILL SEE A LOT OF ONE ANOTHER! REMEMBER THAT NAME, 'VAL' !! SHE'LL HAVE HER EYE OUT FOR YOU!
* skipping trips to specializeTypes when not necessary in constructorsMiguel Garcia2013-08-081-3/+13
|
* separation of concerns: guard non-specialized ctor-stats in constructorsMiguel Garcia2013-08-081-115/+120
| | | | | | | | | | | | | This commit modularizes TemplateTransformer by moving two methods from TemplateTransformer into the newly added OmittablesHelper. The methods in question are: - mergeConstructors(genericClazz, originalStats, specializedStats) - guardSpecializedInitializer(stats) That way, the rewriting that introduces a guard for the execution of non-specialized ctor-statements is encapsulated in trait GuardianOfCtorStmts.
* better encapsulation in constructors phaseMiguel Garcia2013-08-081-3/+3
|
* readability for intoConstructors transformerMiguel Garcia2013-08-081-10/+32
|
* separation of concerns: eliding param-accessor fields in constructorsMiguel Garcia2013-08-081-115/+135
| | | | | | | | | | | | | | | | | | | | | | | This commit modularizes TemplateTransformer by moving a few members from TemplateTransformer into the newly added OmittablesHelper. The members in question include - a few methods: # isParamCandidateForElision(Symbol) # isOuterCandidateForElision(Symbol) # mustbeKept(Symbol) - a few vals: # paramCandidatesForElision # outerCandidatesForElision # bodyOfOuterAccessor - class UsagesDetector That way, all trace of rewriting to elide param-accessor fields has vanished from TemplateTransformer and is encapsulated in OmittablesHelper.
* separation of concerns: delayed-init in constructorsMiguel Garcia2013-08-081-134/+137
| | | | | | | | | | | | | | | This commit modularizes TemplateTransformer by moving a few methods from TemplateTransformer into the newly added DelayedInitHelper. The methods in question - delayedInitCall() - delayedInitClosure() - delayedEndpointDef() build trees that rewriteDelayedInit() puts together. That way, all trace of rewriting related to delayed-init have vanished from TemplateTransformer and are encapsulated in DelayedInitHelper.
* method transformClassTemplate() turned into class TemplateTransformerMiguel Garcia2013-08-081-575/+579
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, each activation of transformClassTemplate() performed the rewriting that the constructors phase is well-known for. Lots of auxialiary objects were created in the process, with lifetime confined to said activation. The same auxiliary objects (having same lifetimes as before) also are in effect starting with this commit, but now it's an instance of TemplateTransformer that holds them together. In other words, there's a one-to-one correspondence between: - (what used to be) transformClassTemplate() activation - TemplateTransformer initialization After initialization, the result of TemplateTransformer can be found in its `transformed` member val. In fact, the refactoring to get here from the previous commit basically involves taking the body of method transformClassTemplate() as-is to become the template of TemplateTransformer. The TemplateTransformer in question will allow modularizing sub-transformations (e.g., DelayedInit) into dedicated traits (see upcoming commits).
* eliding what the constructor phase elides but with less effort (2 of 2)Miguel Garcia2013-08-081-63/+1
| | | | | Removing the old implementation of elision in constructors in favor of the new one which is both faster, more readable.
* eliding what the constructor phase elides but with less effort (1 of 2)Miguel Garcia2013-08-081-2/+67
| | | | | | For now both old and new implementations of elision coexist, allowing cross-checking their results. In the next commit only the new one will remain.
* how stuff works: elision of param-accessor-fields and outer-accessorsMiguel Garcia2013-08-081-6/+64
|
* handling AnyVal special case early on to simplify logic afterwardsMiguel Garcia2013-08-081-6/+10
| | | | | | This way the contract of `transformClassTemplate()` can focus on non-AnyVal cases, which are more regular from the perspective of transforming their templates in the constructors phase.
* warn about uninitialized reads (in constructors), self-contained checkMiguel Garcia2013-08-081-37/+47
| | | | | | | The check in question relies on helper maps and methods that don't belong outside that check. This commit encapsulates those helpers into the newly added `checkUninitializedReads()` , thus uncluttering `transformClassTemplate()`
* SI-7592 Replace s.t.n.u.TreeSet with s.c.m.TreeSetSimon Ochsenreither2013-06-191-3/+3
| | | | | | | This means - migrating usages from the compiler-specific implementation to the one in the standard library - removing the now unused compiler-specific implementation
* Merge branch '2.10.x' into topic/merge-v2.10.2-RC1-35-ga54d86b-to-masterJason Zaugg2013-06-101-1/+4
|\ | | | | | | | | Conflicts: src/partest/scala/tools/partest/DirectTest.scala
| * SI-6841 Fix bug at the intersection of DelayedInit and named argsJason Zaugg2013-05-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DelayedInit transformation analyses the constructor to partition regular initialization from calls to super constructors / trait initializers. It failed to find such super calls if they were nested in a Block, which can happens when using named or default arguments. This commit makes that code peer into Blocks to correctly partition the constructor statements. This change doesn't affect the result of run/t4680.scala, which was mentioned in nearby comments and which chronicles bugs with DelayedInit when used in inheritance hierarchies.
* | Merge branch 'pr/merge-2.10.2' into masterPaul Phillips2013-06-041-594/+466
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * pr/merge-2.10.2: SI-7375 ClassTag for value class aliases SI-7507 Fix lookup of private[this] member in presence of self type. SI-7532 Fix regression in Java inner classfile reader SI-7517 Fix higher kinded type inference regression SI-7516 Revert "SI-7234 Make named args play nice w. depmet types" A test case for a recent LUB progression. SI-7421 remove unneeded extra-attachement in maven deploy SI-7486 Regressions in implicit search. SI-7509 Avoid crasher as erronous args flow through NamesDefaults SI-6138 Centralize and refine detection of `getClass` calls SI-7497 Fix scala.util.Properties.isMac SI-7473 Bad for expr crashes postfix Increase build.number to 2.10.3 SI-7391 Always use ForkJoin in Scala actors on ... ... Java 6 and above (except when the porperty actors.enableForkJoin says otherwise) Reimplementing much of the DefaultPromise methods Optimizations: 1) Avoiding to call 'synchronized' in tryComplete and in tryAwait 2) Implementing blocking by using an optimized latch so no blocking ops for non-blockers 3) Reducing method size of isCompleted to be cheaper to inline 4) 'result' to use Try.get instead of patmat c.typeCheck(silent = true) now suppresses ambiguous errors Conflicts: bincompat-backward.whitelist.conf bincompat-forward.whitelist.conf src/compiler/scala/reflect/macros/contexts/Typers.scala src/compiler/scala/reflect/reify/package.scala src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala src/compiler/scala/tools/nsc/typechecker/Typers.scala src/compiler/scala/tools/reflect/ToolBoxFactory.scala src/library/scala/concurrent/impl/Promise.scala src/reflect/scala/reflect/internal/Types.scala