diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2009-12-18 15:22:51 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2009-12-18 15:22:51 +0000 |
commit | 2ab456d13df1ac50539e4620f62f6e234f3c8446 (patch) | |
tree | 865acb3c7eb91100b232aa73214687f53e6dd1c9 /src/compiler | |
parent | a861322f83c23ef1801a0dcb963020b20f8a1b37 (diff) | |
download | scala-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. ........
Diffstat (limited to 'src/compiler')
6 files changed, 53 insertions, 25 deletions
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) } } |