summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes30
-rw-r--r--README.md15
-rw-r--r--spec/07-implicits.md12
-rw-r--r--spec/08-pattern-matching.md2
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala5
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala7
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala18
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala50
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala7
-rw-r--r--src/eclipse/interactive/.gitignore2
-rw-r--r--src/eclipse/partest/.gitignore2
-rw-r--r--src/eclipse/reflect/.gitignore2
-rw-r--r--src/eclipse/repl/.gitignore2
-rw-r--r--src/eclipse/scala-compiler/.gitignore2
-rw-r--r--src/eclipse/scala-library/.gitignore2
-rw-r--r--src/eclipse/scaladoc/.classpath6
-rw-r--r--src/eclipse/scaladoc/.gitignore2
-rw-r--r--src/eclipse/scalap/.gitignore2
-rw-r--r--src/eclipse/test-junit/.gitignore2
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala23
-rw-r--r--src/library/scala/collection/LinearSeqOptimized.scala8
-rw-r--r--src/library/scala/collection/TraversableLike.scala2
-rw-r--r--src/library/scala/collection/immutable/RedBlackTree.scala4
-rw-r--r--src/library/scala/collection/immutable/Set.scala74
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala18
-rw-r--r--src/library/scala/concurrent/Future.scala2
-rw-r--r--src/library/scala/runtime/Tuple2Zipped.scala8
-rw-r--r--src/library/scala/runtime/Tuple3Zipped.scala8
-rw-r--r--src/library/scala/sys/process/Process.scala4
-rw-r--r--src/library/scala/util/Either.scala12
-rw-r--r--src/partest-extras/scala/tools/partest/IcodeComparison.scala9
-rw-r--r--src/reflect/scala/reflect/io/Streamable.scala8
-rw-r--r--test/files/neg/t4425b.check22
-rw-r--r--test/files/neg/t8127a.check4
-rw-r--r--test/files/neg/t8127a.scala12
-rw-r--r--test/files/neg/t8989.check4
-rw-r--r--test/files/neg/t8989.scala14
-rw-r--r--test/files/run/t7850c.scala11
-rw-r--r--test/files/run/t7850d.scala17
-rw-r--r--test/files/run/t9029.flags1
-rw-r--r--test/files/run/t9029.scala15
-rw-r--r--test/files/run/t9029b.check1
-rw-r--r--test/files/run/t9029b.scala31
-rw-r--r--test/files/run/t9029c.scala21
45 files changed, 370 insertions, 135 deletions
diff --git a/.gitattributes b/.gitattributes
index ac98781b3d..da4421cb78 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2,20 +2,24 @@
# this must be first so later entries will override it
* text=auto
+# check out text files with lf, not crlf, on Windows. (especially
+# important for Scala source files, since """ preserves line endings)
+text eol=lf
+
# These files are text and should be normalized (convert crlf => lf)
-*.c text
-*.check text
-*.css text
-*.flags text
-*.html text
-*.java text
-*.js text
-*.policy text
-*.sbt text
-*.scala text
-*.sh text
-*.txt text
-*.xml text
+*.c eol=lf
+*.check eol=lf
+*.css eol=lf
+*.flags eol=lf
+*.html eol=lf
+*.java eol=lf
+*.js eol=lf
+*.policy eol=lf
+*.sbt eol=lf
+*.scala eol=lf
+*.sh eol=lf
+*.txt eol=lf
+*.xml eol=lf
# Windows-specific files get windows endings
*.bat eol=crlf
diff --git a/README.md b/README.md
index d59cb08489..c8f3f206c4 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,18 @@
# Welcome!
This is the official repository for the [Scala Programming Language](http://www.scala-lang.org).
+# How to contribute
+
To contribute to the Scala Standard Library, Scala Compiler and Scala Language Specification, please send us a [pull request](https://help.github.com/articles/using-pull-requests/#fork--pull) from your fork of this repository! We do have to ask you to sign the [Scala CLA](http://typesafe.com/contribute/cla/scala) before we can merge any of your work into our code base, to protect its open source nature.
-For more information on building and developing the core of Scala, read on! Please also check out our [guidelines for contributing](CONTRIBUTING.md).
+For more information on building and developing the core of Scala, read on!
+
+Please also check out:
+
+* our [guidelines for contributing](CONTRIBUTING.md).
+* the ["Scala Hacker Guide"](http://scala-lang.org/contribute/hacker-guide.html) covers some of the same ground as this README, but in greater detail and in a more tutorial style, using a running example.
+
+# Reporting issues
We're still using Jira for issue reporting, so please [report any issues](https://issues.scala-lang.org) over there.
(We would love to start using GitHub Issues, but we're too resource-constrained to take on this migration right now.)
@@ -154,6 +163,10 @@ ideas and coordinate your effort with others.
NOTE: we are working on migrating the build to sbt.
+If you are behind a HTTP proxy, include
+[`ANT_ARGS=-autoproxy`](https://ant.apache.org/manual/proxy.html) in
+your environment.
+
Run `ant build-opt` to build an optimized version of the compiler.
Verify your build using `ant test-opt`.
diff --git a/spec/07-implicits.md b/spec/07-implicits.md
index 726320ed33..28f6dfe5a8 100644
--- a/spec/07-implicits.md
+++ b/spec/07-implicits.md
@@ -357,8 +357,16 @@ they appear and all the resulting evidence parameters are concatenated
in one implicit parameter section. Since traits do not take
constructor parameters, this translation does not work for them.
Consequently, type-parameters in traits may not be view- or context-bounded.
-Also, a method or class with view- or context bounds may not define any
-additional implicit parameters.
+
+Evidence parameters are prepended to the existing implicit parameter section, if one exists.
+
+For example:
+
+```scala
+def foo[A: M](implicit b: B): C
+// expands to:
+// def foo[A](implicit evidence$1: M[A], b: B): C
+```
###### Example
The `<=` method from the [`Ordered` example](#example-ordered) can be declared
diff --git a/spec/08-pattern-matching.md b/spec/08-pattern-matching.md
index c494fbcef5..d496388a91 100644
--- a/spec/08-pattern-matching.md
+++ b/spec/08-pattern-matching.md
@@ -507,7 +507,7 @@ def f[B](t: Term[B]): B = t match {
The expected type of the pattern `y: Number` is
`Term[B]`. The type `Number` does not conform to
`Term[B]`; hence Case 2 of the rules above
-applies. This means that `b` is treated as another type
+applies. This means that `B` is treated as another type
variable for which subtype constraints are inferred. In our case the
applicable constraint is `Number <: Term[B]`, which
entails `B = Int`. Hence, `B` is treated in
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 3469726455..936bed7c8f 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -1686,7 +1686,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
try {
val stream = new FileOutputStream(file)
printer.setWriter(new PrintWriter(stream, true))
- printer.printClass(cls)
+ try
+ printer.printClass(cls)
+ finally
+ stream.close()
informProgress(s"wrote $file")
} catch {
case e: IOException =>
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzer.scala b/src/compiler/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzer.scala
index 700b2f2f6c..594fd8923c 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzer.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzer.scala
@@ -475,4 +475,4 @@ class InitialProducerSourceInterpreter extends SourceInterpreter {
override def newExceptionValue(tryCatchBlockNode: TryCatchBlockNode, handlerFrame: Frame[_ <: Value], exceptionType: Type): SourceValue = {
new SourceValue(1, ExceptionProducer(handlerFrame))
}
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 163c44822e..ee7c839de9 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -475,13 +475,6 @@ abstract class UnCurry extends InfoTransform
withNeedLift(needLift = true) { super.transform(tree) }
else
super.transform(tree)
- case UnApply(fn, args) =>
- val fn1 = transform(fn)
- val args1 = fn.symbol.name match {
- case nme.unapplySeq => transformArgs(tree.pos, fn.symbol, args, patmat.alignPatterns(global.typer.context, tree).expectedTypes)
- case _ => args
- }
- treeCopy.UnApply(tree, fn1, args1)
case Apply(fn, args) =>
val needLift = needTryLift || !fn.symbol.isLabel // SI-6749, no need to lift in args to label jumps.
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala b/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala
index e84ccbf754..1916050dd8 100644
--- a/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala
+++ b/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala
@@ -86,9 +86,25 @@ trait PatternExpander[Pattern, Type] {
* @param fixed The non-sequence types which are extracted
* @param repeated The sequence type which is extracted
*/
- final case class Extractor(whole: Type, fixed: List[Type], repeated: Repeated) {
+ final case class Extractor(whole: Type, fixed: List[Type], repeated: Repeated, typeOfSinglePattern: Type) {
require(whole != NoType, s"expandTypes($whole, $fixed, $repeated)")
+ /** A pattern with arity-1 that doesn't match the arity of the Product-like result of the `get` method,
+ * will match that result in its entirety. Example:
+ *
+ * {{{
+ * warning: there was one deprecation warning; re-run with -deprecation for details
+ * scala> object Extractor { def unapply(a: Any): Option[(Int, String)] = Some((1, "2")) }
+ * defined object Extractor
+ *
+ * scala> "" match { case Extractor(x: Int, y: String) => }
+ *
+ * scala> "" match { case Extractor(xy : (Int, String)) => }
+ * warning: there was one deprecation warning; re-run with -deprecation for details
+ * }}}
+ * */
+ def asSinglePattern: Extractor = copy(fixed = List(typeOfSinglePattern))
+
def productArity = fixed.length
def hasSeq = repeated.exists
def elementType = repeated.elementType
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala b/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala
index b1783dc81f..d4f44303bb 100644
--- a/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala
+++ b/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala
@@ -43,8 +43,9 @@ trait ScalacPatternExpanders {
orElse definitions.elementType(ArrayClass, seq)
)
}
- def newExtractor(whole: Type, fixed: List[Type], repeated: Repeated): Extractor =
- logResult(s"newExtractor($whole, $fixed, $repeated")(Extractor(whole, fixed, repeated))
+ def newExtractor(whole: Type, fixed: List[Type], repeated: Repeated, typeOfSinglePattern: Type): Extractor =
+ logResult(s"newExtractor($whole, $fixed, $repeated, $typeOfSinglePattern")(Extractor(whole, fixed, repeated, typeOfSinglePattern))
+ def newExtractor(whole: Type, fixed: List[Type], repeated: Repeated): Extractor = newExtractor(whole, fixed, repeated, tupleType(fixed))
// Turn Seq[A] into Repeated(Seq[A], A, A*)
def repeatedFromSeq(seqType: Type): Repeated = {
@@ -73,26 +74,27 @@ trait ScalacPatternExpanders {
* Unfortunately the MethodType does not carry the information of whether
* it was unapplySeq, so we have to funnel that information in separately.
*/
- def unapplyMethodTypes(whole: Type, result: Type, isSeq: Boolean): Extractor = {
- val expanded = (
- if (result =:= BooleanTpe) Nil
- else typeOfMemberNamedGet(result) match {
+ def unapplyMethodTypes(context: Context, whole: Type, result: Type, isSeq: Boolean): Extractor = {
+ if (result =:= BooleanTpe) newExtractor(whole, Nil, NoRepeated)
+ else {
+ val getResult = typeOfMemberNamedGet(result)
+ def noGetError() = {
+ val name = "unapply" + (if (isSeq) "Seq" else "")
+ context.error(context.tree.pos, s"The result type of an $name method must contain a member `get` to be used as an extractor pattern, no such member exists in ${result}")
+ }
+ val expanded = getResult match {
+ case global.NoType => noGetError(); Nil
case rawGet if !hasSelectors(rawGet) => rawGet :: Nil
case rawGet => typesOfSelectors(rawGet)
}
- )
- expanded match {
- case init :+ last if isSeq => newExtractor(whole, init, repeatedFromSeq(last))
- case tps => newExtractor(whole, tps, NoRepeated)
+ expanded match {
+ case init :+ last if isSeq => newExtractor(whole, init, repeatedFromSeq(last), getResult)
+ case tps => newExtractor(whole, tps, NoRepeated, getResult)
+ }
}
}
}
object alignPatterns extends ScalacPatternExpander {
- /** Converts a T => (A, B, C) extractor to a T => ((A, B, CC)) extractor.
- */
- def tupleExtractor(extractor: Extractor): Extractor =
- extractor.copy(fixed = tupleType(extractor.fixed) :: Nil)
-
private def validateAligned(context: Context, tree: Tree, aligned: Aligned): Aligned = {
import aligned._
@@ -129,8 +131,8 @@ trait ScalacPatternExpanders {
val isUnapply = sel.symbol.name == nme.unapply
val extractor = sel.symbol.name match {
- case nme.unapply => unapplyMethodTypes(firstParamType(fn.tpe), sel.tpe, isSeq = false)
- case nme.unapplySeq => unapplyMethodTypes(firstParamType(fn.tpe), sel.tpe, isSeq = true)
+ case nme.unapply => unapplyMethodTypes(context, firstParamType(fn.tpe), sel.tpe, isSeq = false)
+ case nme.unapplySeq => unapplyMethodTypes(context, firstParamType(fn.tpe), sel.tpe, isSeq = true)
case _ => applyMethodTypes(fn.tpe)
}
@@ -142,12 +144,14 @@ trait ScalacPatternExpanders {
def acceptMessage = if (extractor.isErroneous) "" else s" to hold ${extractor.offeringString}"
val requiresTupling = isUnapply && patterns.totalArity == 1 && productArity > 1
- if (requiresTupling && effectivePatternArity(args) == 1) {
- val sym = sel.symbol.owner
- currentRun.reporting.deprecationWarning(sel.pos, sym, s"${sym} expects $productArity patterns$acceptMessage but crushing into $productArity-tuple to fit single pattern (SI-6675)")
- }
-
- val normalizedExtractor = if (requiresTupling) tupleExtractor(extractor) else extractor
+ val normalizedExtractor = if (requiresTupling) {
+ val tupled = extractor.asSinglePattern
+ if (effectivePatternArity(args) == 1 && isTupleType(extractor.typeOfSinglePattern)) {
+ val sym = sel.symbol.owner
+ currentRun.reporting.deprecationWarning(sel.pos, sym, s"${sym} expects $productArity patterns$acceptMessage but crushing into $productArity-tuple to fit single pattern (SI-6675)")
+ }
+ tupled
+ } else extractor
validateAligned(context, fn, Aligned(patterns, normalizedExtractor))
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index c46bc7444a..e73a4c6276 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -823,7 +823,12 @@ trait Contexts { self: Analyzer =>
case List() =>
List()
case List(ImportSelector(nme.WILDCARD, _, _, _)) =>
- collectImplicits(pre.implicitMembers, pre, imported = true)
+ // Using pre.implicitMembers seems to exposes a problem with out-dated symbols in the IDE,
+ // see the example in https://www.assembla.com/spaces/scala-ide/tickets/1002552#/activity/ticket
+ // I haven't been able to boil that down the an automated test yet.
+ // Looking up implicit members in the package, rather than package object, here is at least
+ // consistent with what is done just below for named imports.
+ collectImplicits(qual.tpe.implicitMembers, pre, imported = true)
case ImportSelector(from, _, to, _) :: sels1 =>
var impls = collect(sels1) filter (info => info.name != from)
if (to != nme.WILDCARD) {
diff --git a/src/eclipse/interactive/.gitignore b/src/eclipse/interactive/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/interactive/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/partest/.gitignore b/src/eclipse/partest/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/partest/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/reflect/.gitignore b/src/eclipse/reflect/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/reflect/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/repl/.gitignore b/src/eclipse/repl/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/repl/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scala-compiler/.gitignore b/src/eclipse/scala-compiler/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scala-compiler/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scala-library/.gitignore b/src/eclipse/scala-library/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scala-library/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scaladoc/.classpath b/src/eclipse/scaladoc/.classpath
index c8f0e89b8a..3db64f5b0d 100644
--- a/src/eclipse/scaladoc/.classpath
+++ b/src/eclipse/scaladoc/.classpath
@@ -6,8 +6,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
<classpathentry combineaccessrules="false" kind="src" path="/partest-extras"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.11.0-M7/1.0.0-RC7/scala-xml_2.11.0-M7-1.0.0-RC7.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-parser-combinators_2.11.0-M7/1.0.0-RC5/scala-parser-combinators_2.11.0-M7-1.0.0-RC5.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11.0-M7/1.0.0-RC8/scala-partest_2.11.0-M7-1.0.0-RC8.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.11/1.0.4/scala-xml_2.11-1.0.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.4/scala-parser-combinators_2.11-1.0.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11/1.0.9/scala-partest_2.11-1.0.9.jar"/>
<classpathentry kind="output" path="build-quick-scaladoc"/>
</classpath>
diff --git a/src/eclipse/scaladoc/.gitignore b/src/eclipse/scaladoc/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scaladoc/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scalap/.gitignore b/src/eclipse/scalap/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scalap/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/test-junit/.gitignore b/src/eclipse/test-junit/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/test-junit/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index f77462ce88..a45ec965f5 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -393,20 +393,35 @@ trait GenTraversableOnce[+A] extends Any {
*/
def minBy[B](f: A => B)(implicit cmp: Ordering[B]): A
- def forall(pred: A => Boolean): Boolean
+ /** Tests whether a predicate holds for all elements of this $coll.
+ *
+ * $mayNotTerminateInf
+ *
+ * @param p the predicate used to test elements.
+ * @return `true` if this $coll is empty or the given predicate `p`
+ * holds for all elements of this $coll, otherwise `false`.
+ */
+ def forall(@deprecatedName('pred) p: A => Boolean): Boolean
- def exists(pred: A => Boolean): Boolean
+ /** Tests whether a predicate holds for at least one element of this $coll.
+ *
+ * $mayNotTerminateInf
+ *
+ * @param p the predicate used to test elements.
+ * @return `true` if the given predicate `p` is satisfied by at least one element of this $coll, otherwise `false`
+ */
+ def exists(@deprecatedName('pred) p: A => Boolean): Boolean
/** Finds the first element of the $coll satisfying a predicate, if any.
*
* $mayNotTerminateInf
* $orderDependent
*
- * @param pred the predicate used to test elements.
+ * @param p the predicate used to test elements.
* @return an option value containing the first element in the $coll
* that satisfies `p`, or `None` if none exists.
*/
- def find(pred: A => Boolean): Option[A]
+ def find(@deprecatedName('pred) p: A => Boolean): Option[A]
/** Copies values of this $coll to an array.
* Fills the given array `xs` with values of this $coll.
diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala
index 9c336e8e31..b426061537 100644
--- a/src/library/scala/collection/LinearSeqOptimized.scala
+++ b/src/library/scala/collection/LinearSeqOptimized.scala
@@ -117,20 +117,20 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
}
override /*TraversableLike*/
- def foldLeft[B](z: B)(f: (B, A) => B): B = {
+ def foldLeft[B](z: B)(@deprecatedName('f) op: (B, A) => B): B = {
var acc = z
var these = this
while (!these.isEmpty) {
- acc = f(acc, these.head)
+ acc = op(acc, these.head)
these = these.tail
}
acc
}
override /*IterableLike*/
- def foldRight[B](z: B)(f: (A, B) => B): B =
+ def foldRight[B](z: B)(@deprecatedName('f) op: (A, B) => B): B =
if (this.isEmpty) z
- else f(head, tail.foldRight(z)(f))
+ else op(head, tail.foldRight(z)(op))
override /*TraversableLike*/
def reduceLeft[B >: A](f: (B, A) => B): B =
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index 96374ef653..04ae8c8aff 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -357,7 +357,7 @@ trait TraversableLike[+A, +Repr] extends Any
result
}
- /** Tests whether a predicate holds for some of the elements of this $coll.
+ /** Tests whether a predicate holds for at least one element of this $coll.
*
* $mayNotTerminateInf
*
diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala
index 7e8cfcc902..afb4c9c552 100644
--- a/src/library/scala/collection/immutable/RedBlackTree.scala
+++ b/src/library/scala/collection/immutable/RedBlackTree.scala
@@ -409,11 +409,11 @@ object RedBlackTree {
def cons[B](x: B, xs: NList[B]): NList[B] = new NList(x, xs)
- def foldLeft[A, B](xs: NList[A], z: B)(f: (B, A) => B): B = {
+ def foldLeft[A, B](xs: NList[A], z: B)(op: (B, A) => B): B = {
var acc = z
var these = xs
while (these ne null) {
- acc = f(acc, these.head)
+ acc = op(acc, these.head)
these = these.tail
}
acc
diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala
index a115469b83..031e5248c1 100644
--- a/src/library/scala/collection/immutable/Set.scala
+++ b/src/library/scala/collection/immutable/Set.scala
@@ -33,7 +33,7 @@ trait Set[A] extends Iterable[A]
with Parallelizable[A, ParSet[A]]
{
override def companion: GenericCompanion[Set] = Set
-
+
/** Returns this $coll as an immutable set, perhaps accepting a
* wider range of elements. Since it already is an
@@ -63,7 +63,7 @@ trait Set[A] extends Iterable[A]
object Set extends ImmutableSetFactory[Set] {
/** $setCanBuildFromInfo */
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Set[A]] = setCanBuildFrom[A]
-
+
/** An optimized representation for immutable empty sets */
private object EmptySet extends AbstractSet[Any] with Set[Any] with Serializable {
override def size: Int = 0
@@ -71,7 +71,7 @@ object Set extends ImmutableSetFactory[Set] {
def + (elem: Any): Set[Any] = new Set1(elem)
def - (elem: Any): Set[Any] = this
def iterator: Iterator[Any] = Iterator.empty
- override def foreach[U](f: Any => U): Unit = {}
+ override def foreach[U](f: Any => U): Unit = ()
override def toSet[B >: Any]: Set[B] = this.asInstanceOf[Set[B]]
}
private[collection] def emptyInstance: Set[Any] = EmptySet
@@ -90,17 +90,17 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
else None
}
// Why is Set1 non-final? Need to fix that!
@@ -124,18 +124,18 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
else None
}
// Why is Set2 non-final? Need to fix that!
@@ -159,19 +159,19 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2, elem3)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2); f(elem3)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2) || f(elem3)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2) || p(elem3)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2) && f(elem3)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2) && p(elem3)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
- else if (f(elem3)) Some(elem3)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
+ else if (p(elem3)) Some(elem3)
else None
}
// Why is Set3 non-final? Need to fix that!
@@ -196,20 +196,20 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2, elem3, elem4)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2); f(elem3); f(elem4)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2) || f(elem3) || f(elem4)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2) || p(elem3) || p(elem4)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2) && f(elem3) && f(elem4)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2) && p(elem3) && p(elem4)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
- else if (f(elem3)) Some(elem3)
- else if (f(elem4)) Some(elem4)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
+ else if (p(elem3)) Some(elem3)
+ else if (p(elem4)) Some(elem4)
else None
}
// Why is Set4 non-final? Need to fix that!
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 016255dca4..e7b022b895 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -520,22 +520,22 @@ self: ParIterableLike[T, Repr, Sequential] =>
*
* $abortsignalling
*
- * @param pred a predicate used to test elements
+ * @param p a predicate used to test elements
* @return true if `p` holds for all elements, false otherwise
*/
- def forall(pred: T => Boolean): Boolean = {
- tasksupport.executeAndWaitResult(new Forall(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def forall(@deprecatedName('pred) p: T => Boolean): Boolean = {
+ tasksupport.executeAndWaitResult(new Forall(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Tests whether a predicate holds for some element of this $coll.
*
* $abortsignalling
*
- * @param pred a predicate used to test elements
+ * @param p a predicate used to test elements
* @return true if `p` holds for some element, false otherwise
*/
- def exists(pred: T => Boolean): Boolean = {
- tasksupport.executeAndWaitResult(new Exists(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def exists(@deprecatedName('pred) p: T => Boolean): Boolean = {
+ tasksupport.executeAndWaitResult(new Exists(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Finds some element in the collection for which the predicate holds, if such
@@ -546,11 +546,11 @@ self: ParIterableLike[T, Repr, Sequential] =>
*
* $abortsignalling
*
- * @param pred predicate used to test the elements
+ * @param p predicate used to test the elements
* @return an option value with the element if such an element exists, or `None` otherwise
*/
- def find(pred: T => Boolean): Option[T] = {
- tasksupport.executeAndWaitResult(new Find(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def find(@deprecatedName('pred) p: T => Boolean): Option[T] = {
+ tasksupport.executeAndWaitResult(new Find(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Creates a combiner factory. Each combiner factory instance is used
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index 914646320c..294ca2aa48 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -497,7 +497,7 @@ object Future {
def sequence[A, M[X] <: TraversableOnce[X]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]] = {
in.foldLeft(successful(cbf(in))) {
(fr, fa) => for (r <- fr; a <- fa) yield (r += a)
- } map (_.result())
+ }.map(_.result())(InternalCallbackExecutor)
}
/** Returns a new `Future` to the result of the first future in the list that is completed.
diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala
index 512c4fbc27..4109f5cb4b 100644
--- a/src/library/scala/runtime/Tuple2Zipped.scala
+++ b/src/library/scala/runtime/Tuple2Zipped.scala
@@ -84,12 +84,12 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
(b1.result(), b2.result())
}
- def exists(f: (El1, El2) => Boolean): Boolean = {
+ def exists(@deprecatedName('f) p: (El1, El2) => Boolean): Boolean = {
val elems2 = colls._2.iterator
for (el1 <- colls._1) {
if (elems2.hasNext) {
- if (f(el1, elems2.next()))
+ if (p(el1, elems2.next()))
return true
}
else return false
@@ -97,8 +97,8 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
false
}
- def forall(f: (El1, El2) => Boolean): Boolean =
- !exists((x, y) => !f(x, y))
+ def forall(@deprecatedName('f) p: (El1, El2) => Boolean): Boolean =
+ !exists((x, y) => !p(x, y))
def foreach[U](f: (El1, El2) => U): Unit = {
val elems2 = colls._2.iterator
diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala
index ffd44acf81..cde7699d40 100644
--- a/src/library/scala/runtime/Tuple3Zipped.scala
+++ b/src/library/scala/runtime/Tuple3Zipped.scala
@@ -90,13 +90,13 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
result
}
- def exists(f: (El1, El2, El3) => Boolean): Boolean = {
+ def exists(@deprecatedName('f) p: (El1, El2, El3) => Boolean): Boolean = {
val elems2 = colls._2.iterator
val elems3 = colls._3.iterator
for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext) {
- if (f(el1, elems2.next(), elems3.next()))
+ if (p(el1, elems2.next(), elems3.next()))
return true
}
else return false
@@ -104,8 +104,8 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
false
}
- def forall(f: (El1, El2, El3) => Boolean): Boolean =
- !exists((x, y, z) => !f(x, y, z))
+ def forall(@deprecatedName('f) p: (El1, El2, El3) => Boolean): Boolean =
+ !exists((x, y, z) => !p(x, y, z))
def foreach[U](f: (El1, El2, El3) => U): Unit = {
val elems2 = colls._2.iterator
diff --git a/src/library/scala/sys/process/Process.scala b/src/library/scala/sys/process/Process.scala
index c40838bb06..06b9967908 100644
--- a/src/library/scala/sys/process/Process.scala
+++ b/src/library/scala/sys/process/Process.scala
@@ -68,7 +68,7 @@ trait ProcessCreation {
/** Creates a [[scala.sys.process.ProcessBuilder]] with working dir set to `File` and extra
* environment variables.
*
- * @example {{{ apply("java", new java.ioFile("/opt/app"), "CLASSPATH" -> "library.jar") }}}
+ * @example {{{ apply("java", new java.io.File("/opt/app"), "CLASSPATH" -> "library.jar") }}}
*/
def apply(command: String, cwd: File, extraEnv: (String, String)*): ProcessBuilder =
apply(command, Some(cwd), extraEnv: _*)
@@ -76,7 +76,7 @@ trait ProcessCreation {
/** Creates a [[scala.sys.process.ProcessBuilder]] with working dir set to `File` and extra
* environment variables.
*
- * @example {{{ apply("java" :: javaArgs, new java.ioFile("/opt/app"), "CLASSPATH" -> "library.jar") }}}
+ * @example {{{ apply("java" :: javaArgs, new java.io.File("/opt/app"), "CLASSPATH" -> "library.jar") }}}
*/
def apply(command: Seq[String], cwd: File, extraEnv: (String, String)*): ProcessBuilder =
apply(command, Some(cwd), extraEnv: _*)
diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala
index e196d403c2..32b7ec4487 100644
--- a/src/library/scala/util/Either.scala
+++ b/src/library/scala/util/Either.scala
@@ -329,8 +329,8 @@ object Either {
* }}}
*
*/
- def forall(f: A => Boolean) = e match {
- case Left(a) => f(a)
+ def forall(@deprecatedName('f) p: A => Boolean) = e match {
+ case Left(a) => p(a)
case Right(_) => true
}
@@ -345,8 +345,8 @@ object Either {
* }}}
*
*/
- def exists(f: A => Boolean) = e match {
- case Left(a) => f(a)
+ def exists(@deprecatedName('f) p: A => Boolean) = e match {
+ case Left(a) => p(a)
case Right(_) => false
}
@@ -507,9 +507,9 @@ object Either {
* Left(12).right.exists(_ > 10) // false
* }}}
*/
- def exists(f: B => Boolean) = e match {
+ def exists(@deprecatedName('f) p: B => Boolean) = e match {
case Left(_) => false
- case Right(b) => f(b)
+ case Right(b) => p(b)
}
/**
diff --git a/src/partest-extras/scala/tools/partest/IcodeComparison.scala b/src/partest-extras/scala/tools/partest/IcodeComparison.scala
index 7122703918..1430db886e 100644
--- a/src/partest-extras/scala/tools/partest/IcodeComparison.scala
+++ b/src/partest-extras/scala/tools/partest/IcodeComparison.scala
@@ -48,8 +48,13 @@ abstract class IcodeComparison extends DirectTest {
compile("-d" :: testOutput.path :: arg0 :: args.toList : _*)
val icodeFiles = testOutput.files.toList filter (_ hasExtension "icode")
- try icodeFiles sortBy (_.name) flatMap (f => f.lines.toList)
- finally icodeFiles foreach (f => f.delete())
+ // Some methods in scala.reflect.io.File leak an InputStream, leaving the underlying file open.
+ // Windows won't delete an open file, but we must ensure the files get deleted, since the logic
+ // here depends on it (collectIcode will be called multiple times, and we can't allow crosstalk
+ // between calls). So we are careful to use `slurp` which does call `close`, and careful to
+ // check that `delete` returns true indicating successful deletion.
+ try icodeFiles sortBy (_.name) flatMap (f => f.slurp().lines.toList)
+ finally icodeFiles foreach (f => require(f.delete()))
}
/** Collect icode at the default phase, `printIcodeAfterPhase`. */
diff --git a/src/reflect/scala/reflect/io/Streamable.scala b/src/reflect/scala/reflect/io/Streamable.scala
index aa47947672..99a14d1fb0 100644
--- a/src/reflect/scala/reflect/io/Streamable.scala
+++ b/src/reflect/scala/reflect/io/Streamable.scala
@@ -27,6 +27,10 @@ object Streamable {
* efficient method implementations.
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
+ *
+ * Note that this code was not written with resource management in mind.
+ * Several methods (such as `chars` and `lines`) create InputStreams they
+ * don't close
*/
trait Bytes {
def inputStream(): InputStream
@@ -82,9 +86,13 @@ object Streamable {
*/
def creationCodec: Codec = implicitly[Codec]
+ /** Caller is responsible for closing the returned BufferedSource. */
def chars(codec: Codec): BufferedSource = Source.fromInputStream(inputStream())(codec)
+ /** Beware! Leaks an InputStream which will not be closed until it gets finalized. */
def lines(): Iterator[String] = lines(creationCodec)
+
+ /** Beware! Leaks an InputStream which will not be closed until it gets finalized. */
def lines(codec: Codec): Iterator[String] = chars(codec).getLines()
/** Obtains an InputStreamReader wrapped around a FileInputStream.
diff --git a/test/files/neg/t4425b.check b/test/files/neg/t4425b.check
index 8418b4fd12..a204467586 100644
--- a/test/files/neg/t4425b.check
+++ b/test/files/neg/t4425b.check
@@ -22,16 +22,28 @@ t4425b.scala:10: error: object X is not a case class, nor does it have an unappl
Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list
println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" })
^
-t4425b.scala:18: error: too many patterns for object X: expected 1, found 2
+t4425b.scala:18: error: The result type of an unapply method must contain a member `get` to be used as an extractor pattern, no such member exists in Nothing
+ println( "" match { case _ X _ => "ok" ; case _ => "fail" })
+ ^
+t4425b.scala:18: error: too many patterns for object X offering Boolean: expected 0, found 2
println( "" match { case _ X _ => "ok" ; case _ => "fail" })
^
-t4425b.scala:19: error: too many patterns for object X: expected 1, found 2
+t4425b.scala:19: error: The result type of an unapply method must contain a member `get` to be used as an extractor pattern, no such member exists in Nothing
+ println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" })
+ ^
+t4425b.scala:19: error: too many patterns for object X offering Boolean: expected 0, found 2
println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" })
^
-t4425b.scala:22: error: too many patterns for object X: expected 1, found 2
+t4425b.scala:20: error: The result type of an unapply method must contain a member `get` to be used as an extractor pattern, no such member exists in Nothing
+ println( "" match { case X(_) => "ok" ; case _ => "fail" })
+ ^
+t4425b.scala:21: error: The result type of an unapply method must contain a member `get` to be used as an extractor pattern, no such member exists in Nothing
+ println((X: Any) match { case X(_) => "ok" ; case _ => "fail" })
+ ^
+t4425b.scala:22: error: The result type of an unapply method must contain a member `get` to be used as an extractor pattern, no such member exists in Nothing
println( "" match { case X(_, _) => "ok" ; case _ => "fail" })
^
-t4425b.scala:23: error: too many patterns for object X: expected 1, found 2
+t4425b.scala:23: error: The result type of an unapply method must contain a member `get` to be used as an extractor pattern, no such member exists in Nothing
println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" })
^
t4425b.scala:31: error: too many patterns for object X offering Nothing: expected 1, found 2
@@ -46,4 +58,4 @@ t4425b.scala:35: error: too many patterns for object X offering Nothing: expecte
t4425b.scala:36: error: too many patterns for object X offering Nothing: expected 1, found 2
println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" })
^
-14 errors found
+18 errors found
diff --git a/test/files/neg/t8127a.check b/test/files/neg/t8127a.check
new file mode 100644
index 0000000000..5a30574861
--- /dev/null
+++ b/test/files/neg/t8127a.check
@@ -0,0 +1,4 @@
+t8127a.scala:7: error: The result type of an unapplySeq method must contain a member `get` to be used as an extractor pattern, no such member exists in Seq[_$1]
+ case H(v) =>
+ ^
+one error found
diff --git a/test/files/neg/t8127a.scala b/test/files/neg/t8127a.scala
new file mode 100644
index 0000000000..c05facdac1
--- /dev/null
+++ b/test/files/neg/t8127a.scala
@@ -0,0 +1,12 @@
+object H {
+ def unapplySeq(m: Any): Seq[_] = List("")
+}
+
+object Test {
+ def unapply(m: Any) = m match {
+ case H(v) =>
+ case _ =>
+ }
+ // now: too many patterns for object H offering Boolean: expected 0, found 1
+ // was: result type Seq[_$2] of unapplySeq defined in method unapplySeq in object H does not conform to Option[_]
+}
diff --git a/test/files/neg/t8989.check b/test/files/neg/t8989.check
new file mode 100644
index 0000000000..4e89b862bd
--- /dev/null
+++ b/test/files/neg/t8989.check
@@ -0,0 +1,4 @@
+t8989.scala:11: error: The result type of an unapply method must contain a member `get` to be used as an extractor pattern, no such member exists in A
+ val f = p match {case d(1) => true; case _ => false}
+ ^
+one error found
diff --git a/test/files/neg/t8989.scala b/test/files/neg/t8989.scala
new file mode 100644
index 0000000000..8ed6a901cd
--- /dev/null
+++ b/test/files/neg/t8989.scala
@@ -0,0 +1,14 @@
+class A extends Product1[Int] {
+ def _1 = 1
+ def isEmpty = false // used by scalac
+ def isDefined = !isEmpty // used by dotty
+ def canEqual(a: Any) = true
+}
+
+object d{
+ def unapply(a: Any) = new A
+ val p: Any = ???
+ val f = p match {case d(1) => true; case _ => false}
+}
+
+
diff --git a/test/files/run/t7850c.scala b/test/files/run/t7850c.scala
new file mode 100644
index 0000000000..25b9c0028d
--- /dev/null
+++ b/test/files/run/t7850c.scala
@@ -0,0 +1,11 @@
+// Testing that isEmpty and get are viewed with `memberType` from `Casey1`.
+trait T[A, B >: Null] { def isEmpty: A = false.asInstanceOf[A]; def get: B = null}
+class Casey1() extends T[Boolean, String]
+object Casey1 { def unapply(a: Casey1) = a }
+
+object Test {
+ def main(args: Array[String]) {
+ val c @ Casey1(x) = new Casey1()
+ assert(x == c.get)
+ }
+}
diff --git a/test/files/run/t7850d.scala b/test/files/run/t7850d.scala
new file mode 100644
index 0000000000..ccc98f1bcc
--- /dev/null
+++ b/test/files/run/t7850d.scala
@@ -0,0 +1,17 @@
+// Testing that the ad-hoc overload resolution of isEmpty/get discards
+// parameter-accepting variants
+trait T[A, B >: Null] { def isEmpty: A = false.asInstanceOf[A]; def get: B = null}
+class Casey1(val a: Int) {
+ def isEmpty: Boolean = false
+ def isEmpty(x: Int): Boolean = ???
+ def get: Int = a
+ def get(x: Int): String = ???
+}
+object Casey1 { def unapply(a: Casey1) = a }
+
+object Test {
+ def main(args: Array[String]) {
+ val c @ Casey1(x) = new Casey1(0)
+ assert(x == c.get)
+ }
+}
diff --git a/test/files/run/t9029.flags b/test/files/run/t9029.flags
new file mode 100644
index 0000000000..dcc59ebe32
--- /dev/null
+++ b/test/files/run/t9029.flags
@@ -0,0 +1 @@
+-deprecation
diff --git a/test/files/run/t9029.scala b/test/files/run/t9029.scala
new file mode 100644
index 0000000000..c01033b76e
--- /dev/null
+++ b/test/files/run/t9029.scala
@@ -0,0 +1,15 @@
+class Y(val _2: Int, val _1: String)
+
+object X { def unapply(u: Unit): Option[Y] = Some(new Y(42, "!")) }
+
+object Test {
+ def test1 = {
+ val X(y) = ()
+ val yy: Y = y
+ assert(yy._1 == "!")
+ assert(yy._2 == 42)
+ }
+ def main(args: Array[String]): Unit = {
+ test1
+ }
+}
diff --git a/test/files/run/t9029b.check b/test/files/run/t9029b.check
new file mode 100644
index 0000000000..aeb2d5e239
--- /dev/null
+++ b/test/files/run/t9029b.check
@@ -0,0 +1 @@
+Some(1)
diff --git a/test/files/run/t9029b.scala b/test/files/run/t9029b.scala
new file mode 100644
index 0000000000..764d0771ec
--- /dev/null
+++ b/test/files/run/t9029b.scala
@@ -0,0 +1,31 @@
+class Foo(val x: Bar) {
+ def isEmpty = false
+ def get = x
+}
+
+object Foo {
+ def unapply(x: Foo) = x
+}
+
+class Bar(val x: Option[Int], val y: Option[Int]) {
+ def isEmpty = false
+ def get = this
+ def _1 = x
+ def _2 = y
+}
+
+object Bar {
+ def unapply(x: Bar) = x
+}
+
+object Test {
+ def nameBased: Unit = {
+ val x: AnyRef = new Foo(new Bar(Some(1), Some(2)))
+ x match {
+ case Foo(Bar(x1, x2)) => println(x1)
+ }
+ }
+ def main(args: Array[String]): Unit = {
+ nameBased
+ }
+}
diff --git a/test/files/run/t9029c.scala b/test/files/run/t9029c.scala
new file mode 100644
index 0000000000..ccb51e23ae
--- /dev/null
+++ b/test/files/run/t9029c.scala
@@ -0,0 +1,21 @@
+object Extractor {
+ def unapply(a: Any): Option[Product2[Int, String]] = Some(new P2(1, "2"))
+}
+class P2[A, B](val _1: A, val _2: B) extends Product2[A, B] {
+ def canEqual(other: Any) = true
+ def isP2 = true
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ "" match {
+ case Extractor(p) =>
+ val pp: Product2[Int, String] = p
+ }
+ "" match {
+ case Extractor(x, y) =>
+ val xx: Int = x
+ val yy: String = y
+ }
+ }
+}