summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Class symbols can't be contravariant.Jason Zaugg2013-02-044-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | During development of the fix for SI-6666, I encountered: % test/files/pos/t4842.scala test/files/pos/t4842.scala:10: error: contravariant class Bar occurs in covariant position in type ()this.Bar of constructor Bar this(new { class Bar { println(Bar.this); new { println(Bar.this) } }; new Bar } ) // okay I had incorrectly set the INCONSTRUCTOR flag on the class symbol `Bar`. (It isn't directly in the self constructor call, as it is nested an intervening anonymous class.) But, this flag shares a slot with CONTRAVARIANT, and the variance validation intepreted it as such. ClassSymbol already has this code to resolve the ambiguous flags for display purposes: override def resolveOverloadedFlag(flag: Long) = flag match { case INCONSTRUCTOR => "<inconstructor>" // INCONSTRUCTOR / CONTRAVARIANT / LABEL case EXISTENTIAL => "<existential>" // EXISTENTIAL / MIXEDIN case IMPLCLASS => "<implclass>" // IMPLCLASS / PRESUPER case _ => super.resolveOverloadedFlag(flag) } This commit overrides `isContravariant` to reflect the same logic.
* SI-6666 Catch VerifyErrors in the making in early defs.Jason Zaugg2013-02-023-9/+20
| | | | | | As we did for self/super calls, add a backstop into explicitouter and lambdalift to check when we try to get an outer pointer to an under-construction instance.
* Broader checks for poisonous this references.Jason Zaugg2013-02-0212-82/+146
| | | | Replaces more VerifyErrors with implementation restrictions.
* Add a test case from the comments of SI-6666.Jason Zaugg2013-02-022-0/+21
| | | | | This one lands in the new implementation restriction which beats the VerifyError.
* SI-6666 Account for nesting in setting INCONSTRUCTORJason Zaugg2013-02-025-4/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This flag is calcualed in Namers, and assigned to class and module class symbols that are defined in self/super-calls, and in early definitions. For example, class D is INCONSTRUCTOR in each case below: class C extends Super({class D; ()}) class C(a: Any) { def this(a: Any) = this({class D; ()}) } new { val x = { class D; () } with Super(()) But, the calculation of this flag failed to account for nesting, so it was not set in cases like: class C(a: Any) { def this(a: Any) = this({val x = {class D; ()}; x}) } This patch searches the enclosing context chain, rather than just the immediate context. The search is terminated at the first non term-owned context. In the following example, this avoids marking `E` as INCONSTRUCTOR; only `D` should be. class C extends Super({class D { class E }; ()}) This closes SI-6259 and SI-6506, and fixes one problem in the recently reopened SI-6957.
* Move a test from pos to run to highlight bytecode deficiencies.Jason Zaugg2013-01-281-5/+14
| | | | We'll address them in subsequent commits.
* SI-6666 Restrict hidden `this` access in self/super calls.Jason Zaugg2013-01-203-7/+203
| | | | | | | | | | | | | | | | | Detect when classes (user authored or compiler generated) local to a self or super constructor argument would require premature access to the in-construction instance. The same restriction applies for classes and objects; for objects, the premature access would result in a null via MODULE$ field. A residual error has been lodged as SI-6997. I'd like to remove calls to `Symbol#outerClass` (which relies on the flaky flag INCONSTRUCTOR, see my comments in the JIRA issue for more discussion) from `LambdaLift` and `ExplicitOuter`, and instead use the stack of active self/super calls to know when to skip an enclosing class. That will obviate that flag.
* Merge pull request #1904 from JamesIry/SI-5568_2.10.xGrzegorz Kossakowski2013-01-183-6/+46
|\ | | | | SI-5568 Fixes verify error from getClass on refinement of value type
| * SI-5568 Comment improvements for getClass on primitive intersection.James Iry2013-01-152-7/+9
| | | | | | | | | | Based on code review here are a few comment cleanups and the removal of some dead test code.
| * SI-5568 Fixes verify error from getClass on refinement of value typeJames Iry2013-01-153-6/+44
| | | | | | | | | | | | | | | | ().asInstanceOf[AnyRef with Unit].getClass and 5.asInstanceOf[AnyRef with Int].getClass would cause a verify error. Going the other way, i.e. [Unit with AnyRef] or [Int with AnyRef] worked fine. This commit fixes it that both directions work out to BoxedUnit or java.lang.Integer.
* | Merge pull request #1914 from retronym/ticket/6601Grzegorz Kossakowski2013-01-175-1/+10
|\ \ | | | | | | SI-6601 Publicise derived value contstructor after pickler
| * | SI-6601 Publicise derived value contstructor after picklerJason Zaugg2013-01-165-1/+10
| | | | | | | | | | | | | | | | | | | | | Otherwise the access restrictions are not enforced under separate compilation. See also SI-6608.
* | | Merge pull request #1854 from pufuwozu/ticket-SI-6923Paul Phillips2013-01-175-3/+39
|\ \ \ | | | | | | | | SI-6923 Context now buffers warnings as well as errors
| * | | SI-6923 Context now buffers warnings as well as errorsBrian McKenna2013-01-075-3/+39
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code that was silently typed would not report warnings, even if it returned a successful result. This appeared in the following code which didn't show warnings even with -Ywarn-adapted-args: def foo(a: Any) = a; foo(1, 2) While the following would show the expected warning: def foo[A](a: Any) = a; foo(1, 2)
* | | Merge pull request #1905 from adriaanm/ticket-6956Paul Phillips2013-01-173-2/+31
|\ \ \ | | | | | | | | SI-6956 determine switchability by type, not tree
| * | | use Constant::isIntRange even if it's NIHAdriaan Moors2013-01-151-1/+1
| | | |
| * | | SI-6956 determine switchability by type, not treeAdriaan Moors2013-01-153-2/+31
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | Constant folding will set the type of a constant tree to `ConstantType(Constant(folded))`, while the tree itself can be many different things (in casu, an Ident). We used to look at the tree directly when deciding whether to emit a switch. Now we look at the tree's type. Voilà.
* | | Merge pull request #1892 from retronym/ticket/6479Paul Phillips2013-01-152-2/+60
|\ \ \ | |/ / |/| | SI-6479 Don't lift try exprs in label arguments.
| * | SI-6479 Don't lift try exprs in label arguments.Jason Zaugg2013-01-132-2/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new pattern matcher uses label jumps to GOTO the next case. Uncurry treated these like regular method arguments, and performed the liftedTree() transformation, which ensures that try expressions are only used in a statement position. Even try in statement position of a block used as such an argument are subject to the same transform. This transform stems from the JVM limitation, that try/catch does not leave a value on the stack. See b194446. This commit changes Uncurry to avoid this transform for arguments to label jumps. This avoids needlessly indirect code, and enables tail call elimination in more cases. As an example, Scala 2.10.0 transforms the last method of the enclosed test case to: try { case <synthetic> val x1: Int = 1; case5(){ if (2.==(x1)) { val x2: Int = x1; matchEnd4({ { def liftedTree2(): Unit = try { throw new scala.runtime.NonLocalReturnControl[Unit](nonLocalReturnKey1, ()) } catch { case (e @ (_: ClassNotFoundException)) => () }; liftedTree2() }; TailrecAfterTryCatch.this.bad() }) } else case6() }; case6(){ matchEnd4(throw new MatchError(x1)) }; matchEnd4(x: Unit){ x } } catch { case (ex @ (_: scala.runtime.NonLocalReturnControl[Unit @unchecked])) => if (ex.key().eq(nonLocalReturnKey1)) ex.value() else throw ex } After this patch: @scala.annotation.tailrec final def bad(): Unit = { case <synthetic> val x1: Int = 1; case5(){ if (2.==(x1)) { <synthetic> val x2: Int = x1; matchEnd4({ try { return () } catch { case (e @ (_: ClassNotFoundException)) => () }; TailrecAfterTryCatch.this.bad() }) } else case6() }; case6(){ matchEnd4(throw new MatchError(x1)) }; matchEnd4(x: Unit){ x } }
* | | Merge pull request #1895 from JamesIry/SI_6963_2.10.xPaul Phillips2013-01-154-1/+8
|\ \ \ | | | | | | | | SI-6963 Deprecates -Xmigration switch
| * | | SI-6963 Deprecates -Xmigration switchJames Iry2013-01-144-1/+8
| |/ / | | | | | | | | | | | | | | | -Xmigration is specific to the 2.7 to 2.8 upgrade and is no longer relevant. There is no plan to maintain it so it will be removed. This commit deprecates it in anticipation.
* | | Merge pull request #1888 from retronym/ticket/6675Paul Phillips2013-01-1511-10/+53
|\ \ \ | | | | | | | | SI-6675 -Xlint arity enforcement for extractors
| * | | SI-6675 Test new warning under -Xoldpatmat.Jason Zaugg2013-01-153-0/+18
| | | | | | | | | | | | | | | | This commit should be discarded when merging to master.
| * | | SI-6675 -Xlint arity enforcement for extractorsJason Zaugg2013-01-158-10/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extractor Patterns changed in 2.10.0 to implement the letter of the spec, which allows a single binding to capture an entire TupleN. But this can hide arity mismatches, especially if the case body uses the bound value as an `Any`. This change warns when this happens under -Xlint.
* | | | Merge pull request #1879 from adriaanm/ticket-6955Paul Phillips2013-01-153-1/+28
|\ \ \ \ | | | | | | | | | | SI-6955 switch emission no longer foiled by type alias
| * | | | SI-6955 switch emission no longer foiled by type aliasAdriaan Moors2013-01-103-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | dealias the type of the scrutinee before checking it's switchable now with tests! (using IcodeTest since javap is not available everywhere)
* | | | | Merge pull request #1894 from retronym/ticket/6082Adriaan Moors2013-01-143-4/+22
|\ \ \ \ \ | | | | | | | | | | | | SI-6082 Conditionally expand @ann(x) to @ann(value = x)
| * | | | | SI-6082 Conditionally expand @ann(x) to @ann(value = x)Jason Zaugg2013-01-133-4/+22
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... if the annotation has an argument with the name `value`. Doing so unconditionally obscures error messages. We still require that arguments to ClassFileAnnotations are named, other than for this special case.
* | | | | Merge pull request #1890 from retronym/ticket/5440Adriaan Moors2013-01-143-0/+13
|\ \ \ \ \ | | | | | | | | | | | | SI-5440 Test case for exhaustiveness check
| * | | | | SI-5440 Test case for exhaustiveness checkJason Zaugg2013-01-133-0/+13
| | |_|/ / | |/| | | | | | | | | | | | | Reported against patmatclassic, working in virtpatmat.
* | | | | Merge pull request #1889 from retronym/ticket/5340Adriaan Moors2013-01-143-1/+36
|\ \ \ \ \ | | | | | | | | | | | | SI-5340 Change println to log
| * | | | | SI-5340 Change println to logJason Zaugg2013-01-133-1/+36
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | An esoteric implicit search could trigger an "amb prefix ..." message to standard out. Now the message has been improved and sent to the logger.
* | | | | Merge pull request #1878 from adriaanm/ticket-6925Adriaan Moors2013-01-145-145/+183
|\ \ \ \ \ | | | | | | | | | | | | SI-6925 use concrete type in applyOrElse's match's selecto
| * | | | | clean up synthesizePartialFunctionAdriaan Moors2013-01-103-19/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implement the following review comments by @retronym: - [x] Please clothe this naked assert. - [x] Use match to dissect targs and check isFullyDefined. - [x] Instead of `targs.head`/`targs.last`, use `val argTp :: resTp :: Nil = targs`. - [x] Add a quasi-quote-style comment for `apply`. - [x] Factor out mkCastPreservingAnnotations.
| * | | | | rework partial function synthesisAdriaan Moors2013-01-092-146/+163
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | no behavioral changes, just highly overdue cleanup some TODOs for further improvements
| * | | | | SI-6925 use concrete type in applyOrElse's match's selectorAdriaan Moors2013-01-092-1/+19
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a regression introduced in 28483739c3: PartialFunction synthesis was broken so that we'd get: ``` scala> def f[T](xs: Set[T]) = xs collect { case x => x } f: [T](xs: Set[T])scala.collection.immutable.Set[_ <: T] ``` rather than ``` scala> def f[T](xs: Set[T]) = xs collect { case x => x } f: [T](xs: Set[T])scala.collection.immutable.Set[T] ```
* | | | | Merge pull request #1876 from adriaanm/ticket-5189-infAdriaan Moors2013-01-143-6/+19
|\ \ \ \ \ | | | | | | | | | | | | SI-5189 detect unsoundness when inferring type of match
| * | | | | SI-5189 detect unsoundness when inferring type of matchAdriaan Moors2013-01-093-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GADT skolems encode type slack that results from pattern matching on variant type constructors I thought they would not longer be relevant after cases have been typed, and since they caused weird issues with the old pattern matcher, I deskolemized in typedCase however, when we don't have an expected type for the match, we need to keep the skolems around until the skolemized type makes it out of the match and it becomes the result of type inference for that match when you do have an expected type, it will propagate to the case-level and the confrontation will thus already take place when typing individual cases
* | | | | | Merge pull request #1872 from kzys/jira-6555-2.10.xAdriaan Moors2013-01-141-1/+1
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-6555 Scaladoc's class filter shouldn't drop the last character (2.10.x)
| * | | | | | SI-6555 Scaladoc's class filter shouldn't drop the last characterKato Kazuyoshi2013-01-091-1/+1
| | |/ / / / | |/| | | | | | | | | | | | | | | | The event handler have to wait "keyup", not "keydown".
* | | | | | Merge pull request #1860 from heathermiller/issue/6930Adriaan Moors2013-01-141-0/+14
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-6930 adds documentation to reduceLeft in TraversableOnce
| * | | | | | SI-6930 adds documentation to reduceLeft in TraversableOnceHeather Miller2013-01-081-0/+14
| | |/ / / / | |/| | | |
* | | | | | Merge pull request #1838 from viktorklang/wip-6905-√Adriaan Moors2013-01-142-4/+28
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-6594 - Switch to sneakyThrows instead of Unsafe.throwException as per...
| * | | | | | SI-6905 - Switch to sneakyThrows instead of Unsafe.throwException as per new ↵Viktor Klang2013-01-142-4/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | jsr166y to avoid issues with Android
* | | | | | | Merge pull request #1891 from retronym/ticket/6126Adriaan Moors2013-01-141-0/+8
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | SI-6126 Test case for varargs of tagged primitives.
| * | | | | | | SI-6126 Test case for varargs of tagged primitives.Jason Zaugg2013-01-131-0/+8
| | |_|_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | This started working after the merge fe1110f. I didn't track down precisely which commit was responsible beyond that.
* | | | | | | Merge pull request #1875 from heathermiller/issue/6946Adriaan Moors2013-01-141-15/+86
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | SI-6946, SI-6924 Greatly improves IsTraversableLike docs
| * | | | | | | SI-6946, SI-6924 Greatly improves IsTraversableLike docsHeather Miller2013-01-091-15/+86
| | |_|_|/ / / | |/| | | | |
* | | | | | | Merge pull request #1882 from JamesIry/SI-5954_2.10.xAdriaan Moors2013-01-1411-0/+97
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | SI-5954 Adds implementation restriction preventing companions in package...
| * | | | | | | SI-5954 Implementation restriction preventing companions in package objsJames Iry2013-01-1311-0/+97
| | |/ / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Companion objects (and thus also case classes) in package objects caused an assert about an overloaded symbol when everything was compiled twice. It's a hairy problem that doesn't fit in 2.10.1. So this fix adds an implementation restriction. It also has a test to make sure the error messages are clean and reasonably friendly, and does not catch other things defined in package objects. The test includes a commented out test in case somebody thinks they've solved the underlying problem. A handful of tests were falling afoul of the new implementation restriction. I verified that they do in fact fail on second compile so they aren't false casualties. But they do test real things we'd like to work once the re-compile issue is fixed. So I added a -X flag to disable the implementation restriction and made all the tests accidentally clobbered by the restriction use that flag.