summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2009-12-18 15:22:51 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2009-12-18 15:22:51 +0000
commit2ab456d13df1ac50539e4620f62f6e234f3c8446 (patch)
tree865acb3c7eb91100b232aa73214687f53e6dd1c9
parenta861322f83c23ef1801a0dcb963020b20f8a1b37 (diff)
downloadscala-2ab456d13df1ac50539e4620f62f6e234f3c8446.tar.gz
scala-2ab456d13df1ac50539e4620f62f6e234f3c8446.tar.bz2
scala-2ab456d13df1ac50539e4620f62f6e234f3c8446.zip
Merged revisions 20229-20233 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r20229 | odersky | 2009-12-18 16:16:51 +0100 (Fri, 18 Dec 2009) | 1 line Closed #1492. review by extempore ........ r20230 | odersky | 2009-12-18 16:18:44 +0100 (Fri, 18 Dec 2009) | 1 line Closed #2779. review by community. ........ r20231 | odersky | 2009-12-18 16:20:56 +0100 (Fri, 18 Dec 2009) | 1 line added test case for #2775 and commented the handling code in Implicits better. Gilles already had a look so noreview. ........ r20232 | dubochet | 2009-12-18 16:21:44 +0100 (Fri, 18 Dec 2009) | 1 line [scaladoc] Added option "-doc-version" to Scaladoc tool (and "docversion" attribute to ant task). Both "-doc-version" and "-doc-title" can be set, but are not yet used in the output. No review. ........ r20233 | odersky | 2009-12-18 16:22:11 +0100 (Fri, 18 Dec 2009) | 1 line Closed #2801. Had to update a couple of files that already exploited the missing test. ........
-rw-r--r--src/actors/scala/actors/ReactorTask.scala2
-rw-r--r--src/compiler/scala/tools/ant/Scaladoc.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala43
-rw-r--r--src/compiler/scala/tools/nsc/doc/Settings.scala17
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala6
-rw-r--r--src/swing/scala/swing/UIElement.scala2
-rw-r--r--test/files/neg/t2775.check4
-rw-r--r--test/files/neg/t2775.scala1
-rw-r--r--test/files/neg/t2779.check4
-rwxr-xr-xtest/files/neg/t2779.scala25
-rw-r--r--test/files/neg/t2801.check6
-rw-r--r--test/files/neg/t2801.scala3
-rw-r--r--test/files/pos/implicits.scala11
-rw-r--r--test/files/pos/t2794.scala2
16 files changed, 110 insertions, 28 deletions
diff --git a/src/actors/scala/actors/ReactorTask.scala b/src/actors/scala/actors/ReactorTask.scala
index 8fde0e4aea..28e93bbbff 100644
--- a/src/actors/scala/actors/ReactorTask.scala
+++ b/src/actors/scala/actors/ReactorTask.scala
@@ -20,7 +20,7 @@ import java.util.concurrent.Callable
*
* @author Philipp Haller
*/
-private[actors] class ReactorTask[T <: Reactor](var reactor: T, var fun: () => Unit)
+private[actors] class ReactorTask[T >: Null <: Reactor](var reactor: T, var fun: () => Unit)
extends Callable[Unit] with Runnable {
def run() {
diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala
index 4d8333ae93..78093ae95a 100644
--- a/src/compiler/scala/tools/ant/Scaladoc.scala
+++ b/src/compiler/scala/tools/ant/Scaladoc.scala
@@ -104,6 +104,9 @@ class Scaladoc extends MatchingTask {
/** The document title of the generated HTML documentation. */
private var doctitle: Option[String] = None
+ /** The document version, to be added to the title. */
+ private var docversion: Option[String] = None
+
/** Instruct the compiler to use additional parameters */
private var addParams: String = ""
@@ -493,6 +496,7 @@ class Scaladoc extends MatchingTask {
if (!extdirs.isEmpty) docSettings.extdirs.value = asString(getExtdirs)
if (!encoding.isEmpty) docSettings.encoding.value = encoding.get
if (!doctitle.isEmpty) docSettings.doctitle.value = decodeEscapes(doctitle.get)
+ if (!docversion.isEmpty) docSettings.docversion.value = decodeEscapes(docversion.get)
docSettings.deprecation.value = deprecation
docSettings.unchecked.value = unchecked
log("Scaladoc params = '" + addParams + "'", Project.MSG_DEBUG)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index c4c26e54b3..a8118242df 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1058,13 +1058,7 @@ self =>
Throw(expr())
}
case IMPLICIT =>
- val start = in.skipToken()
- val param0 = convertToParam(atPos(in.offset)(Ident(ident())))
- val param = treeCopy.ValDef(param0, param0.mods | Flags.IMPLICIT, param0.name, param0.tpt, param0.rhs)
- atPos(start, in.offset) {
- accept(ARROW)
- Function(List(param), if (location != InBlock) expr() else block())
- }
+ implicitClosure(in.skipToken(), location)
case _ =>
var t = postfixExpr()
if (in.token == EQUALS) {
@@ -1124,6 +1118,17 @@ self =>
stripParens(t)
}
+ /** Expr ::= implicit Id => Expr
+ */
+ def implicitClosure(start: Int, location: Int): Tree = {
+ val param0 = convertToParam(atPos(in.offset)(Ident(ident())))
+ val param = treeCopy.ValDef(param0, param0.mods | Flags.IMPLICIT, param0.name, param0.tpt, param0.rhs)
+ atPos(start, in.offset) {
+ accept(ARROW)
+ Function(List(param), if (location != InBlock) expr() else block())
+ }
+ }
+
/** PostfixExpr ::= InfixExpr [Id [nl]]
* InfixExpr ::= PrefixExpr
* | InfixExpr Id [nl] InfixExpr
@@ -2560,12 +2565,15 @@ self =>
}
*/
- def localDef : List[Tree] = {
+ def localDef(implicitMod: Int): List[Tree] = {
val annots = annotations(true, false)
val pos = in.offset
- val mods = localModifiers() withAnnotations annots
- if (!(mods hasFlag ~(Flags.IMPLICIT | Flags.LAZY))) defOrDcl(pos, mods)
- else List(tmplDef(pos, mods))
+ val mods = (localModifiers() | implicitMod) withAnnotations annots
+ val defs =
+ if (!(mods hasFlag ~(Flags.IMPLICIT | Flags.LAZY))) defOrDcl(pos, mods)
+ else List(tmplDef(pos, mods))
+ if (in.token != RBRACE && in.token != CASE) defs
+ else defs ::: List(Literal(()).setPos(o2p(in.offset)))
}
/** BlockStatSeq ::= { BlockStat semi } [ResultExpr]
@@ -2584,11 +2592,14 @@ self =>
stats += statement(InBlock)
if (in.token != RBRACE && in.token != CASE) acceptStatSep()
} else if (isDefIntro || isLocalModifier || in.token == AT) {
- stats ++= localDef
- if (in.token == RBRACE || in.token == CASE) {
- //syntaxError("block must end in result expression, not in definition", false)
- stats += Literal(()).setPos(o2p(in.offset))
- } else acceptStatSep()
+ if (in.token == IMPLICIT) {
+ val start = in.skipToken()
+ if (isIdent) stats += implicitClosure(start, InBlock)
+ else stats ++= localDef(Flags.IMPLICIT)
+ } else {
+ stats ++= localDef(0)
+ }
+ if (in.token != RBRACE && in.token != CASE) acceptStatSep()
} else if (isStatSep) {
in.nextToken()
} else {
diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala
index 87d5eca645..75aff8e4bd 100644
--- a/src/compiler/scala/tools/nsc/doc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/doc/Settings.scala
@@ -10,16 +10,23 @@ package doc
import java.io.File
import java.lang.System
+/** An extended version of compiler settings, with additional Scaladoc-specific options.
+ * @param error A function that prints a string to the appropriate error stream. */
class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) {
- /** scaladoc specific options */
- val docformat = ChoiceSetting ("-doc-format", "Selects to which format documentation is rendered", List("html"), "html")
- val doctitle = StringSetting ("-doc-title", "doc-title", "Include title for the overview page", "Scala 2 API")
+ /** A setting that defines in which format the documentation is output. ''Note:'' this setting is currently always
+ * `html`. */
+ val docformat = ChoiceSetting ("-doc-format", "Selects in which format documentation is rendered", List("html"), "html")
- // working around issue described in r18708.
- suppressVTWarn.value = true
+ /** A setting that defines the overall title of the documentation, typically the name of the library being
+ * documented. 'Note:'' This setting is currently not used. */
+ val doctitle = StringSetting ("-doc-title", "doc-title", "The overall name of the Scaladoc site", "")
+ /** A setting that defines the overall version number of the documentation, typically the version of the library being
+ * documented. 'Note:'' This setting is currently not used. */
+ val docversion = StringSetting ("-doc-version", "doc-version", "An optional version number, to be appended to the title", "")
// working around issue described in r18708.
suppressVTWarn.value = true
+
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 24abef8944..513ed34ff9 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -4188,7 +4188,7 @@ A type's typeSymbol should never be inspected directly.
} else if (sym1 == NullClass) {
tp2 match {
case TypeRef(_, sym2, _) =>
- (sym2 isNonBottomSubClass ObjectClass) &&
+ sym2.isClass && (sym2 isNonBottomSubClass ObjectClass) &&
!(tp2.normalize.typeSymbol isNonBottomSubClass NotNullClass)
case _ =>
isSingleType(tp2) && tp1 <:< tp2.widen
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 707c91e6ad..eea5be32b7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -771,8 +771,12 @@ self: Analyzer =>
else if (sym.isTypeParameterOrSkolem)
EmptyTree // a manifest should have been found by normal searchImplicit
else {
- // the following is tricky! We want to find the parameterized version of
+ // The following is tricky! We want to find the parameterized version of
// what will become the erasure of the upper bound.
+ // But there is a case where the erasure is not a superclass of the current type:
+ // Any erases to Object. So an abstract type having Any as upper bound will not see
+ // Object as a baseType. That's why we do the basetype trick only when we must,
+ // i.e. when the baseclass is parameterized.
var era = erasure.erasure(tp1)
if (era.typeSymbol.typeParams.nonEmpty)
era = tp1.baseType(era.typeSymbol)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index e541c58c1a..542b2d04c2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2111,10 +2111,12 @@ trait Typers { self: Analyzer =>
(e.sym.isType || inBlock || (e.sym.tpe matches e1.sym.tpe)))
// default getters are defined twice when multiple overloads have defaults. an
// error for this is issued in RefChecks.checkDefaultsInOverloaded
- if (!e.sym.isErroneous && !e1.sym.isErroneous && !e.sym.hasFlag(DEFAULTPARAM))
+ if (!e.sym.isErroneous && !e1.sym.isErroneous && !e.sym.hasFlag(DEFAULTPARAM)) {
error(e.sym.pos, e1.sym+" is defined twice"+
{if(!settings.debug.value) "" else " in "+unit.toString})
- e1 = scope.lookupNextEntry(e1);
+ scope.unlink(e1) // need to unlink to avoid later problems with lub; see #2779
+ }
+ e1 = scope.lookupNextEntry(e1)
}
}
diff --git a/src/swing/scala/swing/UIElement.scala b/src/swing/scala/swing/UIElement.scala
index bff294d641..8a661626f4 100644
--- a/src/swing/scala/swing/UIElement.scala
+++ b/src/swing/scala/swing/UIElement.scala
@@ -32,7 +32,7 @@ object UIElement {
* it will return that wrapper. Otherwise it returns `null`. This
* method never throws an exception.
*/
- private[swing] def cachedWrapper[C<:UIElement](c: java.awt.Component): C = {
+ private[swing] def cachedWrapper[C>:Null<:UIElement](c: java.awt.Component): C = {
val w = c match {
case c: javax.swing.JComponent => c.getClientProperty(ClientKey)
case _ => wrapperCache.get(c)
diff --git a/test/files/neg/t2775.check b/test/files/neg/t2775.check
new file mode 100644
index 0000000000..a30d35fdd9
--- /dev/null
+++ b/test/files/neg/t2775.check
@@ -0,0 +1,4 @@
+t2775.scala:1: error: cannot find class manifest for element type B.this.T
+trait B[S] { type T = S; val c = new Array[T](1) }
+ ^
+one error found
diff --git a/test/files/neg/t2775.scala b/test/files/neg/t2775.scala
new file mode 100644
index 0000000000..9e4f2f606d
--- /dev/null
+++ b/test/files/neg/t2775.scala
@@ -0,0 +1 @@
+trait B[S] { type T = S; val c = new Array[T](1) }
diff --git a/test/files/neg/t2779.check b/test/files/neg/t2779.check
new file mode 100644
index 0000000000..4f94a780a1
--- /dev/null
+++ b/test/files/neg/t2779.check
@@ -0,0 +1,4 @@
+t2779.scala:16: error: method f is defined twice
+ override def f = List(M1)
+ ^
+one error found
diff --git a/test/files/neg/t2779.scala b/test/files/neg/t2779.scala
new file mode 100755
index 0000000000..d025055aa0
--- /dev/null
+++ b/test/files/neg/t2779.scala
@@ -0,0 +1,25 @@
+abstract class M
+{
+ def f: List[M] = Nil
+}
+
+object M1 extends M
+
+object M2 extends M
+{
+ override def f = List(M1)
+}
+
+object M3 extends M
+{
+ override def f = List(M1)
+ override def f = List(M1)
+}
+
+object M4 extends M
+{
+ override def f = List(
+ M3,
+ M2
+ )
+}
diff --git a/test/files/neg/t2801.check b/test/files/neg/t2801.check
new file mode 100644
index 0000000000..25320de5bc
--- /dev/null
+++ b/test/files/neg/t2801.check
@@ -0,0 +1,6 @@
+t2801.scala:2: error: type mismatch;
+ found : Null(null)
+ required: A
+ def f[A <: AnyRef] = { val a: A = null ; a }
+ ^
+one error found
diff --git a/test/files/neg/t2801.scala b/test/files/neg/t2801.scala
new file mode 100644
index 0000000000..d425f58b56
--- /dev/null
+++ b/test/files/neg/t2801.scala
@@ -0,0 +1,3 @@
+object Test {
+ def f[A <: AnyRef] = { val a: A = null ; a }
+}
diff --git a/test/files/pos/implicits.scala b/test/files/pos/implicits.scala
index 4979835e21..14241a2655 100644
--- a/test/files/pos/implicits.scala
+++ b/test/files/pos/implicits.scala
@@ -12,6 +12,17 @@ class C1435 {
}
}
+// #1492
+class C1492 {
+
+ class X
+
+ def foo(x: X => X) {}
+
+ foo ( implicit x => implicitly[X] )
+ foo { implicit x => implicitly[X] }
+}
+
// #1579
object Test1579 {
class Column
diff --git a/test/files/pos/t2794.scala b/test/files/pos/t2794.scala
index caefea4fbb..a17edf8cb3 100644
--- a/test/files/pos/t2794.scala
+++ b/test/files/pos/t2794.scala
@@ -4,6 +4,6 @@ class Entry[T](val k: Key[T], val v: T)
object Entry {
- def makeDefault[T <: AnyRef] = new Entry[T](new Key[T], null: T)
+ def makeDefault[T >: Null <: AnyRef] = new Entry[T](new Key[T], null: T)
}