summaryrefslogtreecommitdiff
path: root/test/files/pos
Commit message (Collapse)AuthorAgeFilesLines
* Java joint compilation: tweak static lookup implJason Zaugg2016-08-122-2/+7
|
* Javadoc: java static name resolutionAdriaan Moors2016-08-092-0/+13
| | | | [Jakob Odersky <jodersky@gmail.com>: remove obsolete comments and fix tests]
* Merge pull request #5257 from szeiger/wip/final-tuplesLukas Rytz2016-07-202-8/+4
|\ | | | | SI-7301 Make tuple classes final
| * SI-7301 Make tuple classes finalStefan Zeiger2016-07-072-8/+4
| | | | | | | | | | This includes undoing the special case for `-Xfuture` introduced in https://github.com/scala/scala/pull/2299 and updating tests to take the new errors into account.
* | SI-9855 Fix regression in extractor pattern translationJason Zaugg2016-07-142-0/+26
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In faa5ae6, I changed the pattern matchers code generator to use stable references (`Ident`-s with the singleton type, rather than the widened type) to the synthetic vals used to store intermediate results ("binders"). In the case where the scrutinee matched the unapply parameter type of some extractor pattern, but the pattern subsequently failed, this led to an regression. It turns out that this was due to the way that the type of the binder was mutated to upcast to the exact type of a subsequent pattern in `ensureConformsTo`: https://github.com/scala/scala/blob/953559988/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala#L165-L174 This was added in 32c57329a as a workaround for the problem caused in t6664.scala, when the binder type was `KList with KCons`, and the code generator wasn't able to find the case field accessors for `KCons` in the decls. The change to use stable references meant that this mutation was now observed in another part of the tree, as opposed to the 2.11.8 situation, where we had used the original, sharper type of the binder eagerly to assign to the `Ident` that referred to it. This led to a tree: Assign(Ident(x3), Ident(x1).setType(x1.tpe) Now that we instead refer generate: Assign(Ident(x3), Ident(x1).setType(stableTypeFor(x1)) and we don't typecheck this until after the mutation of `x1.symbol.info`, we can get a type error. This commit removes this mutation of the binder type altogether, and instead uses `aligner.wholeType`, which is based on the result type of the `Apply(TypeTree(MethodType(params, resultType))` that encodes a typechecked constructor pattern. In `t6624.scala`, this is `KCons`, the case class that has the extractors as its decls.
* Emit trait method bodies in staticsJason Zaugg2016-06-281-0/+21
| | | | | | | | | | | | | | | | | | | | 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.
* Merge commit '91b6944' into merge-2.11-to-2.12-june-19Lukas Rytz2016-06-191-0/+27
|\
| * SI-9245 Fresher name in Try and testSom Snytt2016-06-071-0/+27
| | | | | | | | | | | | | | | | Fresh name for catcher gets a dollar. "Here, have a dollar." Test due to retronym demonstrates possible conflict. Over the lifetime of the universe, surely at least one code monkey would type in that identifier to catch a banana.
* | Merge commit '90706b0' into merge-2.11-to-2.12-june-1Lukas Rytz2016-06-012-0/+13
|\|
| * Move t8449 to correct placeLukas Rytz2016-05-172-0/+13
| | | | | | | | Follow-up for https://github.com/scala/scala/pull/4117
| * Update partest to 1.0.12, test case for reporting invalid flagsLukas Rytz2016-02-171-1/+1
| | | | | | | | | | | | Conflicts: test/files/pos/t3420.flags versions.properties
* | Merge pull request #5102 from milessabin/2.12.xJason Zaugg2016-05-2718-0/+206
|\ \ | | | | | | SI-2712 Add support for partial unification of type constructors
| * | SI-2712 Add support for higher order unificationMiles Sabin2016-05-2418-0/+206
| | |
* | | Rename -Yopt to -opt, -Yopt-warnings to -opt-warningsLukas Rytz2016-05-256-6/+6
| | | | | | | | | | | | Keep -Yopt-inline-heuristics and -Yopt-trace unchanged
* | | Merge pull request #4935 from som-snytt/issue/8044-tickvarAdriaan Moors2016-05-241-0/+15
|\ \ \ | |/ / |/| | SI-8044 Allow binding backquoted varid in patterns
| * | SI-8044 Allow any id in explicit pattern bindingSom Snytt2016-05-201-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allows arbitrary identifier in `X @ pat`, including non-varids. This goes to regularity. Users of this syntax are not likely to be confused by the "backquoted var id is stable" rule. Also for sequence pattern, `X @ _*`.
| * | SI-8044 Allow binding backquoted varid in patternsSom Snytt2016-05-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, a varid could not be backquoted, so that it was not possible to introduce variables with names such as `type` in a match expression. This commit allows backquoted varids in `case x @ _` and `case x: Int`. In neither position is a stable id accepted, that is, an id with leading uppercase. Therefore, this commit merely relaxes the backquoted varid to be taken as a normal varid in these contexts.
* | | Merge pull request #5106 from milessabin/topic/hkgadtAdriaan Moors2016-05-231-0/+35
|\ \ \ | | | | | | | | SI-9760 Fix for higher-kinded GADT refinement
| * | | Added pos test with multiple cases; added neg tests.Miles Sabin2016-05-061-4/+21
| | | |
| * | | Added missing result type to test.Miles Sabin2016-04-201-1/+1
| | | |
| * | | SI-9760 Fix for higher-kinded GADT refinementMiles Sabin2016-04-191-0/+18
| | | |
* | | | Merge pull request #4988 from som-snytt/issue/backtick-barAdriaan Moors2016-05-201-0/+7
|\ \ \ \ | |_|/ / |/| | | SI-9665 Backquoted vbar in extractor pattern
| * | | SI-9665 Backquoted vbar in extractor patternSom Snytt2016-03-151-0/+7
| | | | | | | | | | | | | | | | Allow an infix extractor named `|`, when backquoted.
* | | | Test case for SI-5183, tagged primitives in case classes (#5144)Ben Hutchison2016-05-192-0/+42
| | | | | | | | | | | | Test for SI-7088, arrays containing tagged primitives
* | | | SI-9397 Add "_root_" to "GenUtils.scalaFactoryCall" to avoid the scala ↵Shixiong Zhu2016-05-111-0/+12
| | | | | | | | | | | | | | | | | | | | package name conflits (#5150) When a user imports some package ending with `scala`, the macro expansion of TypeTag may not work because it uses `scala.collection.immutable.List` but it's overrided. This patch adds the `_root_` prefix to avoid the scala package name conflits. Of cause, after this fix, importing a package ending with `_root_` has the same issue. However, people rarely do that.
* | | | Emit a warning when a constant expression evaluates to an ↵Olli Helenius2016-05-023-0/+8
| | | | | | | | | | | | | | | | ArithmeticException (#5123)
* | | | SI-9684 Deprecate JavaConversionsSom Snytt2016-04-226-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-201-0/+4
|\ \ \ \ | | | | | | | | | | Ensure ClassBTypes constructed from symbol and classfile are identical
| * | | | SD-98 don't emit unnecessary mixin forwardersLukas Rytz2016-04-121-0/+4
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* / | | Remove dead-code runtime hash() methods.Sébastien Doeraene2016-04-131-4/+0
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ScalaRunTime had a bunch of overloads of the `hash()` method, but only the `Any` version is ever used by the codegen. Worse, their implementation was not in sync with the actual implementations in BoxesRunTime, called by the `Any` version. For example, hash(0x80000000L) != hash(0x80000000L: Any) This commit simply removes all of this dead code. Similarly, we remove BoxesRunTime.hashFromObject(), which was never called either.
* | | Merge pull request #5068 from retronym/topic/jdk8ism2v2.12.0-M4Lukas Rytz2016-04-012-0/+10
|\ \ \ | | | | | | | | Accomodate and exploit new library, lang features JDK 8
| * | | Java types and type parameters can be annotated since JSR 308Jason Zaugg2016-03-292-0/+10
| | | |
* | | | Merge pull request #4971 from adriaanm/genbcode-delambdafyAdriaan Moors2016-03-3118-15/+100
|\ \ \ \ | | | | | | | | | | Unify treatment of built-in functions and SAMs
| * | | | typedFunction undoes eta-expansion regardless of expected typeAdriaan Moors2016-03-301-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When recovering missing argument types for an eta-expanded method value, rework the expected type to a method type.
| * | | | Additional SAM restrictions identified by JasonAdriaan Moors2016-03-264-8/+38
| | | | | | | | | | | | | | | | | | | | | | | | | Also test roundtripping serialization of a lambda that targets a SAM that's not FunctionN (it should make no difference).
| * | | | More fixes based on feedback by LukasAdriaan Moors2016-03-263-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Crucially, the fully-defined expected type must be checked for conformance to the original expected type!! The logic in adaptToSam that checks whether pt is fully defined probably needs some more thought. See pos/t8310 for a good test case. Argument type checking is a challenge, as we first check against a lenient pt (this lenient expected type has wildcards, and thus is not fully defined, but we should still consider sam adaptation a success even if we end up with wildcards for some unknown type parameters, they should be determined later).
| * | | | Treat `Function` literals uniformly, expecting SAM or FunctionN.Adriaan Moors2016-03-262-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | Review feedback from LukasAdriaan Moors2016-03-261-1/+1
| | | | |
| * | | | SI-9449 sam expansion for explicitly eta-expanded methodAdriaan Moors2016-03-261-0/+19
| | | | |
| * | | | Refactor typedFunction, rework synthesizeSAMFunction for sammyAdriaan Moors2016-03-265-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `typedFunction` uniformly recognizes Single Abstract Method types and built-in `FunctionN` types, type checking literals regardless of expected type. `adapt` synthesizes an anonymous subclass of the SAM type, if needed to meet the expected (non-`FunctionN`) type. (Later, we may want to carry `Function` AST nodes with SAM types through the whole pipeline until the back-end, and treat them uniformly with built-in function types there too, emitting the corresponding `invokedynamic` & `LambdaMetaFactory` bytecode. Would be faster to avoid synthesizing all this code during type checking...) Refactor `typedFunction` for performance and clarity to avoid non-local returns. A nice perk is that the error message for missing argument types now indicates with `<error>` where they are missing (see updated check file). Allow pattern matching function literals when SAM type is expected (SI-8429). Support `return` in function body of SAM target type, by making the synthetic `sam$body` method transparent to the `enclMethod` chain, so that the `return` is interpreted in its original context. A cleaner approach to inferring unknown type params of the SAM method. Now that `synthesizeSAMFunction` operates on typed `Function` nodes, we can take the types of the parameters and the body and compare them against the function type that corresponds to the SAM method's signature. Since we are reusing the typed body, we do need to change owners for the symbols, and substitute the new method argument symbols for the function's vparam syms. Impl Notes: - The shift from typing as a regular Function for SAM types was triggered by limitation of the old approach, which deferred type checking the body until it was in the synthetic SAM type subclass, which would break if the expression was subsequently retypechecked for implicit search. Other problems related to SAM expansion in ctor args also are dodged now. - Using `<:<`, not `=:=`, in comparing `pt`, as `=:=` causes `NoInstance` exceptions when `WildcardType`s are encountered. - Can't use method type subtyping: method arguments are in invariant pos. - Can't use STATIC yet, results in illegal bytecode. It would be a better encoding, since the function body should not see members of SAM class. - This is all battle tested by running `synthesizeSAMFunction` on all `Function` nodes while bootstrapping, including those where a regular function type is expected. The only thing that didn't work was regarding Function0 and the CBN transform, which breaks outer path creation in lambdalift.
| * | | | SI-9415 Turn on SAM by defaultJason Zaugg2016-03-268-8/+0
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initial work to change settings and test by Svyatoslav Ilinskiy Thanks! To avoid cycles during overload resolution (which showed up during bootstrapping), and to improve performance, I've guarded the detection of SAM types in `isCompatible` to cases when the LHS is potentially compatible.
* | | | Merge pull request #5008 from janekdb/2.12.x-remove-Predef-errorSeth Tisue2016-03-292-2/+2
|\ \ \ \ | | | | | | | | | | Remove deprecated Predef.error
| * | | | Remove deprecated Predef.errorJanek Bogucki2016-03-262-2/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | error was deprecated in 2.9.0 but remained to ensure compatibility with sbt. This changes follows on from an update to the latest sbt version (0.13.11).
* | | | Merge pull request #5021 from szeiger/wip/remove-deprecationsSeth Tisue2016-03-291-1/+2
|\ \ \ \ | |/ / / |/| | | Seal collection classes that were annotated with deprecatedInheritance in 2.11.0
| * | | Make some collection classes final or sealedStefan Zeiger2016-03-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | They were all annotated with `@deprecatedInheritance` in 2.11.0. Some deprecated classes are moved to new source files in order to seal the parent class. The package-private class `DoublingUnrolledBuffer` is moved from `scala.collection.parallel.mutable` to `scala.collection.mutable` in order to seal `UnrolledBuffer`.
* | | | New trait encoding: use default methods, jettison impl classesJason Zaugg2016-03-181-4/+4
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | SI-9658 Fix crosstalk between partial fun. and GADT matchJason Zaugg2016-03-041-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When typechecking the synthetic default case of a pattern matching anonymous partial function, we failed to create a new `Context`. This led to crosstalk with the management of the saved type bounds of an enclosing GADT pattern match. This commit avoids the direct call to `typeCase` and instead indirects through `typedCases`, which spawns a new nested typer context, and hence avoids the crosstalk when `restoreSavedTypeBounds` runs.
* | | Remove -Y settings that are no longer used in 2.12Lukas Rytz2016-02-161-1/+1
| | | | | | | | | | | | | | | | | | 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-159-40/+3
|/ /
* | Merge pull request #4868 from retronym/ticket/9542-comboJason Zaugg2016-02-101-0/+8
|\ \ | | | | | | SI-9542 Fix regression in value classes (served two ways)