summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/2.12.x' into ↵Jason Zaugg2016-02-045-145/+170
|\ | | | | | | merge/2.11.x-to-2.12.x-20160203
| * Merge pull request #4920 from lrytz/oldOptimizerTestsLukas Rytz2016-02-032-132/+151
| |\ | | | | | | restore / rewrite various tests
| | * rename -YoptTrace to -Yopt-traceLukas Rytz2016-02-031-1/+1
| | |
| | * Improve simplifyJumpsLukas Rytz2016-02-031-131/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve simplifyJumps to rewrite IFEQ L4 L5 GOTO L6 to IFNE L6 L5 This rewrite is only correct if L5 is not the target of any jump instruction (otherwise, removing the GOTO would change semantics). Previously we did not do the rewrite if there was any label between the conditional jump and the goto (like L5). Now we track which labels are jump targets.
| * | Merge pull request #4737 from soc/SI-9315Lukas Rytz2016-02-033-13/+19
| |\ \ | | | | | | | | SI-9315 Desugar string concat to java.lang.StringBuilder ...
| | * | SI-9315 Desugar string concat to java.lang.StringBuilder ...Simon Ochsenreither2016-02-033-13/+19
| | |/ | | | | | | | | | | | | | | | ... instead of scala.collection.mutable.StringBuilder to benefit from JVM optimizations. Unfortunately primitives are already boxed in erasure when they end up in this part of the backend.
* | | Merge commit 'cc6fea6' into merge/2.11.x-to-2.12.x-20160203Jason Zaugg2016-02-043-35/+58
|\ \ \ | | | | | | | | | | | | | | | | | | | | Conflicts: build.sbt scripts/jobs/integrate/bootstrap
| * | | SI-9572 Check for illegal tuple sizes in the parserStefan Zeiger2016-01-283-35/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds explicit checks with syntax errors for tuple literals and types of more than 22 elements. An alternative approach to fixing SI-9572 would be to revert to the old failure mode of Scala 2.10 where references to arbitrary `scala.TupleXY` would be generated in the parser, which then leads to “type/object not found” errors in the typechecker. This fix here is more intrusive but arguably provides a better user experience. Methods `stripParens` and `makeBinop` are moved from `TreeBuilder` to `Parsers` because they can now generate syntax errors. New methods `makeSafeTupleType` and `makeSafeTupleTerm` implement the error checking on top of `makeTupleType` and `makeTupleTerm`. They are overridden with no-op versions in the quasiquotes parser because it also overrides `makeTupleType` and `makeTupleTerm` in a way that supports arbitrary tuple sizes.
| * | | Merge pull request #4899 from som-snytt/issue/9616Jason Zaugg2016-01-191-12/+15
| |\ \ \ | | | | | | | | | | [backport] SI-9616 False positive in unused import warning
| | * | | [backport] SI-9616 False positive in unused import warningSom Snytt2016-01-071-12/+15
| | | | | | | | | | | | | | | | | | | | This is a minimal backport of the fix for SI-9383.
* | | | | Merge commit 'bf599bc' into merge/2.11.x-to-2.12.x-20160203Jason Zaugg2016-02-036-8/+20
|\| | | | | |_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala src/compiler/scala/tools/nsc/transform/Constructors.scala src/compiler/scala/tools/nsc/typechecker/Contexts.scala src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala src/scaladoc/scala/tools/nsc/doc/html/resource/lib/jquery.layout.js
| * | | Fix some simple extra wordsEitan Adler2016-01-177-7/+7
| |/ / | | | | | | | | | The the word 'the' is often used twice. Fix that.
| * | SI-9567 Fix pattern match on 23+ param, method local case classJason Zaugg2015-11-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Typechecking constructor patterns of method local case classes was only working because of the existence of the unapply method in the companion, which is used if navigation to the case class companion object fails. We now support defintion of, and pattern matching on, case classes with more than 22 parameters. These have no `unapply` method in the companion, as we don't have a large enough tuple type to return. So for such case classes, the fallback that we inadvertently relied on would no longer save us, and we'd end up with a compile error advising that the identifier in the constructor pattern was neither a case class nor an extractor. This is due to the propensity of `Symbol#companionXxx` to return `NoSymbol` when in the midst of typechecking. That method should only be relied upon after typechecking. During typechecking, `Namers#companionSymbolOf` should be used instead, which looks in the scopes of enclosing contexts for symbol companionship. That's what I've done in this commit.
| * | SI-9567 Fix latent bugs in patmat's reasoning about mutabilityJason Zaugg2015-11-251-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under -optimize, the pattern matcher tries to avoid local variables in favour of directly accessing to non-var case class accessors. However, the code that analysed the patterns failed to account properly for repeated parameters, which could either lead to a compiler crash (when assuming that the n-th subpattern must have a corresponding param accessor), or could lead to a correctness problem (when failing to eagerly the bound elements from the sequence.) The test case that tried to cover seems only to have been working because of a separate bug (the primary subject of SI-9567) related to method-local case classes: they were treated during typechecking as extractors, rather than native case classes. The subsequent commit will fix that problem, but first we must pave the way with this commit that emits local vals for bound elements of case class repeated params.
* | | Merge pull request #4926 from lrytz/scalaTreeMapJason Zaugg2016-02-011-6/+4
|\ \ \ | | | | | | | | mutable.TreeMap instead of java.util.TreeMap in closure optimizer
| * | | mutable.TreeMap instead of java.util.TreeMap in closure optimizerLukas Rytz2016-01-281-6/+4
| | | |
* | | | Merge pull request #4917 from retronym/ticket/9629Jason Zaugg2016-01-291-4/+4
|\ \ \ \ | | | | | | | | | | SI-9629 Emit missing 'pattern must be a value' error
| * | | | SI-9629 Emit missing 'pattern must be a value' errorJason Zaugg2016-01-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The error used to only be emitted for top-level patterns. This commit moves it into `typedInternal` so it works for nested patterns. It uses the typer mode to know when to fire.
* | | | | Merge pull request #4919 from retronym/ticket/9630Jason Zaugg2016-01-294-9/+16
|\ \ \ \ \ | |_|/ / / |/| | | | Pattern Matching analysis improvements
| * | | | Avoid exhaustivity warning in typedTemplateJason Zaugg2016-01-291-1/+1
| | | | |
| * | | | Fix non-exhaustive match in macro code parsingJason Zaugg2016-01-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` ⚡ qscala -deprecation Welcome to Scala 2.12.0-20160126-000825-1e302b76aa (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_66). Type in expressions for evaluation. Or try :help. scala> import reflect.macros.blackbox.Context; import language.experimental.macros import reflect.macros.blackbox.Context import language.experimental.macros scala> def impl(c: Context) = {println(c.universe.showRaw(c.parse("val then = 0"))); c.literalUnit}; def m: Unit = macro impl; <console>:13: warning: method literalUnit in trait ExprUtils is deprecated: Use quasiquotes instead def impl(c: Context) = {println(c.universe.showRaw(c.parse("val then = 0"))); c.literalUnit}; def m: Unit = macro impl; ^ impl: (c: scala.reflect.macros.blackbox.Context)c.Expr[Unit] defined term macro m: Unit scala> m <console>:16: error: exception during macro expansion: scala.MatchError: pos: source-<macro>,line-1,offset=4 then is now a reserved word; usage as an identifier is deprecated WARNING (of class scala.tools.nsc.reporters.StoreReporter$Info) at scala.reflect.macros.contexts.Parsers$class.scala$reflect$macros$contexts$Parsers$class$$$anonfun$1(Parsers.scala:17) ```
| * | | | SI-9398 Treat case classes as one-element ADTs for analysisJason Zaugg2016-01-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, exhaustivity analysis only runs for scrutinees with a sealed type. This commit treats any case class as a one-element, sealed type to enable additional analysis, such as in the new test case.
| * | | | SI-9630 Fix spurious warning related to same-named case accessorsJason Zaugg2016-01-292-7/+11
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hash consing of trees within pattern match analysis was broken, and considered `x1.foo#1` to be the same tree as `x1.foo#2`, even though the two `foo`-s referred to different symbols. The hash consing was based on `Tree#correspondsStructure`, but the predicate in that function cannot veto correspondance, it can only supplement the default structural comparison. I've instead created a custom tree comparison method for use in the pattern matcher that handles the tree shapes that we use.
* / | | Ensure bytecode stability in the closure optimizerLukas Rytz2016-01-271-38/+33
|/ / / | | | | | | | | | | | | | | | | | | | | | https://github.com/scala/scala-dev/issues/77 Previously, the order in which closure invocations were re-written depended on the callGraph's closureInstantiations map, which is not sorted / linked.
* | | Merge pull request #4735 from soc/SI-9437Lukas Rytz2016-01-263-6/+32
|\ \ \ | | | | | | | | SI-9437 Emit and support parameter names in class files
| * | | SI-9437 Emit and support parameter names in class filesSimon Ochsenreither2016-01-253-6/+32
| |/ / | | | | | | | | | | | | | | | | | | | | | JEP 118 added a MethodParameters attribute to the class file spec which holds the parameter names of methods when compiling Java code with `javac -parameters`. We emit parameter names by default now.
* | | -YoptTrace takes a package/Class.method parameterLukas Rytz2016-01-252-2/+3
| | |
* | | Merge remote-tracking branch 'upstream/2.12.x' into opt/elimBoxesLukas Rytz2016-01-24118-16484/+1376
|\| |
| * | Merge pull request #4903 from som-snytt/issue/9622Jason Zaugg2016-01-181-9/+10
| |\ \ | | | | | | | | SI-9622 Native method may be private
| | * | SI-9622 Native method may be privateSom Snytt2016-01-131-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | This was lost in a refactor. https://github.com/scala/scala/commit/290f687fb6ab91b6aef62d871036ddc3829f12b4
| * | | SI-8700 Exhaustiveness warning for enums from Java sourceSimon Ochsenreither2016-01-144-13/+10
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, the warning was only emitted for enums from Java class files. This commit fixes it by - aligning the flags set in JavaParsers with the flags set in ClassfileParser (which are required by the pattern matcher to even consider checking exhaustiveness) - adding the enum members as childs to the class holding the enum as done in ClassfileParser so that the pattern matcher sees the enum members when looking for the sealed children of a type
| * | Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-1862-150/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Language imports are preceding other imports - Deleted empty file: InlineErasure - Removed some unused private[parallel] methods in scala/collection/parallel/package.scala This removes hundreds of warnings when compiling with "-Xlint -Ywarn-dead-code -Ywarn-unused -Ywarn-unused-import".
| * | Merge pull request #4729 from retronym/topic-trait-defaults-moduleLukas Rytz2015-12-186-66/+83
| |\ \ | | | | | | | | Desugar module var and accessor in refchecks/lazyvals
| | * | Avoid tree sharing in lazy val translationJason Zaugg2015-11-232-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The `cond` tree is used in two places, so make it a by-name parameter to create distinct Trees. Also, remove a dangling comment.
| | * | Desugar module var and accessor in refchecks/lazyvalsJason Zaugg2015-10-086-62/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than leaving it until mixin. The broader motivation is to simplify the mixin phase of the compiler before we get rid of implementatation classes in favour of using JDK8 default interface methods. The current code in mixin is used for both lazy val and modules, and puts the "slow path" code that uses the monitor into a dedicated method (`moduleName$lzyCompute`). I tracked this back to a3d4d17b77. I can't tell from that commit whether the performance sensititivity was related to modules or lazy vals, from the commit message I'd say the latter. As the initialization code for a module is just a constructor call, rather than an arbitraryly large chunk of code for a lazy initializer, this commit opts to inline the `lzycompute` method. During refchecks, mixin module accessors are added to classes, so that mixed in and defined modules are translated uniformly. Trait owned modules get an accessor method with an empty body (that shares the module symbol), but no module var. Defer synthesis of the double checked locking idiom to the lazyvals phase, which gets us a step closer to a unified translation of modules and lazy vals. I had to change the `atOwner` methods to to avoid using the non-existent module class of a module accessor method as the current owner. This fixes a latent bug. Without this change, retypechecking of the module accessor method during erasure crashes with an accessibility error selecting the module var. In the process, I've tweaked a tree generation utility method to wvoid synthesizing redundant blocks in module desugaring.
| * | | Update some phase listsSimon Ochsenreither2015-11-252-2/+2
| | | |
| * | | Remove unused cunit parameter / field in GenBCodeLukas Rytz2015-11-252-18/+7
| | | |
| * | | Merge pull request #4863 from retronym/topic/leaner-patmat-codegenLukas Rytz2015-11-241-1/+9
| |\ \ \ | | | | | | | | | | DRY-er trees in pattern matcher code gen.
| | * | | DRY-er trees in pattern matcher code gen.Jason Zaugg2015-11-241-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than building a cascade of if/elses, push additional conditions into a conjunction in the condition of a single if/else. This is possible when emitting conditions for the list of arguments of a pattern. Here's an example of the improvement to post-pattern matcher trees: https://gist.github.com/retronym/0d8f7126157061d72b81 While we could try to rely on the optimizer to coalesce the repeated else clauses, it seems wasteful to emit the code in that way in the first place.
| * | | | Merge commit '8eb1d4c' into merge-2.11-to-2.12-nov-24Lukas Rytz2015-11-247-12/+12
| |\ \ \ \ | | |/ / / | |/| | / | | | |/ | | |/|
| | * | Merge pull request #4839 from SethTisue/reword-dependent-type-errorSeth Tisue2015-11-141-1/+1
| | |\ \ | | | | | | | | | | less confusing wording for a dependent method type error
| | | * | less confusing wording for a dependent method type errorSeth Tisue2015-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | note to reviewers: the error messages in this file are over the place about whether they're called "parameter sections", or "argument lists", or what, so there's no point in being picky about that here for context see SI-823
| | * | | Merge pull request #4809 from wpopielarski/delambdafy-multiple-outputsJason Zaugg2015-11-132-5/+5
| | |\ \ \ | | | | | | | | | | | | Multi output problem with delambdafied compilation
| | | * | | Sets source for newly created lambda classwpopielarski2015-11-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This source is then used to figure out output folder for compilation product.
| | | * | | Allows to propagate fatal errors when output folder not found.wpopielarski2015-11-052-23/+8
| | | | | |
| | | * | | Multi output problem with delambdafied compilationwpopielarski2015-11-042-9/+23
| | | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | User code compilation with -Ybackend:GenBCode -Ydelambdafy:method fails for projects with multiple output directories. The problem has its root in a fact that some `lambdaClass` symbols the `associatedFile` field is not set. It can be done in Delambdafy.scala (`makeAnonymousClass` method) and is working for following lambda examples: {{{ package acme object Delambdafy { type -->[D, I] = PartialFunction[D, I] def main(args: Array[String]): Unit = { val result = List(1, 2, 4).map { a => val list = List("1", "2", "3").map { _ + "test" } list.find { _ == a.toString + "test" } } lazy val _foo = foo(result) { case x::xs if x isDefined => x.get.length case _ => 0 } lazy val bar: Int => Int = { case 2 => 13 case _ => val v = List(1).map(_ + 42).head v + 1 } } def foo(b: List[Option[String]])(a: List[Option[String]] => Int): Int = a(b) } }}} but is NOT working for following lambda: {{{ package acme object Delambdafy { type -->[D, I] = PartialFunction[D, I] def main(args: Array[String]): Unit = { lazy val _baz = baz { case 1 => val local = List(1).map(_ + 1) local.head } } def baz[T](f: Any --> Any): Any => Any = f } }}} so that's why source of compilation unit is used to determine output directory in case when source file is not found for symbol.
| | * / / it's Scaladoc, not "ScalaDoc" or "Scala doc"Seth Tisue2015-11-124-6/+6
| | |/ / | | | | | | | | | | | | | | | | renaming the existing ScalaDoc and ScalaDocReporter classes might break stuff, sadly, but at least we can fix the rest
| * | | Fix some small warnings that pop up on every compileSimon Ochsenreither2015-11-192-3/+3
| | | |
| * | | Merge pull request #4842 from adriaanm/fields-prepAdriaan Moors2015-11-1912-409/+420
| |\ \ \ | | | | | | | | | | Set the scene for phase 1 of the new trait encoding.
| | * | | 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.