summaryrefslogtreecommitdiff
path: root/test/junit
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #5094 from lrytz/classOfUnitAdriaan Moors2016-04-271-0/+12
|\ | | | | Fix erasure for classOf[Unit], don't erase to classOf[BoxedUnit]
| * Fix erasure for classOf[Unit], don't erase to classOf[BoxedUnit]Lukas Rytz2016-04-201-0/+12
| |
* | SI-9684 Deprecate JavaConversionsSom Snytt2016-04-2213-13/+13
|/ | | | | | | | | Implicit conversions are now in package convert as ImplicitConversions, ImplicitConversionsToScala and ImplicitConversionsToJava. Deprecated WrapAsJava, WrapAsScala and the values in package object. Improve documentation.
* Merge pull request #5096 from lrytz/traitParentsLukas Rytz2016-04-207-56/+313
|\ | | | | Ensure ClassBTypes constructed from symbol and classfile are identical
| * Ensure that lzycompute methods are entered into the scopeLukas Rytz2016-04-201-2/+14
| | | | | | | | | | For some reason this was not the case, leading to spurious inliner warnings (no inline info found for method O$lzycompute).
| * Ensure ClassBTypes constructed from symbol and classfile are identicalLukas Rytz2016-04-201-13/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A super call (invokespecial) to a default method T.m is only allowed if the interface T is a direct parent of the class. Super calls are introduced for example in Mixin when generating forwarder methods: trait T { override def clone(): Object = "hi" } trait U extends T class C extends U The class C gets a forwarder that invokes T.clone(). During code generation the interface T is added as direct parent to class C. Note that T is not a (direct) parent in the frontend type of class C. This commit stores interfaces that are added to a class during code generation in the InlineInfo classfile attribute. This allows filtering the interface list when constructing a ClassBType from a classfile.
| * Clean up code gen for method invocationsLukas Rytz2016-04-203-6/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code was patched many times in the history and became a bit scattered. When emitting a virtual call, the receiver in the bytecode cannot just be the method's owner (the class in which it is declared), because that class may not be accessible at the callsite. Instead we use the type of the receiver. This was basically done to fix - aladdin bug 455 (9954eaf) - SI-1430 (0bea2ab) - basically the same bug, slightly different - SI-4283 (8707c9e) - the same for field reads In this patch we extend the fix to field writes, and clean up the code. This patch basically reverts 6eb55d4b, the fix for SI-4560, which was rather a workaround than a fix. The underlying problem was that in some cases, in a method invocation `foo.bar()`, the method `bar` was not actually a member of `foo.tpe`, causing a NoSuchMethodErrors. The issue was related to trait implementation classes. The idea of the fix was to check, at code-gen time, `foo.tpe.member("bar")`, and if that returns `NoSymbol`, use `barSym.owner`. With the new trait encoding the underlying problem seems to be fixed - all tests still pass (run/t4560.scala and run/t4560b.scala).
| * SD-98 don't emit unnecessary mixin forwardersLukas Rytz2016-04-123-21/+139
| | | | | | | | | | | | | | | | In most cases when a class inherits a concrete method from a trait we don't need to generate a forwarder to the default method in the class. t5148 is moved to pos as it compiles without error now. the error message ("missing or invalid dependency") is still tested by t6440b.
| * Rewrite JUnit tests to avoid `@Test` methods in traitsLukas Rytz2016-04-121-14/+12
| | | | | | | | | | | | | | | | | | JUnit 4 does not support running `@Test` methods defined as default methods in parent interfaces. JUnit 5 will, but is not yet available. Currently scalac emits a forwarder to every trait method inherited by a class, so tests are correctly executed. The fix for SD-98 will change this.
* | Merge pull request #5100 from lrytz/unitBoxLukas Rytz2016-04-201-0/+119
|\ \ | | | | | | SI-6710 / PR 5072 follow-up: fix Unit.box / Unit.unbox
| * | SI-6710 / PR 5072 follow-up: fix Unit.box / Unit.unboxLukas Rytz2016-04-201-0/+119
| |/ | | | | | | | | | | | | The backend replaces .box / .unbox methods by corresponding invocations to BoxesRunTime, but not for Unit. This commit restores the body of `Unit.box` and `Unit.unbox`.
* / Hide ScalaRunTime.isTuple inside stringOf.SĂ©bastien Doeraene2016-04-131-61/+4
|/ | | | Because it is otherwise unused.
* Fix InlineInfo attribute for nested module accessorsLukas Rytz2016-04-071-29/+67
|
* Remove unused optimizer warnings related to trait impl classesLukas Rytz2016-04-041-24/+0
|
* Remove dead code in the optimizer related to trait impl classesLukas Rytz2016-04-041-21/+20
|
* Merge pull request #5071 from janekdb/topic/2.12.x-scaladoc-ExceptionsLukas Rytz2016-04-011-0/+42
|\ | | | | Add initial unit test for Catch and augment documentation
| * Add initial unit test for Catch and augment documentationJanek Bogucki2016-03-311-0/+42
| | | | | | | | | | | | - Add unit test for andFinally - Reduce code duplication in andFinally - Extend documentation
* | Merge pull request #5059 from lrytz/t9702Adriaan Moors2016-03-311-0/+143
|\ \ | | | | | | SI-9702 Fix backend crash with classOf[T] annotation argument
| * | SI-9702 Fix backend crash with classOf[T] annotation argumentLukas Rytz2016-03-301-0/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes various issues with classOf literals and Java annotations. - Ensure that a Type within a ConstantType (i.e., a classOf literal) is erased, so `classOf[List[Int]]` becomes `classOf[List]`. - Ensure that no non-erased types are passed to `typeToBType` in the backend. This happens for Java annotations: the annotation type and `classOf` annotation arguments are not erased, the annotationInfos of a symbol are not touched in the compiler pipeline. - If T is an alias to a value class, ensure that `classOf[T]` erases to the value class by calling `dealiasWiden` in erasure.
* | | Merge pull request #4971 from adriaanm/genbcode-delambdafyAdriaan Moors2016-03-314-9/+188
|\ \ \ | |_|/ |/| | Unify treatment of built-in functions and SAMs
| * | Specialization precludes use of LambdaMetaFactory for SAMAdriaan Moors2016-03-291-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | Jason's review feedback (ThisReferringMethodTraverser)Adriaan Moors2016-03-261-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Re-simplify logging; - Remove unused method valueTypeToObject; - Limit ThisReferringMethodTraverser to material parts of the AST Limit ThisReferringMethodTraverser's analysis to only look at template-owned anonfun method bodies, to make sure it's fairly low overhead. AFAICT, part of the complexity of this analysis stems from the desire to make all the lambda impl methods static in `() => () => 42`: https://gist.github.com/062181846c13e65490cc. It would possible to accumulate the knowledge we need during the main transform, rather than in an additional pass. We'd need to transform template bodies in such a way that we we process definitions of anonfun methods before usages, which would currently amount to transforming the stats in reverse.
| * | Test bytecode emitted for indy sammyAdriaan Moors2016-03-261-0/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Test that SAM conversion happens after implicit view application A function node is first type checked, and parameter types are inferred, regardless of whether the expected function type is one of our built-in FunctionN classes, or a user-defined Single Abstract Method type. `typedFunction` always assigns a built-in `FunctionN` type to the tree, though. Next, if the expected type is a (polymorphic) SAM type, this creates a tension between the tree's type and the expect type. This gap is closed by the adapt method, by applying one of the implicit conversion in the spec in order (e.g., numeric widening, implicit view application, and now, also SAM conversion) Thus, `adaptToSam` will assign the expected SAM type to the `Function` tree. (This may require some type inference.) The back-end will emit the right invokedynamic instruction that uses Java's LambdaMetaFactory to spin up a class that implements the target method (whether it's defined in FunctionN or some other Java functional interface).
| * | Additional SAM restrictions identified by JasonAdriaan Moors2016-03-262-4/+4
| | | | | | | | | | | | | | | Also test roundtripping serialization of a lambda that targets a SAM that's not FunctionN (it should make no difference).
| * | Treat `Function` literals uniformly, expecting SAM or FunctionN.Adriaan Moors2016-03-261-5/+24
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They both compile to INDY/MetaLambdaFactory, except when they occur in a constructor call. (TODO: can we lift the ctor arg expression to a method and avoid statically synthesizing anonymous subclass altogether?) Typers: - no longer synthesize SAMs -- *adapt* a Function literal to the expected (SAM/FunctionN) type - Deal with polymorphic/existential sams (relevant tests: pos/t8310, pos/t5099.scala, pos/t4869.scala) We know where to find the result type, as all Function nodes have a FunctionN-shaped type during erasure. (Including function literals targeting a SAM type -- the sam type is tracked as the *expected* type.) Lift restriction on sam types being class types. It's enough that they dealias to one, like regular instance creation expressions. Contexts: - No longer need encl method hack for return in sam. Erasure: - erasure preserves SAM type for function nodes - Normalize sam to erased function type during erasure, otherwise we may box the function body from `$anonfun(args)` to `{$anonfun(args); ()}` because the expected type for the body is now `Object`, and thus `Unit` does not conform. Delambdafy: - must set static flag before calling createBoxingBridgeMethod - Refactored `createBoxingBridgeMethod` to wrap my head around boxing, reworked it to generalize from FunctionN's boxing needs to arbitrary LMF targets. Other refactorings: ThisReferringMethodsTraverser, TreeGen.
* / Inline super calls, as they are statically resolvedLukas Rytz2016-03-235-58/+49
|/ | | | | | | Ensures that mixin methods of `@inline` annotated concrete trait methods inline the trait method. Fixes https://github.com/scala/scala-dev/issues/86
* Support :require when using the flat classpath representation.Lukas Rytz2016-03-221-3/+3
| | | | | | :require was re-incarnated in https://github.com/scala/scala/pull/4051, it seems to be used by the spark repl. This commit makes it work when using the flat classpath representation.
* New trait encoding: use default methods, jettison impl classesJason Zaugg2016-03-187-71/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #4968 from lrytz/oldOptCleanupAdriaan Moors2016-02-2420-28/+87
|\ | | | | Remove -Y settings that are no longer used in 2.12
| * Remove -Y settings that are no longer used in 2.12Lukas Rytz2016-02-1620-28/+35
| | | | | | | | | | | | Added a deprecation warning for `-optimize`. Later we'll also graduate `-Yopt` to `-opt`, probably for 2.12.0-M5.
| * Rewrite a few more tests to the new optimizerLukas Rytz2016-02-151-0/+52
| |
* | Clean up some bytecode testsLukas Rytz2016-02-166-168/+111
| |
* | Tests for optimizing val patternsLukas Rytz2016-02-162-14/+72
|/ | | | Fixes https://github.com/scala/scala-dev/issues/28
* SD-79 don't issue spurious inliner warnings under l:projectLukas Rytz2016-02-151-0/+9
| | | | | | | | | | | When enabling `-Yopt:inline-project` (or `-Yopt:l:project`), the inliner would spuriously warn about callsites to methods marked `@inline` that are read from the classpath (not being compiled currently). This patch introduces yet another field to the `Callsite` class, which is growing a bit too large. But the call graph representation will get an overhaul when implementing the new inliner heuristics (2.12.0-M5), so this is just a temporary fix that would be nice to have in M4.
* Merge pull request #4963 from lrytz/simplerBranchingLukas Rytz2016-02-153-5/+127
|\ | | | | Generate leaner code for branches
| * Avoid generating ACONST_NULL; POP; ACONST_NULL when loading nullLukas Rytz2016-02-142-1/+48
| | | | | | | | | | | | | | When loading a value of type scala.runtime.Null$ we need to add POP; ACONST_NULL, see comment in BCodeBodyBuilder.adapt. This is however not necessary if the null value is a simple ACONST_NULL. This patch eliminates that redundancy.
| * Generate leaner code for branchesLukas Rytz2016-02-131-4/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GenBCode used to generate more bytecode for branching instructions than GenASM. A simple method def f(x: Int, b: Boolean) = if (b) 1 else 2 would generate ILOAD 2 IFNE L1 GOTO L2 L1 ICONST_1 GOTO L3 L2 ICONST_2 L3 IRETURN If the conditional branch is negated (IFEQ) the GOTO is unnecessary. While -Yopt:l:method would clean this up, it's also not too hard to generate the leaner bytecode in the first place.
* | SI-8790 test caseLukas Rytz2016-02-131-0/+20
|/ | | | | Tuples created for pattern matching are eliminated since https://github.com/scala/scala/pull/4858
* Merge pull request #4944 from lrytz/stringBuilderNoBoxLukas Rytz2016-02-122-36/+114
|\ | | | | SI-9571 Avoid boxing primitives in string concatenation
| * SI-9571 Avoid boxing primitives in string concatenationMarko Elezovic2016-02-061-36/+99
| |
| * test case for optimizing BooleanOrdering.compareLukas Rytz2016-02-041-0/+15
| |
* | Merge pull request #4957 from retronym/topic/merge-2.11.x-to-2.12.x-20160210Seth Tisue2016-02-111-0/+28
|\ \ | | | | | | Merge 2.11.x to 2.12.x [ci:last-only]
| * \ Merge branch '2.11.x' into topic/merge-2.11.x-to-2.12.x-20160210Jason Zaugg2016-02-101-0/+28
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/library/scala/collection/Iterator.scala | `-- trivial conflicts only. Parens were added to the next() calls in 2.12.x, while in the meantime `{Concat,Join}Iterator` were optimized in 2.11.x
| | * \ Merge pull request #4937 from szeiger/issue/9623-2.11Seth Tisue2016-02-081-0/+28
| | |\ \ | | | | | | | | | | SI-9623 Avoid unnecessary hasNext calls in JoinIterator & ConcatIterator
| | | * | SI-9623 Avoid unnecessary hasNext calls in JoinIterator & ConcatIteratorStefan Zeiger2016-02-011-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These iterator implementations are used to concatenate two (JoinIterator) or more (ConcatIterator) other iterators with `++`. They used to perform many unnecessary calls to the child iterators’ `hasNext` methods. This improved state machine-based implementation reduces that number to the bare minimum, i.e. iterating over concatenated iterators with `foreach` calls the children's `hasNext` methods a total of (number of children) + (number of elements) times, the same as when iterating over all children separately.
* | | | | Merge pull request #4924 from ShaneDelmore/SI-9452Lukas Rytz2016-02-102-0/+21
|\ \ \ \ \ | | | | | | | | | | | | SI-9452: Extend BigDecimal with Ordered for java interop
| * \ \ \ \ Merge branch '2.12.x' into SI-9452Shane Delmore2016-02-046-6/+497
| |\ \ \ \ \ | | | |_|_|/ | | |/| | |
| * | | | | Extend BigInt with Ordered for java interopShane Delmore2016-02-011-0/+16
| | | | | |
| * | | | | Extend BigDecimal with Ordered for java interopShane Delmore2016-02-011-0/+5
| | | | | |
* | | | | | Merge pull request #4868 from retronym/ticket/9542-comboJason Zaugg2016-02-101-1/+27
|\ \ \ \ \ \ | |_|_|/ / / |/| | | | | SI-9542 Fix regression in value classes (served two ways)