summaryrefslogtreecommitdiff
path: root/test/junit
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #5290 from lrytz/sd48Stefan Zeiger2016-08-091-0/+37
|\ | | | | SD-48 limit the lenght of inlined local variable names
| * SD-48 limit the lenght of inlined local variable namesLukas Rytz2016-07-201-0/+37
| | | | | | | | | | | | When inlining local variables, the names are prefixed with the callee method name. In long chains of inlining, these names can grow indefinitely. This commits introduces a limit.
* | Merge pull request #5296 from retronym/ticket/SD-186Lukas Rytz2016-07-221-0/+19
|\ \ | | | | | | SD-186 Fix positions in trait method bytecode
| * | SD-186 Fix positions in trait method bytecodeJason Zaugg2016-07-221-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Concrete, non private methods in traits are translated into a static method with an explicit `$this` parameter. After this translation, the references to `$this` (subistuted for `this` in user written code) where being positioned at the position of the method, which makes debugging unpleasant. This commit leaves the `Ident($this)` trees unpositioned. This is analagous to what we do in the body of extension methods, which is the other user of `ThisSubstitutor`. It would be more correct to copy the position of each `This` tree over to the substituted tree. That would let us set a breakpoint on a line that _only_ contained `this`. But in 99% of cases users won't be able to spot the difference, so I've opted for the tried and tested approach here.
* | | Merge pull request #5261 from som-snytt/issue/9827Stefan Zeiger2016-07-191-1/+69
|\ \ \ | | | | | | | | SI-9827 MatchIterator advances itself
| * | | SI-9827 MatchIterator advances itselfSom Snytt2016-07-181-1/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid caveats about calling `next` (or `hasNext`) before using `MatchData` methods on `MatchIterator`, just do it internally as necessary. Note `MatchIterator` behavior in the docs. Added tests showing what people cried about.
* | | | SI-9691 BufferedIterator should expose a headOptionChristopher Davenport2016-07-151-0/+28
| |_|/ |/| | | | | | | | This exposes a new API to the BufferedIterator trait. It will return the next element of an iterator as an Option. The return will be Some(value) if there is a next value, and None if there is not a next element.
* | | Merge pull request #5234 from som-snytt/review/printersLukas Rytz2016-07-131-0/+16
|\ \ \ | |_|/ |/| | Avoid triple-quoting triple quotes in printer
| * | Constant print control in unicodeSom Snytt2016-06-161-1/+5
| | | | | | | | | | | | | | | Since octal escape is deprecated, use unicode escape for string representation of constants.
| * | Refactor triple quote quotingSom Snytt2016-06-161-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | To quote a triple quote, only quote one quote. Refactors the code for legibility. Adds test for other inline cruft like control chars.
| * | Avoid triple-quoting triple quotesSom Snytt2016-06-161-0/+8
| | | | | | | | | | | | | | | | | | The boolean test for triples was inadvertently flipped. Adds test for pretty printed multiline strings
* | | SI-9515 closure elimination also for non-Scala-Function SAM typesLukas Rytz2016-07-041-0/+20
| |/ |/| | | | | | | | | | | | | | | | | Also logged in as SD-162 The optimizer had conservative checks in place to perform closure elimination only for Scala Function types. We can eliminate IndyLambda instructions for any functional interface. LambdaMetaFactory only constructs lambda objects for interface types, which don't have any side-effects on construction - they don't have a constructor.
* | Emit trait method bodies in staticsJason Zaugg2016-06-287-28/+67
|/ | | | | | | | | | | | | | | | | | | | And use this as the target of the default methods or statically resolved super or $init calls. The call-site change is predicated on `-Yuse-trait-statics` as a stepping stone for experimentation / bootstrapping. I have performed this transformation in the backend, rather than trying to reflect this in the view from Scala symbols + ASTs. We also need to add an restriction related to invokespecial to Java parents: to support a super call to one of these to implement a super accessor, the interface must be listed as a direct parent of the class. The static method names has a trailing $ added to avoid duplicate name and signature errors in classfiles.
* Keep line numbers when inlining from the same compilation unitLukas Rytz2016-06-062-1/+49
| | | | | | | | So far, line numbers were kept only when inlining from the same class. We can also keep them when inlining from a different class defined in the same compilation unit. Longer-term we should support JSR-45, see SI-7518 and scala-dev#3.
* SI-9256 check companions in same compilation unit only if same runLukas Rytz2016-06-063-17/+29
|
* clear all flags when resetting a symbolLukas Rytz2016-06-061-0/+11
| | | | | | this change is a bit scary because it changes code that's not been changed in 11 years https://github.com/scala/scala/commit/7fa7c93#diff-d5789e5ae5061197d782d08324b260dbL214
* Store source file paths of classes being compiled in the bytecode repoLukas Rytz2016-06-062-2/+2
| | | | | | | For classes being compiled (vs. being loaded from classfiles), keep the source file path in the bytecode repo. This will allow to keep line numbers when inlining from one class into another in case the two are defined in the same compilation unit.
* Merge pull request #5099 from retronym/ticket/9390Jason Zaugg2016-06-062-3/+3
|\ | | | | SI-9390 Emit local defs that don't capture this as static
| * SI-9390 Emit local defs that don't capture this as staticJason Zaugg2016-06-012-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This avoids unnecessary memory retention, and allows lambdas that call the local methods to be serializable, regardless of whether or not the enclosing class is serializable. The second point is especially pressing, given that the enclosing class for local methods defined in a used to be the (serializable) anonymous function class, but as of Scala 2.12 will be the enclosing class of the lambda. This change is similar in spirit to SI-9408 / 93bee55e.
* | Merge pull request #5157 from retronym/topic/lambda-staticsJason Zaugg2016-06-067-41/+47
|\| | | | | Lambda impl methods static and more stably named
| * Treat self parameter as non-null in the optimizerLukas Rytz2016-06-012-2/+2
| |
| * Lambda impl methods static and more stably namedJason Zaugg2016-06-016-40/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The body of lambdas is compiled into a synthetic method in the enclosing class. Previously, this method was a public virtual method named `fully$qualified$Class$$anonfun$n`. For lambdas that didn't capture a `this` reference, a static method was used. This commit changes two aspects. Firstly, all lambda impl methods are now emitted static. An extra parameter is added to those that require a this reference. This is an improvement as it: - allows, shorter, more readable names for the lambda impl method - avoids pollution of the vtable of the class. Note that javac uses private instance methods, rather than public static methods. If we followed its lead, we would be unable to support important use cases in our inliner Secondly, the name of the enclosing method has been included in the name of the lambda impl method to improve debuggability and to improve serialization compatibility. The serialization improvement comes from the way that fresh names for the impl methods are allocated: adding or removing lambdas in methods not named "foo" won't change the numbering of the `anonfun$foo$n` impl methods from methods named "foo". This is in line with user expectations about anonymous class and lambda serialization stability. Brian Goetz has described this tricky area well in: http://cr.openjdk.java.net/~briangoetz/eg-attachments/lambda-serialization.html This commit doesn't go as far a Javac, we don't use the hash of the lambda type info, param names, etc to map to a lambda impl method name. As such, we are more prone to the type-1 and -2 failures described there. However, our Scala 2.11.8 has similar characteristics, so we aren't going backwards. Special case in the naming: Use "new" rather than "<init>" for constructor enclosed lambdas, as javac does. I have also changed the way that "delambdafy target" methods are identifed. Rather than relying on the naming convention, I have switched to using a symbol attachment. The assumption is that we only need to identify them from within the same compilation unit. This means we can distinguish impl metbods for expanded functions (ones called from an `apply` method of an ahead-of-time expanded anonfun class), from those that truly end up as targets for lambda metafactory. Only the latter are translated to static methods in this patch.
* | Merge pull request #5207 from lrytz/nan-compareAdriaan Moors2016-06-021-0/+38
|\ \ | | | | | | Fix comparisons involving NaN
| * | Fix comparisons involving NaNLukas Rytz2016-06-021-0/+38
| | | | | | | | | | | | | | | Floating point comparisons involving NaN should always return false, except for !=. Fixes a regression introduced by #4963.
* | | Merge commit '4196569' into merge-2.11-to-2.12-june-1Lukas Rytz2016-06-011-0/+48
|\ \ \ | |/ / |/| |
| * | SI-9688 Make merge in immutable HashMap1 work with null kv.Łukasz Gieroń2016-05-231-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | The kv field of scala.collection.immutable.HashMap.HashMap1 can be null. This commit corrects the behavior of updated0 (which is on call path for merged) to work in such cases, instead of throwing NPE. Commit contains regression test.
* | | SI-9767 document and test behaviour of String->integer/float conversionsMike Pheasant2016-06-011-0/+31
| |/ |/| | | | | | | | | | | We delegate `String`'s extension methods `toInt`, `toFloat`, etc to corresponding methods in the Java standard library. These differ in the way they handle whitespace in the original string. This commit documents and tests the current behaviour.
* | Merge pull request #5076 from soc/topic/deprecations-sinceLukas Rytz2016-05-301-1/+1
|\ \ | | | | | | Improvements to deprecations related to `since` parameter
| * | Add since arg to deprecationWarning and use itSimon Ochsenreither2016-05-291-1/+1
| | |
* | | Merge pull request #5191 from som-snytt/issue/9382Lukas Rytz2016-05-302-16/+68
|\ \ \ | |/ / |/| | SI-9382 Privatize enhanced x in Tuple2Zipped.Ops
| * | SI-9382 Zippy clean-up in aisle 2 & 3Som Snytt2016-05-262-16/+68
| | | | | | | | | | | | | | | Consolated JUnit tests and heeded comment about private def and code beauty.
* | | Merge pull request #5102 from milessabin/2.12.xJason Zaugg2016-05-271-3/+3
|\ \ \ | | | | | | | | SI-2712 Add support for partial unification of type constructors
| * | | -Xexperimental mode now only includes -Ypartial-unificationMiles Sabin2016-05-241-3/+3
| |/ /
* | | Merge pull request #5186 from lrytz/inlinerM5Jason Zaugg2016-05-271-5/+5
|\ \ \ | | | | | | | | Debug flag to print a summary of the inliner's work
| * | | Debug flag to print a summary of the inliner's workLukas Rytz2016-05-241-5/+5
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example output below. Note that inlining List.map fails because the trait forwarder uses `INVOKESPECIAL` for now, will change with pr 5177. $ cat Test.scala class C { def foo = Map(1 -> 'a', 2 -> 'b') def bar(l: List[Int]) = l.map(_ + 1) } $ qsc -Yopt-log-inline _ -Yopt:l:classpath Test.scala Inlining into C.foo (initially 36 instructions, ultimately 72): - Inlined scala/Predef$ArrowAssoc$.$minus$greater$extension (8 instructions) 2 times: the callee is annotated `@inline` Inlining into C.bar (initially 12 instructions, ultimately 12): - Failed to inline scala/collection/immutable/List.map (the callee is a higher-order method, the argument for parameter (bf: Function1) is a function literal): The callee scala/collection/immutable/List::map(Lscala/Function1;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object; contains the instruction INVOKESPECIAL scala/collection/TraversableLike.map (Lscala/Function1;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object; that would cause an IllegalAccessError when inlined into class C.
* | | Merge pull request #5192 from dwijnand/wip/scala-repl-no-importsJason Zaugg2016-05-271-0/+19
|\ \ \ | | | | | | | | Fully qualify types in REPL generated code
| * | | Fully qualify types in REPL generated codeDale Wijnand2016-05-261-0/+19
| | | |
* | | | Rename -Yopt to -opt, -Yopt-warnings to -opt-warningsLukas Rytz2016-05-2521-33/+33
|/ / / | | | | | | | | | Keep -Yopt-inline-heuristics and -Yopt-trace unchanged
* / / SI-9522 release key reference when deleting from OpenHashMapPerformant Data LLC2016-05-241-1/+57
|/ / | | | | | | | | | | | | | | | | This sets the key field in the hash table entry to its default value when an entry is deleted, so as not to unexpectedly retain an object reference, leading to a memory leak. Also includes incidental changes to the slot location algorithm that reduce the number of deleted entries.
* | SI-9121 test case (fixed in new optimizer), SI-9179 test caseLukas Rytz2016-05-232-0/+54
| | | | | | | | | | Also adds a mising phase travel in the backend. A comment already points out why it's necessary, but it was actually forgotten.
* | Merge pull request #5180 from lrytz/junit-passJason Zaugg2016-05-2346-2036/+2051
|\ \ | | | | | | Clean up JUnit tests, make sure they pass without bootstrap [ci: last-only]
| * | Adapt naming convention for collection.convert null safety testLukas Rytz2016-05-203-279/+286
| | | | | | | | | | | | | | | | | | | | | Test classes not ending in "Test" are not executed in sbt. IntelliJ runs them. After this patch: 803 tests executed both in sbt and junit.
| * | All JUnit tests pass without bootstrap (when run in intellij, sbt)Lukas Rytz2016-05-203-92/+123
| | |
| * | Split RunTest and BytecodeTest into parts, put in matching packages.Lukas Rytz2016-05-2013-610/+660
| | |
| * | Cleanup in BytecodeTestLukas Rytz2016-05-201-28/+20
| | |
| * | Small cleanup in JUnit testLukas Rytz2016-05-201-5/+1
| | |
| * | Clean up bytecode testing methods.Lukas Rytz2016-05-2022-462/+496
| | |
| * | Better abstraction for JUnit run testsLukas Rytz2016-05-202-11/+22
| | |
| * | Better abstraction for bytecode tests. Also organize some imports.Lukas Rytz2016-05-2030-555/+453
| | |
| * | Rename nsc.backend.jvm.CodeGenTools to testing.BytecodeTestingLukas Rytz2016-05-2030-39/+35
| | |