summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #3037 from gkossakowski/fix-merge-3018v2.11.0-M6Grzegorz Kossakowski2013-10-1420-27/+411
|\ | | | | [resubmit] Experimental Single Abstract Method support (sammy meets world)
| * Merge remote-tracking branch 'scala/master' into fix-merge-3018Grzegorz Kossakowski2013-10-1464-581/+933
| |\ | | | | | | | | | | | | Conflicts: src/compiler/scala/tools/nsc/typechecker/Typers.scala
| * | Remove stray debug commentAdriaan Moors2013-10-081-2/+0
| | |
| * | Single Abstract Method support: java8 testAdriaan Moors2013-10-084-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inspired by test/files/run/t7398.scala and sammy_poly. Added some notes to original tests. Elaborating on that note: we don't yet desugar `f(a)` to `f.sam(a)`, like we do for regular functions: `f(a)` becomes `f.apply(a)`. It seems pleasingly symmetrical and is easy to implement, but not sure it's a good idea...
| * | Extract SerialVersionUIDAnnotation. Make SAM body synthetic.Adriaan Moors2013-10-085-12/+18
| | | | | | | | | | | | Addressing review feedback.
| * | Don't pursue SAM translation after an arity mismatch.Jason Zaugg2013-10-084-2/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change: scala> trait T { def apply(a: Int): Int } defined trait T scala> ((x: Int, y: Int) => 0): T <console>:9: error: object creation impossible, since method apply in trait T of type (a: Int)Int is not defined ((x: Int, y: Int) => 0): T ^ After the change, these cases report the same errors as they do *without* -Xexperimental.
| * | Single Abstract Method support: synthesize SAMsAdriaan Moors2013-10-048-12/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under `-Xexperimental`, `typedFunction` invokes `synthesizeSAMFunction` when the expected type for the function literal (`pt`) is not the built-in `FunctionN` type of the expected arity, but `pt` does have a SAM with the expected number of arguments. PS: We'll require `import language.sam` instead of `-Xexperimental`, as soon as the SIP is ready and there are more tests.
| * | Single Abstract Method support: synthesis helpersAdriaan Moors2013-10-042-0/+192
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `synthesizeSAMFunction` will be used to expand the following tree: ``` { (p1: T1, ..., pN: TN) => body } : S ``` to: ``` { def apply$body(p1: T1, ..., pN: TN): T = body new S { def apply(p1: T1, ..., pN: TN): T = apply$body(p1,..., pN) } } ``` The expansion assumes `S` (the expected type) defines a single abstract method (let's call that method `apply` for simplicity). 1. If 'T' is not fully defined, it is inferred by type checking `def apply$body` without a result type before type checking the block. The method's inferred result type is used instead of T`. [See test/files/pos/sammy_poly.scala] 2. To more easily enforce S's members are not in scope in `body`, that tree goes to the `apply$body` method that's outside the anonymous subclass of S. (The separate `apply$body` method simplifies the implementation of 1&2.) 3. The following restrictions apply to S: 1. Its primary constructor (if any) must be public, no-args, not overloaded. 2. S must have exactly one abstract member, its SAM 3. SAM must take exactly one argument list 4. SAM must be monomorphic We may later relax these requirements to allow an implicit argument list, both on the constructor and the SAM. Could also let the SAM be polymorphic.
| * | Clarify findMembers, add reverse engineered docsAdriaan Moors2013-10-041-5/+17
| | | | | | | | | | | | | | | When looking for deferred members, it only makes sense to retry when deferred members aren't excluded.
| * | Simplify partest.task target, fix typo in comment.Adriaan Moors2013-10-042-3/+3
| | |
* | | Merge pull request #3038 from retronym/topic/by-name-revertGrzegorz Kossakowski2013-10-145-3/+35
|\ \ \ | | | | | | | | SI-7899 Allow by-name inference under -Yinfer-by-name
| * | | SI-7899 Allow by-name inference under -Yinfer-by-nameJason Zaugg2013-10-145-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As usual, the hole has been exploited in the wild. While you can't abstract over by-name-ness without running into the ClassCastException or an un-applied Function0, there are cases like the enclosed test where you can tiptoe around those cases. I've proposed a small change to Scalaz to avoid tripping over this problem: https://github.com/scalaz/scalaz/pull/562/files But this commit I've also added a transitional flag, -Yinfer-by-name, that they could use to back-publish older versions without code changes. It is also an insurance policy for other projects that might be exploiting the same hole.
* | | | Merge pull request #3036 from paulp/pr/aestheticsPaul Phillips2013-10-132-76/+65
|\ \ \ \ | |_|_|/ |/| | | Improvement in code aesthetics.
| * | | Aesthetics in Trees.Paul Phillips2013-10-131-52/+52
| | | | | | | | | | | | | | | | | | | | | | | | As long as it's a block of pure boilerplate we have to navigate around all the time, it may as well be the most beautiful boilerplate it knows how to be.
| * | | Aesthetics in GenTrees.Paul Phillips2013-10-131-24/+13
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A nominee for "worst textual shape" might be \\\\\ ///// \\\\\ ///// \\\\\ ///// where the zigzagging wall of text is confined to the first forty columns. In this commit we halve the vertical space usage and double the readability.
* | | Merge pull request #3031 from retronym/topic/skip-docPaul Phillips2013-10-121-38/+40
|\ \ \ | | | | | | | | An ant property to skip building docs
| * | | An ant property to skip building docsJason Zaugg2013-10-111-38/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It can be situationally useful to run: ant -Dskip.docs=1 dist-maven When troubleshooting problems that require creation of a distribution, such as pr-integrate-partest. Scaladoc isn't incremental, so you burn a few minutes for a single file change to the compiler or library.
* | | | Merge pull request #3032 from retronym/ticket/7239-testPaul Phillips2013-10-122-0/+16
|\ \ \ \ | | | | | | | | | | SI-7239 A bonus test case from [scala-user]
| * | | | SI-7239 A bonus test case from [scala-user]Jason Zaugg2013-10-112-0/+16
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | Thanks to Ilya Denisov for another sample [1] that progressed with the fix for SI-7239, 174334b. [1] https://groups.google.com/forum/#!topic/scala-user/8rZeCeiTYDo
* | | | Merge pull request #3024 from retronym/ticket/7895Paul Phillips2013-10-1230-70/+220
|\ \ \ \ | | | | | | | | | | SI-7895 Error reporting: avoid cascading, truncation
| * | | | SI-7985 Typecheck args after failure to typecheck functionJason Zaugg2013-10-0911-13/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `missing1.foo(missing2)` now reports `missing1` and `missing2` as not found. Previously, only the first was reported. The arguments are typed with an expected type ErrorType. We propagate this through as the inferred type of anonymous function parameters to avoid issuing cascading "missing parameter type" errors in code like: scala> Nil.mapp(x => abracadabra) <console>:8: error: value mapp is not a member of object Nil Nil.mapp(x => abracadabra) ^ <console>:8: error: not found: value abracadabra Nil.mapp(x => abracadabra) ^ This was in response to unwanted changes in the output of existing neg tests; no new test is added. Similarly, we refine the errors in neg/t6436b.scala by to avoid cascaded errors after: type mismatch; found: StringContext, required: ?{def q: ?}
| * | | | SI-7895 Issue all buffered errors after silent mode.Jason Zaugg2013-10-0910-25/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than just the first. For example, `foo(wizzle, wuzzle, woggle)` should report all three not-found symbols.
| * | | | SI-7895 Avoid cascade of "symbol not found" in pattern matchesJason Zaugg2013-10-0911-35/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we can't type check the `Foo` in `case Foo(a, b) => (a, b)`, we should enter error symbols for `a` and `b` to avoid further errors being reported in the case body.
* | | | | Merge pull request #3025 from retronym/ticket/7902Paul Phillips2013-10-122-0/+18
|\ \ \ \ \ | | | | | | | | | | | | SI-7902 Fix spurious kind error due to an unitialized symbol
| * | | | | SI-7902 Fix spurious kind error due to an unitialized symbolJason Zaugg2013-10-092-0/+18
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tracked down this error: <none> is invariant, but type Y2 is declared covariant <none>'s bounds<notype> are stricter than type X2's declared bounds >: Nothing <: Any, <none>'s bounds<notype> are stricter than type Y2's declared bounds >: Nothing <: Any to `Symbol#typeParams` returning `List(NoSymbol)` if the symbol was not initialized. This happends in the enclosed test for: // checkKindBoundsHK() hkArgs = List(type M3) hkParams = List(type M2) This commit forces the symbol of the higher-kinded type argument before checking kind conformance. A little backstory: The `List(NoSymbol)` arises from: class PolyTypeCompleter... { // @M. If `owner` is an abstract type member, `typeParams` are all NoSymbol (see comment in `completerOf`), // otherwise, the non-skolemized (external) type parameter symbols override val typeParams = tparams map (_.symbol) The variation that triggers this problem gets into the kind conformance checks quite early on, during naming of: private[this] val x = ofType[InSeq] The inferred type of which is forced during: def addDerivedTrees(typer: Typer, stat: Tree): List[Tree] = stat match { case vd @ ValDef(mods, name, tpt, rhs) if !noFinishGetterSetter(vd) => // If we don't save the annotations, they seem to wander off. val annotations = stat.symbol.initialize.annotations
* | | | | Merge pull request #3021 from paulp/pr/is-he-stable-or-is-he-volatilePaul Phillips2013-10-123-77/+85
|\ \ \ \ \ | |_|_|/ / |/| | | | Extract isStable and isVolatile from Type.
| * | | | Extract isStable and isVolatile from Type.Paul Phillips2013-10-053-77/+85
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As with finalResultType, this is easier to control and WAY easier to understand. Look, all the relevant code fits on half a screenful rather than being spread out over 5000 lines and you have to be constantly conscious of what is overriding what. Truly it would be hard to damn the indiscriminate use of subtype polymorphism any more soundly than does this, by way of contrast: def isStable(tp: Type): Boolean = tp match { case _: SingletonType => true case NoPrefix => true case TypeRef(_, NothingClass | SingletonClass, _) => true case TypeRef(_, sym, _) if sym.isAbstractType => tp.bounds.hi.typeSymbol isSubClass SingletonClass case TypeRef(pre, sym, _) if sym.isModuleClass => isStable(pre) case TypeRef(_, _, _) if tp ne tp.dealias => isStable(tp.dealias) case TypeVar(origin, _) => isStable(origin) case AnnotatedType(_, atp, _) => isStable(atp) // Really? case _: SimpleTypeProxy => isStable(tp.underlying) case _ => false } That's all of it! If there are bugs in it (of course there are) some might even be found now.
* | | | Merge pull request #3020 from paulp/pr/overriding-pairsJason Zaugg2013-10-0919-381/+514
|\ \ \ \ | |_|/ / |/| | | Generalize OverridingPairs to SymbolPairs.
| * | | Generalize OverridingPairs to SymbolPairs.Paul Phillips2013-10-0519-381/+514
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Increases your chance of knowing what is going on in OverridingPairs. Introduces some new abstractions which I hope for your own sakes you will put to use in some way: RelativeTo: operations relative to a prefix SymbolPair: two symbols being compared for something, and the enclosing class where the comparison is being performed Fixed a minor bug with access by accident by way of more principled pair analysis. See run/private-override.scala. Upgraded the error message issued on certain conflicts to give the line numbers of both conflicting methods, as opposed to just one and you go hunting.
* | | Merge pull request #3022 from retronym/ticket/7899Jason Zaugg2013-10-096-13/+35
|\ \ \ | |_|/ |/| | Don't infer by-name types during, e.g. eta-expansion
| * | SI-7899 Don't infer by-name types during, e.g. eta-expansionJason Zaugg2013-10-076-13/+35
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given: def id[A](a: A): A = a def foo(f: (=> Int) => Int) = () foo(id) We eta-expanded `id` and inferred `A` to be `=> Int` to satisfy the expected type set forth by the formal parameter `f`. We really shouldn't go about inferring types that we can't *write*. Our attempt to do so led promptly into a `ClassCastException` in the enclosed test. This commit: - drops by-name-ness during `inferExprInstance` - tests that this results in a type error for the reported bug (neg/t7899) - tests that a method with a by-name parameter can still be eta expanded to match function with a corresponding by-name parameter (run/t7899) - discovers the same latent CCE in pos/t7584 - now that would be a type error - so we compensate by using placeholder functions rather than eta-expansion. - and move that that test to `run` for good measure.
* | Merge pull request #3014 from ceedubs/pr/implicitNotFound-scaladocAdriaan Moors2013-10-071-2/+5
|\ \ | |/ |/| Describe type parameter interpolation in @implicitNotFound documentation
| * Describe type parameter interpolation in @implicitNotFound documentationCody Allen2013-10-031-2/+5
| | | | | | | | | | | | Using this feature is necessary for helpful error messages, so it should be documented. Thank you to @adriaanm for recommending the this description.
* | Merge pull request #3005 from paulp/pr/7886Paul Phillips2013-10-0331-76/+221
|\ \ | | | | | | SI-7886 unsoundness in pattern matcher.
| * | SI-6680 unsoundness in gadt typing.Paul Phillips2013-10-0124-69/+185
| | | | | | | | | | | | | | | | | | | | | Introduces -Xstrict-inference to deal with the significant gap between soundness and what presently compiles. I'm hopeful that it's TOO strict, because it finds e.g. 75 errors compiling immutable/IntMap.scala, but it might be that bad.
| * | SI-7886 unsoundness in pattern matcher.Paul Phillips2013-10-018-12/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I tracked down what was behind the issue described here: // TODO: fix the illegal type bound in pos/t602 -- type inference // messes up before we get here: /*override def equals(x$1: Any): Boolean = ... // Span[Any] --> Any is not a legal type argument for Span! val o5: Option[com.mosol.sl.Span[Any]] = */ ...which led straight to the unsoundness seen in neg/t7886. It is dangerous to have an expected type of "Any" because the type system will blithely ignore kind errors, since "Any" can absorb anything. The consequence in this instance was that inferring the case constructor for a type like Foo[T <: Bound] if done with expected type Any, this would come up with Foo[Any]. I altered it to use expected type Foo[T], which lets the dummy type parameter survive to carry the bound forward and restores sense to the inference. The before/after output for -Xprint:patmat on pos/t602.scala is: 15c15 < if (x1.isInstanceOf[com.mosol.sl.Span[Any]]) --- > if (x1.isInstanceOf[com.mosol.sl.Span[K]]) 17c17 < <synthetic> val x2: com.mosol.sl.Span[Any] = \ (x1.asInstanceOf[com.mosol.sl.Span[Any]]: com.mosol.sl.Span[Any]); --- > <synthetic> val x2: com.mosol.sl.Span[K] = \ (x1.asInstanceOf[com.mosol.sl.Span[K]]: com.mosol.sl.Span[K]); 19,20c19,20 < val low$0: Option[Any] = x2.low; < val high$0: Option[Any] = x2.high; --- > val low$0: Option[K] = x2.low; > val high$0: Option[K] = x2.high; A file in the library depended (needlessly) on the unsoundness. It was easy to fix but reminds us this may affect existing code.
* | | Merge pull request #3015 from sschaef/eclipse-updateAdriaan Moors2013-10-031-1/+1
|\ \ \ | | | | | | | | Correct build command for scala-ide
| * | | Correct build command for scala-ideSimon Schaefer2013-10-031-1/+1
|/ / /
* | | Merge pull request #3013 from retronym/topic/unspec-fix-windowsAdriaan Moors2013-10-034-24/+22
|\ \ \ | | | | | | | | Rework cff8b569 to heal the windows build.
| * | | Rework cff8b569 to heal the windows build.Jason Zaugg2013-10-034-24/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - change newTermName to fix negative length names rather than reject them - restore the old logic in unspecializedName for names that result from AnyRef specialized type parameters. Why does fix the windows build? I remain none the wiser.
* | | | Merge pull request #2973 from sschaef/eclipse-update3Adriaan Moors2013-10-0310-113/+58
|\ \ \ \ | |_|_|/ |/| | | Update of Eclipse project files
| * | | Update of Eclipse project filesSimon Schaefer2013-09-2210-113/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Update of project dependencies - Deletion of scala-xml project - Deletion of scala-parser-combinators project - Update of .gitignore to match nested .cache files
* | | | Merge pull request #2965 from retronym/ticket/7859Grzegorz Kossakowski2013-10-0310-37/+147
|\ \ \ \ | | | | | | | | | | SI-7859 Value classes may wrap a non-public member
| * | | | SI-7859 Value classes may wrap a non-public memberJason Zaugg2013-09-2910-37/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We allow value class constructors to be non-public, so to be regular, we should also allow the same for the param accessor. This commit uses the 'makeNotPrivate' machinery to ensure that the backend can generate the requisite unboxing calls. This commit: - refactors the code that enforced the restrictions, improving a few error messages and positions. The remaining restrictions needed some rewording in light of this change. - allows value classes to have non-public, val parameters. private[this] / protected[this] are still disallowed as value classes don't have a concept of `this`, and because trying to accomdate then would complicate the implementation. This means that `class C(x: Int) extends AnyVal` is not allowed, the user still must write `private val x: Int` or `val x: Int`. - Outlaw `class C()()(val x: Int) extends AnyVal` to curtail any bugs that might lurk in such a formulation. The tests: - Show that the privacy is respected in the typer phase, under joint and separate compilation. We don't want a repeat performance of SI-6601. - Show that code that needs compiler-generated unboxes works under both compilation scenarios - Checks that the remaining restrictions are enforced and well communicated.
* | | | | Merge pull request #2994 from xeno-by/topic/bundlesJason Zaugg2013-10-0329-43/+269
|\ \ \ \ \ | | | | | | | | | | | | assorted fixes for bundles
| * | | | | macro bundles are now usable in replEugene Burmako2013-10-023-4/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of the previous commits relaxed the top-level restriction for bundles, turning it into a requirement of staticness (i.e. bundles nested in static objects are also okay now). This means that we can now define bundles in repl. Almost. There's still a little problem remaining that arises from the fact that when compiling a line of input, repl doesn't automatically import all previously defined symbols, but rather uses an heuristic to scan the input and guess what symbols need to be imported. Unfortunately for bundles, this heuristic fails, because when scanning a macro definition that looks like `def foo = macro Macros.foo`, it thinks that it's only necessary to import a term symbol called Macros (a vanilla way of defining macro impls), but not a type symbol called Macros (a new way of writing macro impls in bundles). This commit fixes the problem by making the repl look for both term and type symbols corresponding to the identifiers used in macro definitions.
| * | | | | gets rid of randomness in virtual filenames for bundlesEugene Burmako2013-10-022-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bundles are emitted in compilation units that wrap virtual source files. Previously we had those virtual files named randomly to ensure freshness, but that led to infinite compilation loops in SBT (see the commit message for more details and a link to a scala-user discussion). Now the names are generated deterministically from full names of bundles, which fixes the problems with SBT.
| * | | | | clearly establishes what macro bundles areEugene Burmako2013-10-0225-29/+216
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously it was enough to just extend scala.reflect.macros.Macro, which created some loopholes, but now scalac enforces that bundles: 1) Are static (not necessarily top-level, but just static) 2) Are traits (objects shouldn't be bundles anyway, and classes bring complications with their ctors which require special treatment in generated classes, so why support them if they don't bring anything new to the table?) 3) Are monomorphic (again, this brings unnecessary complications wrt auxiliary code generation, so I don't see merit in supporting polymorphic bundles, whatever that a polymorphic bundle could mean) 4) Don't provide concrete implementation for Macro.c (if they do then what is the point?)
* | | | | Merge pull request #2977 from ↵Jason Zaugg2013-10-033-4/+12
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | sjrd/topic/remove-classpath-logic-dependent-on-inline Don't avoid to load trait impl .class without inliner.
| * | | | Add -Yno-load-impl-class disabling loading of $class.class files.Sébastien Doeraene2013-09-272-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The parent commit, a3f71badf67bbaac1a4ba16f68211ea6e31aa473, removed some logic preventing $class.class files to be loaded. It did so only when the inliner was off. Should this cause any issue, this option provides a means to restore the old behavior by *never* loading $class.class files. So, using -inline -Yno-load-impl-class will not load $class.class files either (where previously -inline would load them). The two old behaviors being available by *either* using -inline *or* -Yno-load-impl-class (not both).