summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeather Miller <heather.miller@epfl.ch>2012-05-16 20:56:07 +0200
committerHeather Miller <heather.miller@epfl.ch>2012-05-16 20:56:07 +0200
commit53db738aaf7a815c5cd09e57eb8c41a8b9ba1320 (patch)
treea16561573030c5cf5e7b68ccfc39249c504f77f8
parent4f693edd54a84d40481df64d7682f1a31bf84364 (diff)
parent9fe251e16b93d4bdc8a496f3edce90ef2e207ee8 (diff)
downloadscala-53db738aaf7a815c5cd09e57eb8c41a8b9ba1320.tar.gz
scala-53db738aaf7a815c5cd09e57eb8c41a8b9ba1320.tar.bz2
scala-53db738aaf7a815c5cd09e57eb8c41a8b9ba1320.zip
Merge branch 'master' of git://github.com/scala/scala into issue/5623
-rw-r--r--src/actors/scala/actors/package.scala2
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/page/Template.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala16
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala12
-rw-r--r--src/library/scala/Array.scala11
-rw-r--r--src/library/scala/Function.scala2
-rw-r--r--src/library/scala/Predef.scala4
-rw-r--r--src/library/scala/collection/IterableLike.scala6
-rw-r--r--src/library/scala/collection/Iterator.scala2
-rw-r--r--src/library/scala/collection/SeqLike.scala6
-rw-r--r--src/library/scala/collection/generic/CanBuildFrom.scala2
-rw-r--r--src/library/scala/collection/generic/GenericCompanion.scala2
-rw-r--r--src/library/scala/collection/mutable/MapLike.scala22
-rw-r--r--src/library/scala/collection/package.scala4
-rw-r--r--src/library/scala/sys/package.scala2
-rw-r--r--src/library/scala/util/MurmurHash3.scala2
-rw-r--r--src/library/scala/util/Try.scala4
-rw-r--r--src/library/scala/util/parsing/combinator/lexical/StdLexical.scala4
-rwxr-xr-xsrc/library/scala/xml/Node.scala2
-rw-r--r--test/files/pos/t5259.scala21
-rw-r--r--test/files/run/t5610.check6
-rw-r--r--test/files/run/t5610.scala30
22 files changed, 123 insertions, 41 deletions
diff --git a/src/actors/scala/actors/package.scala b/src/actors/scala/actors/package.scala
index d809816ff6..d176487e03 100644
--- a/src/actors/scala/actors/package.scala
+++ b/src/actors/scala/actors/package.scala
@@ -7,7 +7,7 @@ package scala
* == Guide ==
*
* A detailed guide for the actors library is available
- * [[http://www.scala-lang.org/docu/files/actors-api/actors_api_guide.html#]].
+ * [[http://docs.scala-lang.org/overviews/core/actors.html]].
*
* == Getting Started ==
*
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
index 4463857aa5..220321d225 100644
--- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
@@ -511,7 +511,7 @@ class Template(universe: doc.Universe, tpl: DocTemplateEntity) extends HtmlPage
<dt>See also</dt>
<dd>{
val seeXml:List[scala.xml.NodeSeq]=(for(see <- comment.see ) yield <span class="cmt">{bodyToHtml(see)}</span> )
- seeXml.reduceLeft(_ ++ Text(", ") ++ _)
+ seeXml.reduceLeft(_ ++ _)
}</dd>
} else NodeSeq.Empty
diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
index 92ce0e6de4..e1fb683aa9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
@@ -63,15 +63,18 @@ trait EtaExpansion { self: Analyzer =>
* @return ...
*/
def liftoutPrefix(tree: Tree): Tree = {
- def liftout(tree: Tree): Tree =
+ def liftout(tree: Tree, byName: Boolean): Tree =
if (treeInfo.isExprSafeToInline(tree)) tree
else {
val vname: Name = freshName()
// Problem with ticket #2351 here
defs += atPos(tree.pos) {
- ValDef(Modifiers(SYNTHETIC), vname.toTermName, TypeTree(), tree)
+ val rhs = if (byName) Function(List(), tree) else tree
+ ValDef(Modifiers(SYNTHETIC), vname.toTermName, TypeTree(), rhs)
+ }
+ atPos(tree.pos.focus) {
+ if (byName) Apply(Ident(vname), List()) else Ident(vname)
}
- Ident(vname) setPos tree.pos.focus
}
val tree1 = tree match {
// a partial application using named arguments has the following form:
@@ -85,11 +88,14 @@ trait EtaExpansion { self: Analyzer =>
defs ++= stats
liftoutPrefix(fun)
case Apply(fn, args) =>
- treeCopy.Apply(tree, liftoutPrefix(fn), args mapConserve (liftout)) setType null
+ val byName = fn.tpe.params.map(p => definitions.isByNameParamType(p.tpe))
+ // zipAll: with repeated params, there might be more args than params
+ val newArgs = args.zipAll(byName, EmptyTree, false) map { case (arg, byN) => liftout(arg, byN) }
+ treeCopy.Apply(tree, liftoutPrefix(fn), newArgs) setType null
case TypeApply(fn, args) =>
treeCopy.TypeApply(tree, liftoutPrefix(fn), args) setType null
case Select(qual, name) =>
- treeCopy.Select(tree, liftout(qual), name) setSymbol NoSymbol setType null
+ treeCopy.Select(tree, liftout(qual, false), name) setSymbol NoSymbol setType null
case Ident(name) =>
tree
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index bef6f13bc3..8ae254d35d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -158,20 +158,20 @@ trait NamesDefaults { self: Analyzer =>
// it stays in Vegas: SI-5720, SI-5727
qual changeOwner (blockTyper.context.owner -> sym)
+ val newQual = atPos(qual.pos.focus)(blockTyper.typedQualifier(Ident(sym.name)))
var baseFunTransformed = atPos(baseFun.pos.makeTransparent) {
- // don't use treeCopy: it would assign opaque position.
- val f = Select(gen.mkAttributedRef(sym), selected)
- .setType(baseFun1.tpe).setSymbol(baseFun1.symbol)
+ // setSymbol below is important because the 'selected' function might be overloaded. by
+ // assigning the correct method symbol, typedSelect will just assign the type. the reason
+ // to still call 'typed' is to correctly infer singleton types, SI-5259.
+ val f = blockTyper.typedOperator(Select(newQual, selected).setSymbol(baseFun1.symbol))
if (funTargs.isEmpty) f
else TypeApply(f, funTargs).setType(baseFun.tpe)
}
val b = Block(List(vd), baseFunTransformed)
.setType(baseFunTransformed.tpe).setPos(baseFun.pos)
-
- val defaultQual = Some(atPos(qual.pos.focus)(gen.mkAttributedRef(sym)))
context.namedApplyBlockInfo =
- Some((b, NamedApplyInfo(defaultQual, defaultTargs, Nil, blockTyper)))
+ Some((b, NamedApplyInfo(Some(newQual), defaultTargs, Nil, blockTyper)))
b
}
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala
index cf72973b7c..e7cf399fa4 100644
--- a/src/library/scala/Array.scala
+++ b/src/library/scala/Array.scala
@@ -438,10 +438,8 @@ object Array extends FallbackArrayBuilding {
* Arrays make use of two common pieces of Scala syntactic sugar, shown on lines 2 and 3 of the above
* example code.
* Line 2 is translated into a call to `apply(Int)`, while line 3 is translated into a call to
- * `update(Int, T)`. For more information on these transformations, see the
- * [[http://www.scala-lang.org/docu/files/ScalaReference.pdf Scala Language Specification v2.8]], Sections
- * 6.6 and 6.15 respectively.
- *
+ * `update(Int, T)`.
+ *
* Two implicit conversions exist in [[scala.Predef]] that are frequently applied to arrays: a conversion
* to [[scala.collection.mutable.ArrayOps]] (shown on line 4 of the example above) and a conversion
* to [[scala.collection.mutable.WrappedArray]] (a subtype of [[scala.collections.Seq]]).
@@ -465,8 +463,9 @@ object Array extends FallbackArrayBuilding {
*
* @author Martin Odersky
* @version 1.0
- * @see [[http://www.scala-lang.org/docu/files/collections-api/collections_38.html#anchor "The Scala 2.8 Collections' API"]]
- * section on `Array` by Martin Odersky for more information.
+ * @see [[http://www.scala-lang.org/docu/files/ScalaReference.pdf Scala Language Specification]], for in-depth information on the transformations the Scala compiler makes on Arrays (Sections 6.6 and 6.15 respectively.)
+ * @see [[http://docs.scala-lang.org/sips/completed/scala-2-8-arrays.html "Scala 2.8 Arrays"]] the Scala Improvement Document detailing arrays since Scala 2.8.
+ * @see [[http://docs.scala-lang.org/overviews/collections/arrays.html "The Scala 2.8 Collections' API"]] section on `Array` by Martin Odersky for more information.
* @define coll array
* @define Coll `Array`
* @define orderDependent
diff --git a/src/library/scala/Function.scala b/src/library/scala/Function.scala
index 9ad2bc49ea..270581a3aa 100644
--- a/src/library/scala/Function.scala
+++ b/src/library/scala/Function.scala
@@ -37,7 +37,7 @@ object Function {
* @param f a function `T => Option[R]`
* @return a partial function defined for those inputs where
* f returns `Some(_)` and undefined where `f` returns `None`.
- * @see [[scala.PartialFunction#lift]]
+ * @see [[scala.PartialFunction]], method `lift`.
*/
def unlift[T, R](f: T => Option[R]): PartialFunction[T, R] = PartialFunction.unlifted(f)
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 30ad703c4a..c08462ac1b 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -451,14 +451,14 @@ object Predef extends LowPriorityImplicits {
}
/** A type for which there is always an implicit value.
- * @see fallbackCanBuildFrom in Array.scala
+ * @see [[scala.Array$]], method `fallbackCanBuildFrom`
*/
class DummyImplicit
object DummyImplicit {
/** An implicit value yielding a `DummyImplicit`.
- * @see fallbackCanBuildFrom in Array.scala
+ * @see [[scala.Array$]], method `fallbackCanBuildFrom`
*/
implicit def dummyImplicit: DummyImplicit = new DummyImplicit
}
diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala
index 0a5d9fc23c..2e9599058f 100644
--- a/src/library/scala/collection/IterableLike.scala
+++ b/src/library/scala/collection/IterableLike.scala
@@ -148,7 +148,7 @@ self =>
}
/** Partitions elements in fixed size ${coll}s.
- * @see Iterator#grouped
+ * @see [[scala.collection.Iterator]], method `grouped`
*
* @param size the number of elements per group
* @return An iterator producing ${coll}s of size `size`, except the
@@ -163,7 +163,7 @@ self =>
/** Groups elements in fixed size blocks by passing a "sliding window"
* over them (as opposed to partitioning them, as is done in grouped.)
- * @see Iterator#sliding
+ * @see [[scala.collection.Iterator]], method `sliding`
*
* @param size the number of elements per group
* @return An iterator producing ${coll}s of size `size`, except the
@@ -174,7 +174,7 @@ self =>
/** Groups elements in fixed size blocks by passing a "sliding window"
* over them (as opposed to partitioning them, as is done in grouped.)
- * @see Iterator#sliding
+ * @see [[scala.collection.Iterator]], method `sliding`
*
* @param size the number of elements per group
* @param step the distance between the first elements of successive
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index 7d5cd9989c..b2bbc8d888 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -824,7 +824,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
/** Creates a buffered iterator from this iterator.
*
- * @see BufferedIterator
+ * @see [[scala.collection.BufferedIterator]]
* @return a buffered iterator producing the same values as this iterator.
* @note Reuse: $consumesAndProducesIterator
*/
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index f64e1d780c..c87726ef2c 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -566,7 +566,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
/** Sorts this $Coll according to the Ordering which results from transforming
* an implicitly given Ordering with a transformation function.
- * @see scala.math.Ordering
+ * @see [[scala.math.Ordering]]
* $willNotTerminateInf
* @param f the transformation function mapping elements
* to some other domain `B`.
@@ -591,7 +591,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
* The sort is stable. That is, elements that are equal (as determined by
* `lt`) appear in the same order in the sorted sequence as in the original.
*
- * @see scala.math.Ordering
+ * @see [[scala.math.Ordering]]
*
* @param ord the ordering to be used to compare elements.
* @return a $coll consisting of the elements of this $coll
@@ -852,7 +852,7 @@ object SeqLike {
/** Finds a particular index at which one sequence occurs in another sequence.
* Like `indexOf`, but finds the latest occurrence rather than earliest.
*
- * @see SeqLike#indexOf
+ * @see [[scala.collection.SeqLike], method `indexOf`
*/
def lastIndexOf[B](
source: Seq[B], sourceOffset: Int, sourceCount: Int,
diff --git a/src/library/scala/collection/generic/CanBuildFrom.scala b/src/library/scala/collection/generic/CanBuildFrom.scala
index 3a335f357a..f3eff03d89 100644
--- a/src/library/scala/collection/generic/CanBuildFrom.scala
+++ b/src/library/scala/collection/generic/CanBuildFrom.scala
@@ -20,7 +20,7 @@ import scala.annotation.implicitNotFound
* @tparam Elem the element type of the collection to be created.
* @tparam To the type of the collection to be created.
*
- * @see Builder
+ * @see [[scala.collection.mutable.Builder]]
* @author Martin Odersky
* @author Adriaan Moors
* @since 2.8
diff --git a/src/library/scala/collection/generic/GenericCompanion.scala b/src/library/scala/collection/generic/GenericCompanion.scala
index badceac713..1844542315 100644
--- a/src/library/scala/collection/generic/GenericCompanion.scala
+++ b/src/library/scala/collection/generic/GenericCompanion.scala
@@ -16,7 +16,7 @@ import language.higherKinds
* represent an unconstrained higher-kinded type. Typically
* such classes inherit from trait `GenericTraversableTemplate`.
* @tparam CC The type constructor representing the collection class.
- * @see GenericTraversableTemplate
+ * @see [[scala.collection.generic.GenericTraversableTemplate]]
* @author Martin Odersky
* @since 2.8
* @define coll collection
diff --git a/src/library/scala/collection/mutable/MapLike.scala b/src/library/scala/collection/mutable/MapLike.scala
index b8b1152099..3046207533 100644
--- a/src/library/scala/collection/mutable/MapLike.scala
+++ b/src/library/scala/collection/mutable/MapLike.scala
@@ -18,6 +18,28 @@ import parallel.mutable.ParMap
* $mapNote
* $mapTags
* @since 2.8
+ *
+ * @define mapNote
+ * '''Implementation note:'''
+ * This trait provides most of the operations of a mutable `Map`
+ * independently of its representation. It is typically inherited by
+ * concrete implementations of maps.
+ *
+ * To implement a concrete mutable map, you need to provide
+ * implementations of the following methods:
+ * {{{
+ * def get(key: A): Option[B]
+ * def iterator: Iterator[(A, B)]
+ * def += (kv: (A, B)): This
+ * def -= (key: A): This
+ * }}}
+ * If you wish that methods like `take`, `drop`, `filter` also return the same kind of map
+ * you should also override:
+ * {{{
+ * def empty: This
+ * }}}
+ * It is also good idea to override methods `foreach` and
+ * `size` for efficiency.
*/
trait MapLike[A, B, +This <: MapLike[A, B, This] with Map[A, B]]
extends scala.collection.MapLike[A, B, This]
diff --git a/src/library/scala/collection/package.scala b/src/library/scala/collection/package.scala
index 0dd4405cf7..237ca28018 100644
--- a/src/library/scala/collection/package.scala
+++ b/src/library/scala/collection/package.scala
@@ -14,7 +14,7 @@ package scala
* == Guide ==
*
* A detailed guide for the collections library is available
- * at [[http://www.scala-lang.org/docu/files/collections-api]].
+ * at [[http://docs.scala-lang.org/overviews/collections/introduction.html]].
*
* == Using Collections ==
*
@@ -67,7 +67,7 @@ package scala
* Also note that the collections library was carefully designed to include several implementations of
* each of the three basic collection types. These implementations have specific performance
* characteristics which are described
- * in [[http://www.scala-lang.org/docu/files/collections-api the guide]].
+ * in [[http://docs.scala-lang.org/overviews/collections/performance-characteristics.html the guide]].
*
* === Converting between Java Collections ===
*
diff --git a/src/library/scala/sys/package.scala b/src/library/scala/sys/package.scala
index b27da8e61d..119ab59c22 100644
--- a/src/library/scala/sys/package.scala
+++ b/src/library/scala/sys/package.scala
@@ -50,7 +50,7 @@ package object sys {
/** A bidirectional, mutable Map representing the current system Properties.
*
* @return a SystemProperties.
- * @see `scala.sys.SystemProperties`
+ * @see [[scala.sys.SystemProperties]]
*/
def props: SystemProperties = new SystemProperties
diff --git a/src/library/scala/util/MurmurHash3.scala b/src/library/scala/util/MurmurHash3.scala
index 33d9d2f0e5..fbb67116dd 100644
--- a/src/library/scala/util/MurmurHash3.scala
+++ b/src/library/scala/util/MurmurHash3.scala
@@ -19,7 +19,7 @@ import java.lang.Integer.{ rotateLeft => rotl }
* to remedy some weaknesses and improve performance. This represents the
* latest and supposedly final version of the algortihm (revision 136).
*
- * @see http://code.google.com/p/smhasher
+ * @see [[http://code.google.com/p/smhasher]]
*/
class MurmurHash3 {
/** Mix in a block of data into an intermediate hash value. */
diff --git a/src/library/scala/util/Try.scala b/src/library/scala/util/Try.scala
index efa2fcabb8..8faba236f0 100644
--- a/src/library/scala/util/Try.scala
+++ b/src/library/scala/util/Try.scala
@@ -92,8 +92,8 @@ sealed abstract class Try[+T] {
def andThen[U](f: T => Try[U]): Try[U] = flatMap(f)
/**
- * Transforms a nested `Try`, i.e., a `Try` of type `Try[Try[T]]`,
- * into an un-nested `Try`, i.e., a `Try` of type `Try[T]`.
+ * Transforms a nested `Try`, ie, a `Try` of type `Try[Try[T]]`,
+ * into an un-nested `Try`, ie, a `Try` of type `Try[T]`.
*/
def flatten[U](implicit ev: T <:< Try[U]): Try[U]
diff --git a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
index 3ac5c07dc4..5d7386b5c1 100644
--- a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
+++ b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
@@ -25,8 +25,8 @@ import scala.collection.mutable
* `delimiters` set.
*
* Usually this component is used to break character-based input into
- * bigger tokens, which are then passed to a token-parser {@see
- * [[scala.util.parsing.combinator.syntactical.TokenParsers]]}.
+ * bigger tokens, which are then passed to a token-parser (see
+ * [[scala.util.parsing.combinator.syntactical.TokenParsers]].)
*
* @author Martin Odersky
* @author Iulian Dragos
diff --git a/src/library/scala/xml/Node.scala b/src/library/scala/xml/Node.scala
index 7fca644730..9cf1869efc 100755
--- a/src/library/scala/xml/Node.scala
+++ b/src/library/scala/xml/Node.scala
@@ -162,8 +162,6 @@ abstract class Node extends NodeSeq {
/**
* Same as `toString('''false''')`.
- *
- * @see <code><a href="#toString">toString(Boolean)</a></code>
*/
override def toString(): String = buildString(false)
diff --git a/test/files/pos/t5259.scala b/test/files/pos/t5259.scala
new file mode 100644
index 0000000000..d33c4dd6a7
--- /dev/null
+++ b/test/files/pos/t5259.scala
@@ -0,0 +1,21 @@
+class A[T]
+class B {
+ def m(a: A[this.type] = new A[this.type]) { }
+}
+
+class C {
+ def foo(a: Int, b: Int = 0) = 0
+ def foo() = 0
+}
+
+object Test {
+ def newB = new B
+ newB.m()
+
+ val stableB = new B
+ stableB.m()
+
+ def f {
+ println((new C).foo(0))
+ }
+}
diff --git a/test/files/run/t5610.check b/test/files/run/t5610.check
new file mode 100644
index 0000000000..023f18d8f1
--- /dev/null
+++ b/test/files/run/t5610.check
@@ -0,0 +1,6 @@
+some string
+some string
+some string
+some string
+List(2, 3)
+List(5, 6)
diff --git a/test/files/run/t5610.scala b/test/files/run/t5610.scala
new file mode 100644
index 0000000000..f62b2df6b4
--- /dev/null
+++ b/test/files/run/t5610.scala
@@ -0,0 +1,30 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ var test: String = null
+ val fun1: Int => () => Unit = foo(test) _
+ val fun2: Int => () => Unit = foo(test)(_)
+ val fun3: Int => () => Unit = {
+ lazy val eta1: String = test
+ (dummy: Int) => foo(eta1)(dummy)
+ }
+ val fun4: Int => () => Unit = {
+ val eta1: () => String = () => test
+ (dummy: Int) => foo(eta1())(dummy)
+ }
+ test = "some string"
+ fun1(1)()
+ fun2(1)()
+ fun3(1)()
+ fun4(1)()
+
+ val f: (String, Int*) => Unit = m(2, 3)
+ f("", 5, 6)
+ }
+
+ def foo(s: => String)(dummy: Int) = () => println(s)
+
+ def m(a: Int*)(z: String, b: Int*) {
+ println(a.toList)
+ println(b.toList)
+ }
+}