summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #4770 from SethTisue/windows-testing-fixesLukas Rytz2015-10-052-2/+5
|\ | | | | get test suite passing on Windows
| * add missing newline at eof in Scala sourceSeth Tisue2015-09-251-1/+1
| | | | | | | | | | | | | | | | | | | | this was causing a mysterious compilation failure on Windows. (it may not have been a sufficient cause in itself -- which is why I say "mysterious" -- but in any case, adding the newline made the failure go away. and besides, the newline should be there. so here it is.) (it's tempting to make a big commit that fixes this in every source file. resisting for now)
| * fix bug where -Xprint-icode leaked an InputStream and a file handleSeth Tisue2015-09-251-1/+4
| | | | | | | | | | | | | | | | usually it hardly matters, but it's still a bug, and on Windows we can't delete an open file, so this can cause trouble for someone writing a test that relies on being able to generate icode files and then clean them up afterwards. (and in fact, two IcodeComparison-based tests were failing.)
* | Improve implicits wildcard imports in the IDEJason Zaugg2015-09-301-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 451cab967a, I changed handling of selection of members from package objects so as to correctly use `somePackage.package.type` as the prefix, rather than `somePackage`. This fixed generic substitution for members inherited from superclasses of the package object. However, this has subtly changed the scope from which we collect implicits given a wildcard import. It seems that the IDE gets into a situation after a scaladoc lookup, which temporarily typechecks the sources of a package object of a third party library, in which the members of package object differ from the members of the enclosing package. The upshot of this was spurious type errors due to implicit search discarding an candidate implicit whose symbol is not matched by typechecking an identifier with the symbol's name at the implicit usage site (this is how we discard shadowed implicits.) I'd like to ge to the bottom of this, but in the meantime, I've found that we can fix the regression by looking up the implicit member symbols in the package, even while correctly using the package object as the prefix.
* | Merge pull request #4720 from retronym/ticket/9029Jason Zaugg2015-09-293-31/+44
|\ \ | | | | | | SI-9029 Fix regression in extractor patterns
| * | SI-9029 Remove unused methodJason Zaugg2015-09-221-5/+0
| | |
| * | SI-8127 Remove dead code in UncurryJason Zaugg2015-09-211-7/+0
| | | | | | | | | | | | | | | It remains from the days of yore, when patterns survived this long in the compiler.
| * | SI-8989 Better error message for invalid extractor patternJason Zaugg2015-09-211-3/+8
| | |
| * | SI-9029 Fix regression in extractor patternsJason Zaugg2015-09-212-16/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The unified treatment of classical and named-based pattern matching does not correctly handle the generalization of "tuple capture". By "tuple capture", I mean: ``` scala> object Extractor { def unapply(a: Any): Option[(Int, String)] = Some((1, "2")) } defined object Extractor scala> "" match { case Extractor(x: Int, y: String) => } scala> "" match { case Extractor(xy : (Int, String)) => } warning: there was one deprecation warning; re-run with -deprecation for details scala> :warnings <console>:9: warning: object Extractor expects 2 patterns to hold (Int, String) but crushing into 2-tuple to fit single pattern (SI-6675) "" match { case Extractor(xy : (Int, String)) => } ^ ``` Name based pattern matching, new in Scala 2.11, allows one to deconstruct the elements that structurally resembles `ProductN`: ``` scala> class P2(val _1: Int, val _2: String) defined class P2 scala> object Extractor { def unapply(a: Any): Option[P2] = Some(new P2(1, "2")) } defined object Extractor scala> "" match { case Extractor(x: Int, y: String) => } ``` However, attempting to extract the `P2` in its entirety leads to an internal error: ``` scala> "" match { case Extractor(p2: P2) => } <console>:10: warning: fruitless type test: a value of type (Int, String) cannot also be a P2 "" match { case Extractor(p2: P2) => } ^ <console>:10: error: error during expansion of this match (this is a scalac bug). The underlying error was: type mismatch; found : P2 required: (Int, String) "" match { case Extractor(p2: P2) => } ^ ``` Note that this match was legal and warning free in 2.10. This commit avoids the hard-coded assumption that the "tuple capture" results in a `TupleN`, and instead keeps track of the product-ish type from which we extracted the element types. I have also opted not to limit the deprecation warning to `TupleN` extractors.
* | | Merge pull request #4674 from kirillkh/2.11.xSeth Tisue2015-09-251-4/+9
|\ \ \ | |_|/ |/| | add support for MSys2 to bin/scala shell script
| * | tool-unix: support environments with TERM=cygwinkirillkh2015-08-091-1/+1
| | |
| * | add support for MSys2 to bin/scala shell scriptKirill Khazan2015-07-311-3/+8
| | |
* | | Improve presentation compilation of annotationsJason Zaugg2015-09-242-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A trio of problems were hampering autocompletion of annotations. First, given that that annotation is written before the annotated member, it is very common to end parse incomplete code that has a floating annotation without an anotatee. The parser was discarding the annotations (ie, the modifiers) and emitting an `EmptyTree`. Second, the presetation compiler was only looking for annotations in the Modifiers of a member def, but after typechecking annotations are moved into the symbol. Third, if an annotation failed to typecheck, it was being discarded in place of `ErroneousAnnotation`. This commit: - modifies the parser to uses a dummy class- or type-def tree, instead of EmptyTree, which can carry the annotations. - updates the locator to look in the symbol annotations of the modifiers contains no annotations. - uses a separate instance of `ErroneousAnnotation` for each erroneous annotation, and stores the original tree in its `original` tree.
* | | Merge pull request #4757 from lrytz/t9375-2.11Lukas Rytz2015-09-222-2/+15
|\ \ \ | | | | | | | | [backport] SI-9375 add synthetic readResolve only for static modules
| * | | [backport] SI-9375 add synthetic readResolve only for static modulesLukas Rytz2015-09-222-2/+15
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | For inner modules, the synthetic readResolve method would cause the module constructor to be invoked on de-serialization in certain situations. See the discussion in the ticket. Adds a comprehensive test around serializing and de-serializing modules.
* | | Merge pull request #4725 from retronym/topic/completely-2.11Lukas Rytz2015-09-212-3/+4
|\ \ \ | |/ / |/| | Topic/completely 2.11
| * | Merge remote-tracking branch 'origin/2.11.x' into topic/completely-2.11Jason Zaugg2015-09-1715-12/+60
| |\ \
| * | | Use the presentation compiler to drive REPL tab completionJason Zaugg2015-09-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old implementation is still avaiable under a flag, but we'll remove it in due course. Design goal: - Push as much code in src/interactive as possible to enable reuse outside of the REPL - Don't entangle the REPL completion with JLine. The enclosed test case drives the REPL and autocompletion programatically. - Don't hard code UI choices, like how to render symbols or how to filter candidates. When completion is requested, we wrap the entered code into the same "interpreter wrapper" synthetic code as is done for regular execution. We then start a throwaway instance of the presentation compiler, which takes this as its one and only source file, and has a classpath formed from the REPL's classpath and the REPL's output directory (by default, this is in memory). We can then typecheck the tree, and find the position in the synthetic source corresponding to the cursor location. This is enough to use the new completion APIs in the presentation compiler to prepare a list of candidates. We go to extra lengths to allow completion of partially typed identifiers that appear to be keywords, e.g `global.def` should offer `definitions`. Two secret handshakes are included; move the the end of the line, type `// print<TAB>` and you'll see the post-typer tree. `// typeAt 4 6<TAB>` shows the type of the range position within the buffer. The enclosed unit test exercises most of the new functionality.
| * | | Add an option to let pres compiler user manage threadingJason Zaugg2015-09-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The presentation compiler currently demands that all interaction is performed by asynchronous submission of work items, which are queued and executed on the presentation compiler thread. This is fairly inconvenient if you are a known-single-threaded client that is trying to use the compiler from your own thread. This commit adds an option to disable "assertCorrectThread" to better support this use case.
| * | | SI-4438 FindAll implicits after errorJason Zaugg2015-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix cross talk between candidates in ImplicitComputation#findAll. Haoyi reported that he couldn't get the presentation compiler to offer completion suggestions for extension methods on primitive arrays. Turns out that an error in typechecking the previous candidate had not been cleared, and this was taken to mean that `arrayIntOps` was itself ineligible. After this patch: ``` scala> Array(1, 2, 3) reverse reverseIterator reverse reverseMap reversed scala> Array(1,2,3).reverse //print scala.Predef.intArrayOps(scala.Array.apply(1, 2, 3)).reverse scala> Array(1, 2, 3) to toString toCollection toSeq toIterator to toMap toSet toList toArray toBuffer toStream toIterable toTraversable toVector toIndexedSeq scala> Array(1, 2, 3) toSeq override def toSeq: Seq[Int] ```
* | | | Merge pull request #4724 from retronym/topic/positioned-errorsLukas Rytz2015-09-181-8/+12
|\ \ \ \ | |_|/ / |/| | | Try harder to avoid reporting unpositioned errors
| * | | Try harder to avoid reporting unpositioned errorsJason Zaugg2015-09-021-8/+12
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than issuing an error at NoPosition, which usually means an unpositioned tree is being typechecked, walk up the context chain for an enclosing positioned tree. I've tested this manually with ensime which was getting an unpositioned warning as a result of a unpositioned trees created by a macro in scalatest. ``` % ../scala-positioned-error/build/quick/bin/scalac @args.txt /Users/jason/code/ensime-server/core/src/it/scala/org/ensime/core/RichPresentationCompilerSpec.scala:216: warning: implicit numeric widening ) { (p, cc) => ^ ```
* | | Merge pull request #4738 from janekdb/2.11.x-urls-driftedSeth Tisue2015-09-151-1/+1
|\ \ \ | | | | | | | | Improve drifted URLs
| * | | Improve drifted URLsJanek Bogucki2015-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Any.scala: Link to the guide instead of the SIP. - AnyVal.scala: Remove SIP link and align guide link to Any.scala. - Commands.scala: Use a less out of date team link. - Logic.scala: Link was broken. Substitute found. - Process.scala: Links were 403 & 404. Fixed as this is a code sample. - TypeMaps.scala: Move old EPFL Trac to JIRA. - RedBlackTree.scala: Replaced broken link with substitutes based on site maintainer input [1]. [1] When asked where Data-Set-RBTree.html had gone Don@UNSW advised "I think it's on the Haskell wiki now. It was Chris Okazaki's version". The closest I could find to what this document probably was is this paper by Hinze edited by Okasaki, http://www.cs.ox.ac.uk/ralf.hinze/publications/WAAAPL99b.ps.gz The paper cites the Okasaki document so I included a link to that as well. The Haskell Wiki does have a link to a RB document but that's broken too, https://wiki.haskell.org/Research_papers/Data_structures > Constructing red-black trees
* | | | Merge pull request #4727 from SethTisue/unset-stray-execute-bitsSeth Tisue2015-09-145-0/+0
|\ \ \ \ | | | | | | | | | | unset inappropriate execute bits
| * | | | unset inappropriate execute bitsSeth Tisue2015-09-025-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I imagine these date back to old Subversion days and are probably the result of inadvertent commits from Windows users with vcs client configs. having the bit set isn't really harmful most of the time, but it's just not right, and it makes the files stand out in directory listings for no reason
* | | | | SI-9369 Fix pattern matcher warnings for diamond shaped inheritance.Gerard Basler2015-09-121-1/+5
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous optimization (d44a86f432a7f9ca250b014acdeab02ac9f2c304) for pattern matcher exhaustivity checks used a smarter encoding to ensure that the scrutinee can be equal to one child only. However, in case of traits between the root and leave type, a child can be of several types and these types should not be in a mutually exclusive group. A simple solution (hat tip to retronym) is to just put traits and classes into separate groups.
* | | | Merge pull request #4713 from SethTisue/batch-of-typosJason Zaugg2015-09-083-4/+4
|\ \ \ \ | | | | | | | | | | fix typos/spelling
| * | | | fix assorted typosSeth Tisue2015-08-283-4/+4
| |/ / /
* | | | Merge pull request #4706 from VladUreche/issue/tree-checkerJason Zaugg2015-09-061-1/+8
|\ \ \ \ | | | | | | | | | | Re-enable tree checkers
| * | | | Re-enable tree checkersVlad Ureche2015-08-241-1/+8
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | My expectation is that tree checkers are re-typechecking the trees and making sure they are consistent. Unfortunately, following patch aced32d05c97651534f468bc9a475ea5f6ae75b8, the call to clearType() was removed, thus the typer no longer recursed inside the trees, rendering the type checkers framework useless. This is an attempt to make the tree checkers run again, by resetting the type of a tree before the call to super.typed, thus allowing the typer to actually visit the entire tree (not just the outer package definition). The work was prompted by SI-9442, where the type checkers would gladly allow validate the inconsistent trees.
* | | | Merge pull request #4704 from VladUreche/issue/9442Jason Zaugg2015-09-061-2/+39
|\ \ \ \ | | | | | | | | | | SI-9442 Fix the uncurry-erasure types
| * | | | SI-9442 Fix the uncurry-erasure typesVlad Ureche2015-08-231-2/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using the "uncurry-erased" type (the one after the uncurry phase) can lead to incorrect tree transformations. For example, compiling: ``` def foo(c: Ctx)(l: c.Tree): Unit = { val l2: c.Tree = l } ``` Results in the following AST: ``` def foo(c: Ctx, l: Ctx#Tree): Unit = { val l$1: Ctx#Tree = l.asInstanceOf[Ctx#Tree] val l2: c.Tree = l$1 // no, not really, it's not. } ``` Of course, this is incorrect, since `l$1` has type `Ctx#Tree`, which is not a subtype of `c.Tree`. So what we need to do is to use the pre-uncurry type when creating `l$1`, which is `c.Tree` and is correct. Now, there are two additional problems: 1. when varargs and byname params are involved, the uncurry transformation desugares these special cases to actual typerefs, eg: ``` T* ~> Seq[T] (Scala-defined varargs) T* ~> Array[T] (Java-defined varargs) =>T ~> Function0[T] (by name params) ``` we use the DesugaredParameterType object (defined in scala.reflect.internal.transform.UnCurry) to redo this desugaring manually here 2. the type needs to be normalized, since `gen.mkCast` checks this (no HK here, just aliases have to be expanded before handing the type to `gen.mkAttributedCast`, which calls `gen.mkCast`)
* | | | | Update Java and Sun URLs to replacement Java and Oracle URLsJanek Bogucki2015-09-023-3/+3
| |_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | For each URL - Where it redirected the target of the redirection was used - Where is no longer existed a replacement was selected
* | | | Merge pull request #4692 from JanBessai/Fix-SI-6636Adriaan Moors2015-08-312-0/+23
|\ \ \ \ | |_|/ / |/| | | SI-6636 Fix macro expansion in toolboxes
| * | | SI-6636 Fix macro expansion in toolboxesJan Bessai2015-08-232-0/+23
| |/ /
* | | Fix typo in the name of a private methodMichał Pociecha2015-08-231-5/+5
| | | | | | | | | | | | Since it's a private method, it's safe to just rename it.
* | | Fix typos in spec, docs and commentsMichał Pociecha2015-08-2311-15/+15
|/ /
* | Merge pull request #4678 from stusmall/2.11.xLukas Rytz2015-08-101-0/+4
|\ \ | | | | | | Improved error message for "filename too long" build errors
| * | SI-3623 Improved error message for "filename too long" build errorsstusmall2015-08-071-0/+4
| |/ | | | | | | | | | | | | | | When building on ecryptfs filenames can be limited to ~142 characters. This limit doesn't take long to hit and can leave the the user with a hard to diagnosis error message. Some legacy file systems will have similarly small limits. This just adds a hint that the error might be related to the underlying fs.
* | Merge pull request #4688 from retronym/topic/typer-debug-implicitsLukas Rytz2015-08-102-3/+5
|\ \ | | | | | | Fix tracing of implicit search under -Ytyper-debug
| * | Fix tracing of implicit search under -Ytyper-debugJason Zaugg2015-08-062-3/+5
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The log messages intented to chronicle implicit search were always being filtered out by virtue of the fact that the the tree passed to `printTyping` was already typed, (e.g. with an implicit MethodType.) This commit enabled printing in this case, although it still filters out trees that are deemed unfit for typer tracing, such as `()`. In the context of implicit search, this happens to filter out the noise of: ``` | | | [search #2] start `()`, searching for adaptation to pt=Unit => Foo[Int,Int] (silent: value <local Test> in Test) implicits disabled | | | [search #3] start `()`, searching for adaptation to pt=(=> Unit) => Foo[Int,Int] (silent: value <local Test> in Test) implicits disabled | | | \-> <error> ``` ... which I think is desirable. The motivation for this fix was to better display the interaction between implicit search and type inference. For instance: ``` class Foo[A, B] class Test { implicit val f: Foo[Int, String] = ??? def t[A, B](a: A)(implicit f: Foo[A, B]) = ??? t(1) } ``` ```` % scalac -Ytyper-debug sandbox/instantiate.scala ... | |-- t(1) BYVALmode-EXPRmode (site: value <local Test> in Test) | | |-- t BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value <local Test> in Test) | | | [adapt] [A, B](a: A)(implicit f: Foo[A,B])Nothing adapted to [A, B](a: A)(implicit f: Foo[A,B])Nothing | | | \-> (a: A)(implicit f: Foo[A,B])Nothing | | |-- 1 BYVALmode-EXPRmode-POLYmode (site: value <local Test> in Test) | | | \-> Int(1) | | solving for (A: ?A, B: ?B) | | solving for (B: ?B) | | [search #1] start `[A, B](a: A)(implicit f: Foo[A,B])Nothing` inferring type B, searching for adaptation to pt=Foo[Int,B] (silent: value <local Test> in Test) implicits disabled | | [search #1] considering f | | [adapt] f adapted to => Foo[Int,String] based on pt Foo[Int,B] | | [search #1] solve tvars=?B, tvars.constr= >: String <: String | | solving for (B: ?B) | | [search #1] success inferred value of type Foo[Int,=?String] is SearchResult(Test.this.f, TreeTypeSubstituter(List(type B),List(String))) | | |-- [A, B](a: A)(implicit f: Foo[A,B])Nothing BYVALmode-EXPRmode (site: value <local Test> in Test) | | | \-> Nothing | | [adapt] [A, B](a: A)(implicit f: Foo[A,B])Nothing adapted to [A, B](a: A)(implicit f: Foo[A,B])Nothing | | \-> Nothing ```
* | Merge pull request #4672 from janekdb/2.11.x-scaladoc-compilerSeth Tisue2015-08-0610-21/+21
|\ \ | | | | | | ScalaDoc fixes for compiler
| * | ScalaDoc fixes for compilerJanek Bogucki2015-07-2910-21/+21
| |/
* | Merge pull request #4675 from retronym/ticket/9425Seth Tisue2015-08-061-1/+2
|\ \ | |/ |/| SI-9425 Leave Companion.apply if constructor is less accessible
| * SI-9425 Leave Companion.apply if constructor is less accessibleJason Zaugg2015-07-311-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calls to synthetic case class apply methods are inlined to the underlying constructor invocation in refchecks. However, this can lead to accessibility errors if the constructor is private. This commit ensures that the constructor is at least as accessible as the apply method before performing this tranform. I've manually checked that other the optimization still works in other cases: scala> class CaseApply { Some(42) } defined class CaseApply scala> :javap -c CaseApply Compiled from "<console>" public class CaseApply { public CaseApply(); Code: 0: aload_0 1: invokespecial #9 // Method java/lang/Object."<init>":()V 4: new #11 // class scala/Some 7: dup 8: bipush 42 10: invokestatic #17 // Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer; 13: invokespecial #20 // Method scala/Some."<init>":(Ljava/lang/Object;)V 16: pop 17: return }
* | Merge pull request #4670 from retronym/ticket/9422Lukas Rytz2015-07-291-3/+5
|\ \ | |/ |/| SI-9422 Fix incorrect constant propagation
| * SI-9422 Fix incorrect constant propagationJason Zaugg2015-07-291-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ConstantOptimization phase uses abstract interpretation to track what is known about values, and then to use this information to optimize away tests with a statically known result. Constant propagation was added under -optimize in Scala 2.11.0-M3, in PR #2214. For example, we might know that a variable must hold one of a set of values (`Possible`). Or, we could track that it must *not* be of of a set of value (`Impossible`). The test case in the bug report was enough to create comparison: v1 == v2 // where V1 = Possible(Set(true, false)) // V2 = Possible(Set(true, false)) This test was considered to be always true, due to a bug in `Possible#mightNotEqual`. The only time we can be sure that `Possible(p1) mightNotEquals Possible(p2)` is if `p1` and `p2` are the same singleton set. This commit changes this method to implement this logic. The starting assumption for all values is currently `Impossible(Set())`, although it would also be reasonable to represent an unknown boolean variable as `Possible(Set(true, false))`, given the finite and small domain. I tried to change the starting assumption for boolean locals in exactly this manner, and that brings the bug into sharp focus. Under this patch: https://github.com/retronym/scala/commit/e564fe522d This code: def test(a: Boolean, b: Boolean) = a == b Compiles to: public boolean test(boolean, boolean); Code: 0: iconst_1 1: ireturn Note: the enclosed test case does not list `-optimize` in a `.flags` file, I'm relying on that being passed in by the validation build. I've tested locally with that option, though.
* | Merge pull request #4661 from retronym/ticket/9365Lukas Rytz2015-07-281-1/+1
|\ \ | | | | | | SI-9365 Don't null out dependencies of transient lazy vals
| * | SI-9365 Don't null out dependencies of transient lazy valsJason Zaugg2015-07-271-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per Iulian's analysis: > When lazy vals are transient, the optimization in SI-720 is invalid, > leading to NPEs. These NPEs appear when recomputing the lazy val when deserializaing the object. This commit disables the field nulling if the lazy val is marked transient. The post-mixin tree in the enclosed test changes as follows: ``` --- sandbox/old.log 2015-07-27 15:48:03.000000000 +1000 +++ sandbox/new.log 2015-07-27 15:47:56.000000000 +1000 @@ -1,61 +1,54 @@ [[syntax trees at end of mixin]] // t9365.scala package <empty> { class Test extends Object with Serializable { @transient @volatile private[this] var bitmap$trans$0: Boolean = false; private def foo$lzycompute(): Object = { { Test.this.synchronized({ if (Test.this.bitmap$trans$0.unary_!()) { Test.this.foo = Test.this.x.apply(); Test.this.bitmap$trans$0 = true; () }; scala.runtime.BoxedUnit.UNIT }); - Test.this.x = null + () }; Test.this.foo }; ``` In addition to the test from the ticket, I've added a reflection based test that directly tests the nulling. This complements the test added in 449f2a7473, the fix for SI-720, which passes by virtue of not exhausting the heap.