diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2011-04-26 08:44:22 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2011-04-26 08:44:22 +0000 |
commit | 15d477697395ff93c3065b7f2c7db06160662851 (patch) | |
tree | 0000b0c73bbf5a9541135364f92bb62c10e007c2 | |
parent | f5faa91d3d6ed21a2849f090c40082f95e7dc121 (diff) | |
download | scala-15d477697395ff93c3065b7f2c7db06160662851.tar.gz scala-15d477697395ff93c3065b7f2c7db06160662851.tar.bz2 scala-15d477697395ff93c3065b7f2c7db06160662851.zip |
Merged revisions 24803-24820 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk
........
r24803 | odersky | 2011-04-21 19:21:28 +0200 (Thu, 21 Apr 2011) | 1 line
Added bridge method capability to compiler. Some tweaks to reflect
generic. No review (yet). ........ r24804 | odersky | 2011-04-22
00:41:20 +0200 (Fri, 22 Apr 2011) | 1 line
Some more tweaks to the bridge scheme.
........
r24805 | extempore | 2011-04-22 03:47:32 +0200 (Fri, 22 Apr 2011) | 1 line
New starr based on r24804, no review.
........
r24806 | odersky | 2011-04-22 11:21:28 +0200 (Fri, 22 Apr 2011) | 1 line
Fixed spurious qualification of types that are locally quantified.
Review by extempore. ........ r24807 | extempore | 2011-04-23 00:01:22
+0200 (Sat, 23 Apr 2011) | 2 lines
Fixing a BaseBerrySethi bug I introduced in r19842. Patch by buraq, no
review. ........ r24808 | eugenevigdorchik | 2011-04-23 14:18:53 +0200
(Sat, 23 Apr 2011) | 1 line
Introduce new request for informing the presentation compiler of files
deletion. Review by odersky. ........ r24809 | extempore | 2011-04-23
17:14:59 +0200 (Sat, 23 Apr 2011) | 2 lines
Strip unused pattern variable bindings out before performing match
translation. Closes #4269, no review. ........ r24810 | extempore |
2011-04-23 18:56:32 +0200 (Sat, 23 Apr 2011) | 1 line
Reverted a jline commit which had broken history search, no review.
........ r24811 | pedrofurla | 2011-04-23 23:11:32 +0200 (Sat, 23 Apr
2011) | 1 line
Shows migration and it's message. Contributed by Simon Ochsenreither
(soc). Review by malayeri. ........ r24812 | extempore | 2011-04-24
00:04:36 +0200 (Sun, 24 Apr 2011) | 5 lines
Working my way through pattern matcher sequence issues mostly caused
by the special handling of Lists. Also deleting all kinds of useless
or almost useless code which is presently only clutter.
Closes #2756, #2800, #3050, #3530, #3972, no review. ........ r24813 |
odersky | 2011-04-24 12:18:44 +0200 (Sun, 24 Apr 2011) | 1 line
Refined handling fo @bridge methods. Review by extempore. ........
r24814 | extempore | 2011-04-24 18:19:21 +0200 (Sun, 24 Apr 2011) | 1
line
Updated a bunch of @deprecated annotations to have a version, no
review. ........ r24815 | extempore | 2011-04-24 19:10:26 +0200 (Sun, 24
Apr 2011) | 1 line
New starr based on r24814, no review.
........
r24816 | extempore | 2011-04-24 21:15:19 +0200 (Sun, 24 Apr 2011) | 1 line
Enclosed the out of bounds index with some IOOB exceptions, no review.
........ r24817 | extempore | 2011-04-24 21:15:46 +0200 (Sun, 24 Apr
2011) | 2 lines
Removed restriction on case classes having only two parameter lists.
Closes #1333, no review. ........ r24818 | extempore | 2011-04-24
21:16:10 +0200 (Sun, 24 Apr 2011) | 2 lines
Added warning when someone tries to return a non-Unit value from a
Unit method, no review. ........ r24819 | odersky | 2011-04-24 22:13:40
+0200 (Sun, 24 Apr 2011) | 1 line
Added a bunch of bridges to make ameliorate binary compatibility of
new collections. Review by prokopec. Review by extempore. ........
r24820 | odersky | 2011-04-25 12:37:48 +0200 (Mon, 25 Apr 2011) | 1 line
Temporarily moving interpreter.scala to pending. We need a more
robust solution wrt heap size before we can bring it back. (interpreter
scala randomly fails with OutOfMemoryError because it starts a new java
process with default heap size. Depending on the configuration, default
heap size is sometimes not enough.) ........
163 files changed, 1163 insertions, 784 deletions
diff --git a/lib/jline.jar.desired.sha1 b/lib/jline.jar.desired.sha1 index a0f97c4d7a..74b0d9d91e 100644 --- a/lib/jline.jar.desired.sha1 +++ b/lib/jline.jar.desired.sha1 @@ -1 +1 @@ -115e0f58e2ffa089c083c466b0161216dd4c916e ?jline.jar +5eade2bafa228aab1f5abc63e6062ce8052e4f6d ?jline.jar diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index d2eb0e93e3..41809695eb 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -e0382dfa2712e567b49f5826ac50eae59cf03cb3 ?scala-compiler.jar +5f31fab985a3efc21229297810c625b0a2593757 ?scala-compiler.jar diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1 index 1b5b949434..3370299a4a 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -5ad90238f4fc57e8147fb69496c68d02ca073ca0 ?scala-library-src.jar +364c3b992bdebeac9fafb187e1acbece45644de7 ?scala-library-src.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index b0aa256cb4..4993fe9421 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -678ada3690dd149c2bd302407e315a74de0bfd42 ?scala-library.jar +c52dbed261e4870a504cef24518484b335a38067 ?scala-library.jar diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala index 3bf1b33abf..7fe492cae2 100644 --- a/src/actors/scala/actors/Scheduler.scala +++ b/src/actors/scala/actors/Scheduler.scala @@ -50,7 +50,7 @@ object Scheduler extends DelegatingScheduler { /* Only <code>ForkJoinScheduler</code> implements this method. */ - @deprecated("restart will be removed") + @deprecated("restart will be removed", "2.8.0") def restart() { if (sched.isInstanceOf[ForkJoinScheduler]) { sched.asInstanceOf[ForkJoinScheduler].restart() diff --git a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala index 45f8d1af5f..b9e9a14adf 100644 --- a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala +++ b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala @@ -40,6 +40,6 @@ class GenericRunnerSettings(error: String => Unit) extends Settings(error) { "-nc", "do not use the fsc compilation daemon") withAbbreviation "-nocompdaemon" - @deprecated("Use `nc` instead") def nocompdaemon = nc - @deprecated("Use `save` instead") def savecompiled = save + @deprecated("Use `nc` instead", "2.9.0") def nocompdaemon = nc + @deprecated("Use `save` instead", "2.9.0") def savecompiled = save } diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index ad39ee2b26..434f19f21b 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -5,7 +5,7 @@ import java.io._ /** A compatibility stub. */ -@deprecated("Use a class in the scala.tools.nsc.interpreter package.") +@deprecated("Use a class in the scala.tools.nsc.interpreter package.", "2.9.0") class Interpreter(settings: Settings, out: PrintWriter) extends IMain(settings, out) { def this(settings: Settings) = this(settings, new NewLinePrintWriter(new ConsoleWriter, true)) def this() = this(new Settings()) diff --git a/src/compiler/scala/tools/nsc/InterpreterCommand.scala b/src/compiler/scala/tools/nsc/InterpreterCommand.scala index ae2530ce40..e25a83e08b 100644 --- a/src/compiler/scala/tools/nsc/InterpreterCommand.scala +++ b/src/compiler/scala/tools/nsc/InterpreterCommand.scala @@ -4,5 +4,5 @@ import interpreter._ /** A compatibility stub. */ -@deprecated("Use a class in the scala.tools.nsc.interpreter package.") +@deprecated("Use a class in the scala.tools.nsc.interpreter package.", "2.9.0") class InterpreterCommand(arguments: List[String], error: String => Unit) extends CommandLine(arguments, error) { }
\ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala index 8eb381f18a..a0be3f4fdb 100644 --- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala +++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala @@ -5,7 +5,7 @@ import java.io._ /** A compatibility stub. */ -@deprecated("Use a class in the scala.tools.nsc.interpreter package.") +@deprecated("Use a class in the scala.tools.nsc.interpreter package.", "2.9.0") class InterpreterLoop(in0: Option[BufferedReader], out: PrintWriter) extends ILoop(in0, out) { def this(in0: BufferedReader, out: PrintWriter) = this(Some(in0), out) def this() = this(None, new PrintWriter(scala.Console.out)) diff --git a/src/compiler/scala/tools/nsc/MainInterpreter.scala b/src/compiler/scala/tools/nsc/MainInterpreter.scala index 9055466dd7..5d190bbe14 100644 --- a/src/compiler/scala/tools/nsc/MainInterpreter.scala +++ b/src/compiler/scala/tools/nsc/MainInterpreter.scala @@ -7,7 +7,7 @@ package scala.tools.nsc import interpreter._ -@deprecated("Use a class in the scala.tools.nsc.interpreter package.") +@deprecated("Use a class in the scala.tools.nsc.interpreter package.", "2.9.0") object MainInterpreter { def main(args: Array[String]): Unit = new ILoop main args } diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index 9df0069ada..5d276e2004 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -301,7 +301,7 @@ trait DocComments { self: SymbolTable => val defines = sections filter { startsWithTag(raw, _, "@define") } val usecases = sections filter { startsWithTag(raw, _, "@usecase") } - val end = startTag(raw, (defines ::: usecases).sort(_._1 < _._1)) + val end = startTag(raw, (defines ::: usecases).sortBy(_._1)) (if (end == raw.length - 2) raw else raw.substring(0, end) + "*/", defines map { case (start, end) => raw.substring(start, end) }, 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 f3e197d0be..e87f297094 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -322,11 +322,10 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { val annotations: Seq[scala.xml.Node] = { // A list of annotations which don't show their arguments, e. g. because they are shown separately. - val annotationsWithHiddenArguments = List("deprecated", "Deprecated") + val annotationsWithHiddenArguments = List("deprecated", "Deprecated", "migration") - def showArguments(annotation: Annotation) = { + def showArguments(annotation: Annotation) = if (annotationsWithHiddenArguments.contains(annotation.qualifiedName)) false else true - } if (!mbr.annotations.isEmpty) { <dt>Annotations</dt> @@ -358,11 +357,21 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { <dd class="cmt">{ bodyToHtml(mbr.deprecation.get) }</dd> } + val migration: Seq[scala.xml.Node] = { + mbr.annotations.find(_.qualifiedName == "migration") match { + case None => NodeSeq.Empty + case Some(mig) => { + <dt>Migration</dt> + <dd class="cmt"><p>{mig.arguments.view.map(_.value).drop(2).mkString(" ")}</p></dd> + } + } + } + val mainComment: Seq[scala.xml.Node] = mbr.comment match { case Some(comment) => val example = if(!comment.example.isEmpty && !isReduced) - <div class="block">Example{ if (comment.example.length > 1) "s" else ""} : + <div class="block">Example{ if (comment.example.length > 1) "s" else ""}: <ol>{ val exampleXml: List[scala.xml.NodeSeq] = for(example <- comment.example ) yield @@ -399,7 +408,7 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { } // end attributes block vals --- - val attributesInfo = attributes ++ definitionClasses ++ selfType ++ annotations ++ sourceLink ++ deprecation ++ mainComment + val attributesInfo = attributes ++ definitionClasses ++ selfType ++ annotations ++ deprecation ++ migration ++ sourceLink ++ mainComment val attributesBlock = if (attributesInfo.isEmpty) NodeSeq.Empty diff --git a/src/compiler/scala/tools/nsc/doc/model/Entity.scala b/src/compiler/scala/tools/nsc/doc/model/Entity.scala index 4fb0341684..86de011e68 100644 --- a/src/compiler/scala/tools/nsc/doc/model/Entity.scala +++ b/src/compiler/scala/tools/nsc/doc/model/Entity.scala @@ -127,7 +127,7 @@ trait MemberEntity extends Entity { /** Some deprecation message if this member is deprecated, or none otherwise. */ def deprecation: Option[Body] - @deprecated("Use `inDefinitionTemplates` instead") + @deprecated("Use `inDefinitionTemplates` instead", "2.9.0") def inheritedFrom: List[TemplateEntity] /** For members representing values: the type of the value returned by this member; for members @@ -204,7 +204,7 @@ trait DocTemplateEntity extends TemplateEntity with MemberEntity { /** The direct super-type of this template. */ def parentType: Option[TypeEntity] - @deprecated("Use `linearizationTemplates` and `linearizationTypes` instead") + @deprecated("Use `linearizationTemplates` and `linearizationTypes` instead", "2.9.0") def linearization: List[(TemplateEntity, TypeEntity)] /** All class, trait and object templates which are part of this template's linearization, in lineratization order. diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index 0c5d85d2a8..ba15ea8aed 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -66,11 +66,11 @@ trait CompilerControl { self: Global => * if it does not yet exist create a new one atomically * Note: We want to get roid of this operation as it messes compiler invariants. */ - @deprecated("use getUnitOf(s) or onUnitOf(s) instead") + @deprecated("use getUnitOf(s) or onUnitOf(s) instead", "2.9.0") def unitOf(s: SourceFile): RichCompilationUnit = getOrCreateUnitOf(s) /** The compilation unit corresponding to a position */ - @deprecated("use getUnitOf(pos.source) or onUnitOf(pos.source) instead") + @deprecated("use getUnitOf(pos.source) or onUnitOf(pos.source) instead", "2.9.0") def unitOf(pos: Position): RichCompilationUnit = getOrCreateUnitOf(pos.source) /** Removes the CompilationUnit corresponding to the given SourceFile @@ -107,7 +107,7 @@ trait CompilerControl { self: Global => if (item.onCompilerThread) item() else scheduler.postWorkItem(item) /** Makes sure a set of compilation units is loaded and parsed. - * Returns () to syncvar `response` on completions. + * Returns () to syncvar `response` on completion. * Afterwards a new background compiler run is started with * the given sources at the head of the list of to-be-compiled sources. */ @@ -120,6 +120,13 @@ trait CompilerControl { self: Global => postWorkItem(new ReloadItem(sources, response)) } + /** Removes source files and toplevel symbols, and issues a new typer run. + * Returns () to syncvar `response` on completion. + */ + def askFilesDeleted(sources: List[SourceFile], response: Response[Unit]) = { + postWorkItem(new FilesDeletedItem(sources, response)) + } + /** Sets sync var `response` to the smallest fully attributed tree that encloses position `pos`. * Note: Unlike for most other ask... operations, the source file belonging to `pos` needs not be be loaded. */ @@ -204,7 +211,7 @@ trait CompilerControl { self: Global => /** Tells the compile server to shutdown, and not to restart again */ def askShutdown() = scheduler raise ShutdownReq - @deprecated("use parseTree(source) instead") + @deprecated("use parseTree(source) instead", "2.9.0") def askParse(source: SourceFile, response: Response[Tree]) = respond(response) { parseTree(source) } @@ -261,6 +268,11 @@ trait CompilerControl { self: Global => override def toString = "reload "+sources } + case class FilesDeletedItem(sources: List[SourceFile], response: Response[Unit]) extends WorkItem { + def apply() = filesDeleted(sources, response) + override def toString = "files deleted "+sources + } + class AskTypeAtItem(val pos: Position, response: Response[Tree]) extends WorkItem { def apply() = self.getTypedTreeAt(pos, response) override def toString = "typeat "+pos.source+" "+pos.show diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 2b920c8c03..d8f43fd209 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -578,6 +578,22 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "") demandNewCompilerRun() } + private[interactive] def filesDeleted(sources: List[SourceFile], response: Response[Unit]) { + informIDE("files deleted: " + sources) + val deletedFiles = sources.map(_.file).toSet + val deletedSyms = currentTopLevelSyms filter {sym => deletedFiles contains sym.sourceFile} + for (d <- deletedSyms) { + d.owner.info.decls unlink d + deletedTopLevelSyms += d + currentTopLevelSyms -= d + } + sources foreach (removeUnitOf(_)) + minRunId = currentRunId + respond(response) () + demandNewCompilerRun() + } + + /** A fully attributed tree located at position `pos` */ private def typedTreeAt(pos: Position): Tree = getUnit(pos.source) match { case None => diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index d6e447ca0a..fbb3457f4d 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -51,10 +51,10 @@ class ILoop(in0: Option[BufferedReader], protected val out: PrintWriter) // TODO // object opt extends AestheticSettings // - @deprecated("Use `intp` instead.") + @deprecated("Use `intp` instead.", "2.9.0") def interpreter = intp - @deprecated("Use `intp` instead.") + @deprecated("Use `intp` instead.", "2.9.0") def interpreter_= (i: Interpreter): Unit = intp = i def history = in.history @@ -835,14 +835,14 @@ class ILoop(in0: Option[BufferedReader], protected val out: PrintWriter) } } - @deprecated("Use `process` instead") + @deprecated("Use `process` instead", "2.9.0") def main(args: Array[String]): Unit = { if (isReplDebug) System.out.println(new java.util.Date) process(args) } - @deprecated("Use `process` instead") + @deprecated("Use `process` instead", "2.9.0") def main(settings: Settings): Unit = process(settings) } diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 62e781958f..2eeefbefce 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -162,7 +162,7 @@ class IMain(val settings: Settings, protected val out: PrintWriter) extends Impo if (_isInitialized()) _compiler else null } - @deprecated("Use `global` for access to the compiler instance.") + @deprecated("Use `global` for access to the compiler instance.", "2.9.0") lazy val compiler: global.type = global import global._ diff --git a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala index edade4da1b..55706f4fd2 100644 --- a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala +++ b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala @@ -52,7 +52,7 @@ object InteractiveReader { } def apply(): InteractiveReader = SimpleReader() - @deprecated("Use `apply` instead.") + @deprecated("Use `apply` instead.", "2.9.0") def createDefault(): InteractiveReader = apply() } diff --git a/src/compiler/scala/tools/nsc/matching/Matrix.scala b/src/compiler/scala/tools/nsc/matching/Matrix.scala index 5648f97f84..8dc960894c 100644 --- a/src/compiler/scala/tools/nsc/matching/Matrix.scala +++ b/src/compiler/scala/tools/nsc/matching/Matrix.scala @@ -88,6 +88,7 @@ trait Matrix extends MatrixAdditions { context: MatrixContext): Tree = { import context._ + TRACE("handlePattern", "(%s: %s) match { %s cases }", selector, selector.tpe, cases.size) val matrixInit: MatrixInit = { val v = copyVar(selector, isChecked, selector.tpe, "temp") diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 1b0265ce5d..f41c37080a 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -39,15 +39,16 @@ trait ParallelMatching extends ast.TreeDSL def data: MatrixContext#MatrixInit - lazy val MatrixInit(roots, cases, failTree) = data - lazy val ExpandedMatrix(rows, targets) = expand(roots, cases) - lazy val expansion: Rep = make(roots, rows) + lazy val MatrixInit(roots, cases, failTree) = data + lazy val (rows, targets) = expand(roots, cases).unzip + lazy val expansion: Rep = make(roots, rows) - val shortCuts = new ListBuffer[Symbol]() + private val shortCuts = mutable.HashMap[Int, Symbol]() - final def shortCut(theLabel: Symbol): Int = { - shortCuts += theLabel - -shortCuts.length + final def createShortCut(theLabel: Symbol): Int = { + val key = shortCuts.size + 1 + shortCuts(key) = theLabel + -key } /** first time bx is requested, a LabelDef is returned. next time, a jump. @@ -55,18 +56,25 @@ trait ParallelMatching extends ast.TreeDSL */ final def requestBody(bx: Int, subst: Bindings): Tree = { // shortcut - if (bx < 0) Apply(ID(shortCuts(-bx-1)), Nil) + if (bx < 0) Apply(ID(shortCuts(-bx)), Nil) else targets(bx) labelBody subst } - /** the injection here handles alternatives and unapply type tests */ - final def make(tvars: PatternVarGroup, row1: List[Row]): Rep = { - // TRACE("make(%s%s)", pp(tvars.pvs, 1, true), pp(row1, 1, true)) - def classifyPat(opat: Pattern, j: Int): Pattern = opat simplify tvars(j) + /** This is the recursively focal point for translating the current + * list of pattern variables and a list of pattern match rows into + * a tree suitable for entering erasure. + * + * The first time it is called, the variables are (copies of) the + * original pattern matcher roots, and the rows correspond to the + * original casedefs. + */ + final def make(roots1: PatternVarGroup, rows1: List[Row]): Rep = { + traceCategory("New Match", "%sx%s (%s)", roots1.size, rows1.size, roots1.syms.mkString(", ")) + def classifyPat(opat: Pattern, j: Int): Pattern = opat simplify roots1(j) - val rows = row1 flatMap (_ expandAlternatives classifyPat) - if (rows.length != row1.length) make(tvars, rows) // recursive call if any change - else Rep(tvars, rows).checkExhaustive + val newRows = rows1 flatMap (_ expandAlternatives classifyPat) + if (rows1.length != newRows.length) make(roots1, newRows) // recursive call if any change + else Rep(roots1, newRows).checkExhaustive } override def toString() = "MatchMatrix(%s) { %s }".format(matchResultType, indentAll(targets)) @@ -182,17 +190,11 @@ trait ParallelMatching extends ast.TreeDSL } } - object TypedUnapply { - def unapply(x: Tree): Option[Boolean] = condOpt(x) { - case Typed(UnapplyParamType(tpe), tpt) => !(tpt.tpe <:< tpe) - } - } - def mkRule(rest: Rep): RuleApplication = { tracing("Rule")(head match { case x if isEquals(x.tree.tpe) => new MixEquals(this, rest) case x: SequencePattern => new MixSequence(this, rest, x) - case AnyUnapply(false) => new MixUnapply(this, rest, false) + case AnyUnapply(false) => new MixUnapply(this, rest) case _ => isPatternSwitch(scrut, ps) match { case Some(x) => new MixLiteralInts(x, rest) @@ -327,7 +329,7 @@ trait ParallelMatching extends ast.TreeDSL /** mixture rule for unapply pattern */ - class MixUnapply(val pmatch: PatternMatch, val rest: Rep, typeTest: Boolean) extends RuleApplication { + class MixUnapply(val pmatch: PatternMatch, val rest: Rep) extends RuleApplication { val uapattern = head match { case x: UnapplyPattern => x ; case _ => abort("XXX") } val ua @ UnApply(app, args) = head.tree @@ -494,7 +496,9 @@ trait ParallelMatching extends ast.TreeDSL val compareFn: Tree => Tree = (t: Tree) => compareOp((t DOT methodOp)(LIT(pivotLen)), ZERO) // wrapping in a null check on the scrutinee + // XXX this needs to use the logic in "def condition" nullSafe(compareFn, FALSE)(scrut.id) + // condition(head.tpe, scrut.id, head.boundVariables.nonEmpty) } lazy val success = squeezedBlock(pvs map (_.valDef), remake(successRows, pvs, hasStar).toTree) lazy val failure = remake(failRows).toTree @@ -521,7 +525,7 @@ trait ParallelMatching extends ast.TreeDSL lazy val success = remake(List( rest.rows.head.insert2(List(NoPattern), head.boundVariables, scrut.sym), - Row(emptyPatterns(1 + rest.tvars.size), NoBinding, EmptyTree, shortCut(label)) + Row(emptyPatterns(1 + rest.tvars.size), NoBinding, EmptyTree, createShortCut(label)) )).toTree lazy val failure = LabelDef(label, Nil, labelBody) @@ -615,8 +619,6 @@ trait ParallelMatching extends ast.TreeDSL case class Row(pats: List[Pattern], subst: Bindings, guard: Tree, bx: Int) { private def nobindings = subst.get().isEmpty private def bindstr = if (nobindings) "" else pp(subst) - // if (pats exists (p => !p.isDefault)) - // traceCategory("Row", "%s%s", pats, bindstr) /** Extracts the 'i'th pattern. */ def extractColumn(i: Int) = { @@ -655,29 +657,6 @@ trait ParallelMatching extends ast.TreeDSL } } - object ExpandedMatrix { - def unapply(x: ExpandedMatrix) = Some((x.rows, x.targets)) - def apply(rowz: List[(Row, FinalState)]) = - new ExpandedMatrix(rowz map (_._1), rowz map (_._2) toIndexedSeq) - } - - class ExpandedMatrix(val rows: List[Row], val targets: IndexedSeq[FinalState]) { - require(rows.size == targets.size) - - override def toString() = { - def vprint(vs: List[Any]) = if (vs.isEmpty) "" else ": %s".format(pp(vs)) - def rprint(r: Row) = pp(r) - def tprint(t: FinalState) = - if (t.params.isEmpty) " ==> %s".format(pp(t.body)) - else " ==>\n %s".format(pp(t.params -> t.body)) - - val xs = rows zip targets map { case (r,t) => rprint(r) + tprint(t) } - val ppstr = pp(xs, newlines = true) - - "ExpandedMatrix(%d rows)".format(rows.size) + ppstr - } - } - case class FinalState(bx: Int, body: Tree, params: List[Symbol]) { private var referenceCount = 0 // typer is not able to digest a body of type Nothing being assigned result type Unit @@ -762,21 +741,19 @@ trait ParallelMatching extends ast.TreeDSL } /** Expands the patterns recursively. */ - final def expand(roots: List[PatternVar], cases: List[CaseDef]) = - tracing("Expanded")(ExpandedMatrix( - for ((CaseDef(pat, guard, body), index) <- cases.zipWithIndex) yield { - def mkRow(ps: List[Tree]) = Row(toPats(ps), NoBinding, guard, index) - - val pattern = Pattern(pat) - val row = mkRow(pat match { - case x if roots.length <= 1 => List(x) - case Apply(_, args) => args - case WILD() => emptyTrees(roots.length) - }) - - row -> FinalState(index, body, pattern.deepBoundVariables) - }) - ) + final def expand(roots: List[PatternVar], cases: List[CaseDef]) = tracing("expand") { + for ((CaseDef(pat, guard, body), index) <- cases.zipWithIndex) yield { + val subtrees = pat match { + case x if roots.length <= 1 => List(x) + case Apply(_, args) => args + case WILD() => emptyTrees(roots.length) + } + val row = Row(toPats(subtrees), NoBinding, guard, index) + val state = FinalState(index, body, Pattern(pat).deepBoundVariables) + + row -> state + } + } /** returns the condition in "if (cond) k1 else k2" */ diff --git a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala index bb062b3c0a..88983a792f 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala @@ -89,8 +89,8 @@ trait PatternBindings extends ast.TreeDSL } // Wrap this pattern's bindings around (_: Type) - def rebindToType(tpe: Type, annotatedType: Type = null): Pattern = { - val aType = if (annotatedType == null) tpe else annotatedType + def rebindToType(tpe: Type, ascription: Type = null): Pattern = { + val aType = if (ascription == null) tpe else ascription rebindTo(Typed(WILD(tpe), TypeTree(aType)) setType tpe) } @@ -104,10 +104,8 @@ trait PatternBindings extends ast.TreeDSL // Like rebindToEqualsCheck, but subtly different. Not trying to be // mysterious -- I haven't sorted it all out yet. - def rebindToObjectCheck(): Pattern = { - val sType = sufficientType - rebindToType(mkEqualsRef(sType), sType) - } + def rebindToObjectCheck(): Pattern = + rebindToType(mkEqualsRef(sufficientType), sufficientType) /** Helpers **/ private def wrapBindings(vs: List[Symbol], pat: Tree): Tree = vs match { diff --git a/src/compiler/scala/tools/nsc/matching/Patterns.scala b/src/compiler/scala/tools/nsc/matching/Patterns.scala index 742ab32736..e1f8204960 100644 --- a/src/compiler/scala/tools/nsc/matching/Patterns.scala +++ b/src/compiler/scala/tools/nsc/matching/Patterns.scala @@ -27,6 +27,16 @@ trait Patterns extends ast.TreeDSL { type PatternMatch = MatchMatrix#PatternMatch private type PatternVar = MatrixContext#PatternVar + // private def unapplyArgs(x: Any) = x match { + // case UnApply(Apply(TypeApply(_, targs), args), _) => (targs map (_.symbol), args map (_.symbol)) + // case _ => (Nil, Nil) + // } + // + // private def unapplyCall(x: Any) = x match { + // case UnApply(t, _) => treeInfo.methPart(t).symbol + // case _ => NoSymbol + // } + // Fresh patterns def emptyPatterns(i: Int): List[Pattern] = List.fill(i)(NoPattern) def emptyTrees(i: Int): List[Tree] = List.fill(i)(EmptyTree) @@ -45,14 +55,12 @@ trait Patterns extends ast.TreeDSL { val Ident(name) = tree require(isVarPattern(tree) && name != nme.WILDCARD) - override def irrefutableFor(tpe: Type) = true override def description = "%s".format(name) } // 8.1.1 (b) case class WildcardPattern() extends Pattern { val tree = EmptyTree - override def irrefutableFor(tpe: Type) = true override def isDefault = true override def description = "_" } @@ -62,11 +70,9 @@ trait Patterns extends ast.TreeDSL { private val Typed(expr, tpt) = tree override def subpatternsForVars: List[Pattern] = List(Pattern(expr)) - - override def irrefutableFor(tpe: Type) = tpe <:< tree.tpe override def simplify(pv: PatternVar) = Pattern(expr) match { - case ExtractorPattern(ua) if pv.sym.tpe <:< tpt.tpe => this rebindTo expr - case _ => this + case ExtractorPattern(ua) if pv.sym.tpe <:< tpt.tpe => this rebindTo expr + case _ => this } override def description = "Typ(%s: %s)".format(Pattern(expr), tpt) } @@ -159,77 +165,67 @@ trait Patterns extends ast.TreeDSL { if (isColonColon) "%s :: %s".format(Pattern(args(0)), Pattern(args(1))) else "%s(%s)".format(name, toPats(args).mkString(", ")) } - - // XXX todo - // override def irrefutableFor(tpe: Type) = false } // 8.1.6 case class TuplePattern(tree: Apply) extends ApplyPattern { - // XXX todo - // override def irrefutableFor(tpe: Type) = false override def description = "((%s))".format(args.size, toPats(args).mkString(", ")) } - // 8.1.7 + // 8.1.7 / 8.1.8 (unapply and unapplySeq calls) case class ExtractorPattern(tree: UnApply) extends UnapplyPattern { - private val Apply(fn, _) = unfn - private val MethodType(List(arg, _*), _) = fn.tpe - private def uaTyped = Typed(tree, TypeTree(arg.tpe)) setType arg.tpe - - override def necessaryType = arg.tpe - override def simplify(pv: PatternVar) = - if (pv.sym.tpe <:< arg.tpe) this + if (pv.tpe <:< arg.tpe) this else this rebindTo uaTyped - override def description = "UnApp(%s => %s)".format(necessaryType, resTypesString) + override def description = "Unapply(%s => %s)".format(necessaryType, resTypesString) } - // 8.1.8 (unapplySeq calls) - case class SequenceExtractorPattern(tree: UnApply) extends UnapplyPattern with SequenceLikePattern { + case class SequenceExtractorPattern(tree: UnApply, elems: List[Tree]) extends UnapplyPattern with SequenceLikePattern { + override def simplify(pv: PatternVar) = { + pv.sym setFlag NO_EXHAUSTIVE - lazy val UnApply( - Apply(TypeApply(Select(_, nme.unapplySeq), List(tptArg)), _), - List(ArrayValue(_, elems)) - ) = tree + if (pv.tpe <:< arg.tpe) this + else this rebindTo uaTyped + } - /** For folding a list into a well-typed x :: y :: etc :: tree. */ - private def listFolder = { - val tpe = tptArg.tpe - val MethodType(_, TypeRef(pre, sym, _)) = ConsClass.primaryConstructor.tpe - val consRef = typeRef(pre, sym, List(tpe)) - val listRef = typeRef(pre, ListClass, List(tpe)) + override def description = "UnapplySeq(%s => %s)".format(necessaryType, resTypesString) + } - def fold(x: Tree, xs: Tree) = unbind(x) match { - case _: Star => Pattern(x) rebindTo WILD(x.tpe) boundTree // this is using boundVariables instead of deepBoundVariables - case _ => - val dummyMethod = new TermSymbol(NoSymbol, NoPosition, "matching$dummy") - val consType = MethodType(dummyMethod newSyntheticValueParams List(tpe, listRef), consRef) + // Special List handling. It was like that when I got here. + case class ListExtractorPattern(tree: UnApply, tpt: Tree, elems: List[Tree]) extends UnapplyPattern with SequenceLikePattern { + private val cons = ConsClass.primaryConstructor.tpe.resultType + private val consRef = typeRef(cons.prefix, ConsClass, List(tpt.tpe)) + private val listRef = typeRef(cons.prefix, ListClass, List(tpt.tpe)) - Apply(TypeTree(consType), List(x, xs)) setType consRef - } + // Fold a list into a well-typed x :: y :: etc :: tree. + private def listFolder(x: Tree, xs: Tree) = unbind(x) match { + case _: Star => Pattern(x) rebindTo WILD(x.tpe) boundTree + case _ => + val dummyMethod = new TermSymbol(NoSymbol, NoPosition, "matching$dummy") + val consType = MethodType(dummyMethod newSyntheticValueParams List(tpt.tpe, listRef), consRef) - fold _ + Apply(TypeTree(consType), List(x, xs)) setType consRef } - - // @pre: is not right-ignoring (no star pattern) ; no exhaustivity check + override def necessaryType = if (nonStarPatterns.nonEmpty) consRef else listRef override def simplify(pv: PatternVar) = { pv.sym setFlag NO_EXHAUSTIVE - this rebindTo elems.foldRight(gen.mkNil)(listFolder) + + if (pv.tpe <:< necessaryType) + this rebindTo elems.foldRight(gen.mkNil)(listFolder) + else + this rebindTo (Typed(tree, TypeTree(necessaryType)) setType necessaryType) } - override def description = "UnSeq(%s => %s)".format(tptArg, resTypesString) + override def description = "List(%s => %s)".format(tpt.tpe, resTypesString) } trait SequenceLikePattern extends Pattern { def elems: List[Tree] - def elemPatterns = toPats(elems) - - def nonStarPatterns: List[Pattern] = if (hasStar) elemPatterns.init else elemPatterns - def nonStarLength = nonStarPatterns.length - def isAllDefaults = nonStarPatterns forall (_.isDefault) + override def hasStar = elems.nonEmpty && isStar(elems.last) - def isShorter(other: SequenceLikePattern) = nonStarLength < other.nonStarLength - def isSameLength(other: SequenceLikePattern) = nonStarLength == other.nonStarLength + def elemPatterns = toPats(elems) + def nonStarElems = if (hasStar) elems.init else elems + def nonStarPatterns = toPats(nonStarElems) + def nonStarLength = nonStarElems.length } // 8.1.8 (b) (literal ArrayValues) @@ -273,16 +269,6 @@ trait Patterns extends ast.TreeDSL { private val cache = new collection.mutable.HashMap[Tree, Pattern] def clear() = cache.clear() - def unadorn(x: Tree): Tree = x match { - case Typed(expr, _) => unadorn(expr) - case Bind(_, x) => unadorn(x) - case _ => x - } - - def isRightIgnoring(t: Tree) = cond(unadorn(t)) { - case ArrayValue(_, xs) if !xs.isEmpty => isStar(unadorn(xs.last)) - } - def apply(tree: Tree): Pattern = { if (cache contains tree) return cache(tree) @@ -321,21 +307,22 @@ trait Patterns extends ast.TreeDSL { object UnapplyPattern { private object UnapplySeq { - private object TypeApp { - def unapply(x: Any) = condOpt(x) { - case TypeApply(sel @ Select(stor, nme.unapplySeq), List(tpe)) if stor.symbol eq ListModule => tpe - } - } - def unapply(x: UnApply) = condOpt(x) { - case UnApply(Apply(TypeApp(tptArg), _), List(ArrayValue(_, xs))) => (tptArg, xs) - } + def unapply(x: UnApply) = x match { + case UnApply( + Apply(TypeApply(Select(qual, nme.unapplySeq), List(tpt)), _), + List(ArrayValue(_, elems))) => + Some(qual.symbol, tpt, elems) + case _ => + None + } } - def apply(x: UnApply): Pattern = { - x match { - case UnapplySeq(_, _) => SequenceExtractorPattern(x) - case _ => ExtractorPattern(x) - } + def apply(x: UnApply): Pattern = x match { + case UnapplySeq(container, tpt, elems) => + if (container == ListModule) ListExtractorPattern(x, tpt, elems) + else SequenceExtractorPattern(x, elems) + case _ => + ExtractorPattern(x) } } @@ -401,7 +388,15 @@ trait Patterns extends ast.TreeDSL { sealed trait UnapplyPattern extends Pattern { lazy val UnApply(unfn, args) = tree - override def subpatternsForVars: List[Pattern] = toPats(args) + lazy val Apply(fn, _) = unfn + lazy val MethodType(List(arg, _*), _) = fn.tpe + protected def uaTyped = Typed(tree, TypeTree(arg.tpe)) setType arg.tpe + + override def necessaryType = arg.tpe + override def subpatternsForVars = args match { + case List(ArrayValue(elemtpe, elems)) => toPats(elems) + case _ => toPats(args) + } def resTypes = analyzer.unapplyTypeList(unfn.symbol, unfn.tpe) def resTypesString = resTypes match { @@ -433,23 +428,10 @@ trait Patterns extends ast.TreeDSL { // returns either a simplification of this pattern or identity. def simplify(pv: PatternVar): Pattern = this - def simplify(): Pattern = this simplify null // the right number of dummies for this pattern def dummies: List[Pattern] = Nil - // 8.1.13 - // A pattern p is irrefutable for type T if any of the following applies: - // 1) p is a variable pattern - // 2) p is a typed pattern x: T', and T <: T' - // 3) p is a constructor pattern C(p1,...,pn), the type T is an instance of class C, - // the primary constructor of type T has argument types T1,...,Tn and and each - // pi is irrefutable for Ti. - def irrefutableFor(tpe: Type) = false - - // does this pattern completely cover that pattern (i.e. latter cannot be matched) - def completelyCovers(second: Pattern) = false - // Is this a default pattern (untyped "_" or an EmptyTree inserted by the matcher) def isDefault = false @@ -460,34 +442,18 @@ trait Patterns extends ast.TreeDSL { // (nullness and guards will still be checked.) def sufficientType = tpe - // XXX have to determine if this can be made useful beyond an extractor barrier. - // Default sufficient type might be NothingClass.tpe, tpe.narrow, ... - // the subpatterns for this pattern (at the moment, that means constructor arguments) def subpatterns(pm: MatchMatrix#PatternMatch): List[Pattern] = pm.dummies def sym = tree.symbol def tpe = tree.tpe - def prefix = tpe.prefix def isEmpty = tree.isEmpty - def isSymValid = (sym != null) && (sym != NoSymbol) - def isModule = sym.isModule || tpe.termSymbol.isModule + def isModule = sym.isModule || tpe.termSymbol.isModule def isCaseClass = tpe.typeSymbol.isCase - def isObject = isSymValid && prefix.isStable // XXX not entire logic + def isObject = (sym != null) && (sym != NoSymbol) && tpe.prefix.isStable // XXX not entire logic - def unadorn(t: Tree): Tree = Pattern unadorn t - - private def isStar(x: Tree) = cond(unadorn(x)) { case Star(_) => true } - private def endsStar(xs: List[Tree]) = xs.nonEmpty && isStar(xs.last) - - def isStarSequence = isSequence && hasStar - def isSequence = cond(unadorn(tree)) { - case ArrayValue(_, _) => true - } - def hasStar = cond(unadorn(tree)) { - case ArrayValue(_, xs) if endsStar(xs) => true - } + def hasStar = false def setType(tpe: Type): this.type = { tree setType tpe diff --git a/src/compiler/scala/tools/nsc/package.scala b/src/compiler/scala/tools/nsc/package.scala index 79ced4f05a..9b9cfe7280 100644 --- a/src/compiler/scala/tools/nsc/package.scala +++ b/src/compiler/scala/tools/nsc/package.scala @@ -6,8 +6,8 @@ package scala.tools package object nsc { - @deprecated("Use a class in the scala.tools.nsc.interpreter package.") + @deprecated("Use a class in the scala.tools.nsc.interpreter package.", "2.9.0") type InterpreterSettings = interpreter.ISettings - @deprecated("Use a class in the scala.tools.nsc.interpreter package.") + @deprecated("Use a class in the scala.tools.nsc.interpreter package.", "2.9.0") val InterpreterResults = interpreter.Results }
\ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 1134f0e15f..9f666e008f 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -217,6 +217,7 @@ trait Definitions extends reflect.generic.StandardDefinitions { lazy val ScalaInlineClass = getClass("scala.inline") lazy val ScalaNoInlineClass = getClass("scala.noinline") lazy val SpecializedClass = getClass("scala.specialized") + lazy val BridgeClass = getClass("scala.annotation.bridge") // fundamental reference classes lazy val ScalaObjectClass = getClass("scala.ScalaObject") @@ -607,6 +608,13 @@ trait Definitions extends reflect.generic.StandardDefinitions { result } + def getClassIfDefined(fullname: Name): Symbol = + try { + getClass(fullname) + } catch { + case ex: MissingRequirementError => NoSymbol + } + def getMember(owner: Symbol, name: Name): Symbol = { if (owner == NoSymbol) NoSymbol else owner.info.nonPrivateMember(name) match { diff --git a/src/compiler/scala/tools/nsc/symtab/Names.scala b/src/compiler/scala/tools/nsc/symtab/Names.scala index a046058faf..7eccb9a49f 100644 --- a/src/compiler/scala/tools/nsc/symtab/Names.scala +++ b/src/compiler/scala/tools/nsc/symtab/Names.scala @@ -120,7 +120,7 @@ trait Names extends reflect.generic.Names { def isTypeName(name: Name): Boolean = name.isTypeName def nameChars: Array[Char] = chrs - @deprecated("") def view(s: String): TermName = newTermName(s) + @deprecated("", "2.9.0") def view(s: String): TermName = newTermName(s) // Classes ---------------------------------------------------------------------- diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index bbdbb09a9d..c29edaa75d 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -1579,10 +1579,6 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable => */ def nameString: String = decodedName + idString - /** The name of the symbol before decoding, e.g. `$eq$eq` instead of `==`. - */ - def encodedName: String = name.toString - /** If settings.uniqid is set, the symbol's id, else "" */ final def idString: String = if (settings.uniqid.value) "#"+id // +" in "+owner.name+"#"+owner.id // DEBUG diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 7c891667b4..7e523d292c 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -58,8 +58,12 @@ abstract class AddInterfaces extends InfoTransform { private def isInterfaceMember(sym: Symbol): Boolean = { sym.isType || { sym.info; // to set lateMETHOD flag if necessary - sym.isMethod && !sym.isLabel && !(sym hasFlag (PRIVATE | BRIDGE)) && - !sym.isConstructor && !sym.isImplOnly + sym.isMethod && + !sym.isLabel && + !(sym hasFlag PRIVATE) && + (!(sym hasFlag BRIDGE) || (sym hasAnnotation BridgeClass)) && // count @_$bridge$_ annotated classes as interface members + !sym.isConstructor && + !sym.isImplOnly } } diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index f7fa9f57ee..5f9c2b544a 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -68,6 +68,13 @@ abstract class ExplicitOuter extends InfoTransform result } + class RemoveBindingsTransformer(toRemove: Set[Symbol]) extends Transformer { + override def transform(tree: Tree) = tree match { + case Bind(_, body) if toRemove(tree.symbol) => super.transform(body) + case _ => super.transform(tree) + } + } + /** Issue a migration warning for instance checks which might be on an Array and * for which the type parameter conforms to Seq, because these answers changed in 2.8. */ @@ -374,18 +381,23 @@ abstract class ExplicitOuter extends InfoTransform val nguard = new ListBuffer[Tree] val ncases = - for (CaseDef(p, guard, b) <- cases) yield { + for (CaseDef(pat, guard, body) <- cases) yield { + // Strip out any unused pattern bindings up front + val patternIdents = for (b @ Bind(_, _) <- pat) yield b.symbol + val references: Set[Symbol] = Set(guard, body) flatMap { t => for (id @ Ident(name) <- t) yield id.symbol } + val (used, unused) = patternIdents partition references + val strippedPat = if (unused.isEmpty) pat else new RemoveBindingsTransformer(unused.toSet) transform pat + val gdcall = if (guard == EmptyTree) EmptyTree else { - val vs = Pattern(p).deepBoundVariables - val guardDef = makeGuardDef(vs, guard) - nguard += transform(guardDef) // building up list of guards + val guardDef = makeGuardDef(used, guard) + nguard += transform(guardDef) // building up list of guards - localTyper typed (Ident(guardDef.symbol) APPLY (vs map Ident)) + localTyper typed (Ident(guardDef.symbol) APPLY (used map Ident)) } - (CASE(transform(p)) IF gdcall) ==> transform(b) + (CASE(transform(strippedPat)) IF gdcall) ==> transform(body) } def isUncheckedAnnotation(tpe: Type) = tpe hasAnnotation UncheckedClass diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index d198303d66..fd27f178ef 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -232,7 +232,7 @@ trait Infer { } def explainTypes(tp1: Type, tp2: Type) = - withDisambiguation(tp1, tp2)(global.explainTypes(tp1, tp2)) + withDisambiguation(List(), tp1, tp2)(global.explainTypes(tp1, tp2)) /* -- Tests & Checks---------------------------------------------------- */ @@ -1506,7 +1506,7 @@ trait Infer { secondTry = true } def improves(sym1: Symbol, sym2: Symbol): Boolean = - sym2 == NoSymbol || + sym2 == NoSymbol || sym2.hasAnnotation(BridgeClass) || { val tp1 = pre.memberType(sym1) val tp2 = pre.memberType(sym2) (tp2 == ErrorType || @@ -1596,7 +1596,7 @@ trait Infer { def improves(sym1: Symbol, sym2: Symbol) = // util.trace("improve "+sym1+sym1.locationString+" on "+sym2+sym2.locationString)( - sym2 == NoSymbol || sym2.isError || + sym2 == NoSymbol || sym2.isError || sym2.hasAnnotation(BridgeClass) || isStrictlyMoreSpecific(followApply(pre.memberType(sym1)), followApply(pre.memberType(sym2)), sym1, sym2) diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 3b3eb74745..f1f8257fff 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -454,6 +454,8 @@ trait Namers { self: Analyzer => finishWith(tparams) case DefDef(mods, name, tparams, _, _, _) => tree.symbol = enterNewMethod(tree, name, mods.flags, mods, tree.pos) + if (mods.annotations.exists(ann => isAnn(ann, "bridge"))) + tree.symbol setFlag BRIDGE finishWith(tparams) case TypeDef(mods, name, tparams, _) => var flags: Long = mods.flags @@ -496,14 +498,15 @@ trait Namers { self: Analyzer => def enterAccessorMethod(tree: Tree, name: Name, flags: Long, mods: Modifiers): TermSymbol = enterNewMethod(tree, name, flags, mods, tree.pos.focus) + def isAnn(ann: Tree, demand: String) = ann match { + case Apply(Select(New(Ident(name)), _), _) => + name.toString == demand + case Apply(Select(New(Select(pre, name)), _), _) => + name.toString == demand + case _ => false + } + private def addBeanGetterSetter(vd: ValDef, getter: Symbol) { - def isAnn(ann: Tree, demand: String) = ann match { - case Apply(Select(New(Ident(name)), _), _) => - name.toString == demand - case Apply(Select(New(Select(pre, name)), _), _) => - name.toString == demand - case _ => false - } val ValDef(mods, name, tpt, _) = vd val hasBP = mods.annotations.exists(isAnn(_, "BeanProperty")) val hasBoolBP = mods.annotations.exists(isAnn(_, "BooleanBeanProperty")) @@ -1122,13 +1125,9 @@ trait Namers { self: Analyzer => * @param namer is the namer of the module class (the comp. obj) */ def addApplyUnapply(cdef: ClassDef, namer: Namer) { - if (!(cdef.symbol hasFlag ABSTRACT)) { - val applyMethod = caseModuleApplyMeth(cdef) - if (applyMethod.vparamss.size > 2) - context.error(cdef.symbol.pos, "case classes limited by implementation: maximum of 2 constructor parameter lists.") + if (!cdef.symbol.hasAbstractFlag) + namer.enterSyntheticSym(caseModuleApplyMeth(cdef)) - namer.enterSyntheticSym(applyMethod) - } namer.enterSyntheticSym(caseModuleUnapplyMeth(cdef)) } diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 240f0c5f12..7bdca6dbab 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -184,7 +184,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT curTree = tree val body1 = atOwner(currentOwner) { transformTrees(body) } accDefs = accDefs.tail; - treeCopy.Template(tree, parents, self, ownAccDefs.toList ::: body1); + treeCopy.Template(tree, parents, self, ownAccDefs.toList ::: body1) case TypeApply(sel @ Select(This(_), name), args) => mayNeedProtectedAccessor(sel, args, false) diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index b0547cb2e2..2abecfa572 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -195,8 +195,9 @@ trait TypeDiagnostics { def resType = if (pt isWildcard) "" else " with expected result type " + pt def allTypes = (alternatives(tree) flatMap (_.paramTypes)) ++ argtpes :+ pt + def locals = alternatives(tree) flatMap (_.typeParams) - withDisambiguation(allTypes: _*) { + withDisambiguation(locals, allTypes: _*) { treeSymTypeMsg(tree) + msg + asParams(argtpes) + resType } } @@ -292,7 +293,7 @@ trait TypeDiagnostics { } def foundReqMsg(found: Type, req: Type): String = { - (withDisambiguation(found, req) { + (withDisambiguation(List(), found, req) { ";\n found : " + found.toLongString + existentialContext(found) + "\n required: " + req + existentialContext(req) }) + explainVariance(found, req) @@ -344,17 +345,16 @@ trait TypeDiagnostics { ) } } - private def typeDiags(types: Type*): List[TypeDiag] = { + private def typeDiags(locals: List[Symbol], types: Type*): List[TypeDiag] = { object SymExtractor { def unapply(x: Any) = x match { case t @ ConstantType(_) => Some(t -> t.underlying.typeSymbol) - case t @ TypeRef(_, sym, _) => Some(t -> sym) + case t @ TypeRef(_, sym, _) => if (locals contains sym) None else Some(t -> sym) case _ => None } } - for (tp <- types.toList ; SymExtractor(t, sym) <- tp) yield - TypeDiag(t, sym) + for (tp <- types.toList; SymExtractor(t, sym) <- tp) yield TypeDiag(t, sym) } /** The distinct pairs from an ordered list. */ @@ -367,8 +367,8 @@ trait TypeDiagnostics { * until they can be distinguished from one another: then executes the given * code. The names are restored and the result is returned. */ - def withDisambiguation[T](types: Type*)(op: => T): T = { - val typeRefs = typeDiags(types: _*) + def withDisambiguation[T](locals: List[Symbol], types: Type*)(op: => T): T = { + val typeRefs = typeDiags(locals, types: _*) val toCheck = pairs(typeRefs) filterNot { case (td1, td2) => td1 sym_== td2 } ultimately(typeRefs foreach (_.restoreName())) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index fb71c8caae..add3bca6f2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1908,6 +1908,12 @@ trait Typers extends Modes { error(x.pos, "_* may only come last") val pat1: Tree = typedPattern(cdef.pat, pattpe) + // When case classes have more than two parameter lists, the pattern ends + // up typed as a method. We only pattern match on the first parameter + // list, so substitute the final result type of the method, i.e. the type + // of the case class. + if (pat1.tpe.paramSectionCount > 0) + pat1 setType pat1.tpe.finalResultType if (forInteractive) { for (bind @ Bind(name, _) <- cdef.pat) @@ -2096,7 +2102,8 @@ trait Typers extends Modes { (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.hasDefaultFlag) { + if (!e.sym.isErroneous && !e1.sym.isErroneous && !e.sym.hasDefaultFlag && + !e.sym.hasAnnotation(BridgeClass) && !e1.sym.hasAnnotation(BridgeClass)) { error(e.sym.pos, e1.sym+" is defined twice"+ {if(!settings.debug.value) "" else " in "+unit.toString}) scope.unlink(e1) // need to unlink to avoid later problems with lub; see #2779 @@ -2466,35 +2473,33 @@ trait Typers extends Modes { /* --- begin unapply --- */ case otpe if inPatternMode(mode) && unapplyMember(otpe).exists => - val unapp = unapplyMember(otpe) - assert(unapp.exists, tree) - val unappType = otpe.memberType(unapp) - val argDummyType = pt // was unappArg - // @S: do we need to memoize this? - val argDummy = context.owner.newValue(fun.pos, nme.SELECTOR_DUMMY) - .setFlag(SYNTHETIC) - .setInfo(argDummyType) if (args.length > MaxTupleArity) error(fun.pos, "too many arguments for unapply pattern, maximum = "+MaxTupleArity) - val arg = Ident(argDummy) setType argDummyType - val oldArgType = arg.tpe - if (!isApplicableSafe(List(), unappType, List(arg.tpe), WildcardType)) { + + def freshArgType(tp: Type): (Type, List[Symbol]) = (tp: @unchecked) match { + case MethodType(param :: _, _) => + (param.tpe, Nil) + case PolyType(tparams, restype) => + val tparams1 = cloneSymbols(tparams) + (freshArgType(restype)._1.substSym(tparams, tparams1), tparams1) + case OverloadedType(_, _) => + error(fun.pos, "cannot resolve overloaded unapply") + (ErrorType, Nil) + } + + val unapp = unapplyMember(otpe) + val unappType = otpe.memberType(unapp) + val argDummy = context.owner.newValue(fun.pos, nme.SELECTOR_DUMMY) setFlag SYNTHETIC setInfo pt + val arg = Ident(argDummy) setType pt + + if (!isApplicableSafe(Nil, unappType, List(pt), WildcardType)) { //Console.println("UNAPP: need to typetest, arg.tpe = "+arg.tpe+", unappType = "+unappType) - def freshArgType(tp: Type): (Type, List[Symbol]) = tp match { - case MethodType(params, _) => - (params(0).tpe, Nil) - case PolyType(tparams, restype) => - val tparams1 = cloneSymbols(tparams) - (freshArgType(restype)._1.substSym(tparams, tparams1), tparams1) - case OverloadedType(_, _) => - error(fun.pos, "cannot resolve overloaded unapply") - (ErrorType, Nil) - } val (unappFormal, freeVars) = freshArgType(unappType.skolemizeExistential(context.owner, tree)) val context1 = context.makeNewScope(context.tree, context.owner) freeVars foreach context1.scope.enter + val typer1 = newTyper(context1) - val pattp = typer1.infer.inferTypedPattern(tree.pos, unappFormal, arg.tpe) + val pattp = typer1.infer.inferTypedPattern(tree.pos, unappFormal, arg.tpe) // turn any unresolved type variables in freevars into existential skolems val skolems = freeVars map { fv => @@ -2504,8 +2509,7 @@ trait Typers extends Modes { skolem } arg.tpe = pattp.substSym(freeVars, skolems) - //todo: replace arg with arg.asInstanceOf[inferTypedPattern(unappFormal, arg.tpe)] instead. - argDummy.setInfo(arg.tpe) // bq: this line fixed #1281. w.r.t. comment ^^^, maybe good enough? + argDummy setInfo arg.tpe } // setType null is necessary so that ref will be stabilized; see bug 881 @@ -2517,12 +2521,13 @@ trait Typers extends Modes { val formals1 = formalTypes(formals0, args.length) if (sameLength(formals1, args)) { val args1 = typedArgs(args, mode, formals0, formals1) - if (!isFullyDefined(pt)) assert(false, tree+" ==> "+UnApply(fun1, args1)+", pt = "+pt) - val itype = glb(List(pt, arg.tpe)) - // restore old type (arg is a dummy tree, just needs to pass typechecking) - arg.tpe = oldArgType + assert(isFullyDefined(pt), tree+" ==> "+UnApply(fun1, args1)+", pt = "+pt) + + val itype = glb(List(pt, arg.tpe)) + arg.tpe = pt // restore type (arg is a dummy tree, just needs to pass typechecking) UnApply(fun1, args1) setPos tree.pos setType itype - } else { + } + else { errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun)) } } @@ -3136,14 +3141,20 @@ trait Typers extends Modes { ) { errorTree(tree, "return outside method definition") } else { - val DefDef(_, _, _, _, restpt, _) = enclMethod.tree - var restpt0 = restpt - if (restpt0.tpe eq null) { - errorTree(tree, "" + enclMethod.owner + - " has return statement; needs result type") - } else { + val DefDef(_, name, _, _, restpt, _) = enclMethod.tree + if (restpt.tpe eq null) + errorTree(tree, enclMethod.owner + " has return statement; needs result type") + else { context.enclMethod.returnsSeen = true - val expr1: Tree = typed(expr, EXPRmode | BYVALmode, restpt0.tpe) + val expr1: Tree = typed(expr, EXPRmode | BYVALmode, restpt.tpe) + // Warn about returning a value if no value can be returned. + if (restpt.tpe.typeSymbol == UnitClass) { + // The typing in expr1 says expr is Unit (it has already been coerced if + // it is non-Unit) so we have to retype it. Fortunately it won't come up much + // unless the warning is legitimate. + if (typed(expr).tpe.typeSymbol != UnitClass) + unit.warning(tree.pos, "enclosing method " + name + " has result type Unit: return value discarded") + } treeCopy.Return(tree, checkDead(expr1)) setSymbol enclMethod.owner setType NothingClass.tpe } } @@ -3890,7 +3901,7 @@ trait Typers extends Modes { case UnApply(fun, args) => val fun1 = typed(fun) val tpes = formalTypes(unapplyTypeList(fun.symbol, fun1.tpe), args.length) - val args1 = (args, tpes).zipped map (typedPattern(_, _)) + val args1 = (args, tpes).zipped map typedPattern treeCopy.UnApply(tree, fun1, args1) setType pt case ArrayValue(elemtpt, elems) => diff --git a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala index 086de23e90..998e1694cc 100644 --- a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala +++ b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala @@ -15,9 +15,9 @@ trait FreshNameCreator { def newName(): String def newName(prefix: String): String - @deprecated("use newName(prefix)") + @deprecated("use newName(prefix)", "2.9.0") def newName(pos: util.Position, prefix: String): String = newName(prefix) - @deprecated("use newName()") + @deprecated("use newName()", "2.9.0") def newName(pos: util.Position): String = newName() } diff --git a/src/compiler/scala/tools/nsc/util/Position.scala b/src/compiler/scala/tools/nsc/util/Position.scala index d296f45aed..49e9c12eb4 100644 --- a/src/compiler/scala/tools/nsc/util/Position.scala +++ b/src/compiler/scala/tools/nsc/util/Position.scala @@ -96,7 +96,7 @@ trait Position { /** The end of the position's range, or point if not a range position */ def endOrPoint: Int = point - @deprecated("use point instead") + @deprecated("use point instead", "2.9.0") def offset: Option[Int] = if (isDefined) Some(point) else None /** The same position with a different start value (if a range) */ diff --git a/src/compiler/scala/tools/nsc/util/Set.scala b/src/compiler/scala/tools/nsc/util/Set.scala index 108956321c..2bc2526b16 100644 --- a/src/compiler/scala/tools/nsc/util/Set.scala +++ b/src/compiler/scala/tools/nsc/util/Set.scala @@ -20,7 +20,7 @@ abstract class Set[T <: AnyRef] { def apply(x: T): Boolean = contains(x) - @deprecated("use `iterator' instead") def elements = iterator + @deprecated("use `iterator' instead", "2.9.0") def elements = iterator def contains(x: T): Boolean = findEntry(x) ne null diff --git a/src/dbc/scala/dbc/DataType.scala b/src/dbc/scala/dbc/DataType.scala index 3a485d317e..677621e0c0 100644 --- a/src/dbc/scala/dbc/DataType.scala +++ b/src/dbc/scala/dbc/DataType.scala @@ -14,7 +14,7 @@ package scala.dbc; /** An ISO-9075:2003 (SQL) data type. Mappings between SQL types and * database specific types should be provided by the database driver. */ -@deprecated(DbcIsDeprecated) abstract class DataType { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class DataType { /** Tests whether this datatype is equivalent to another. Usually, two * types are defined as equivalent if they are equal. Two types can be @@ -50,7 +50,7 @@ package scala.dbc; } -@deprecated(DbcIsDeprecated) object DataType { +@deprecated(DbcIsDeprecated, "2.9.0") object DataType { type Id = Int; diff --git a/src/dbc/scala/dbc/Database.scala b/src/dbc/scala/dbc/Database.scala index 86774292ea..2895f2cb29 100644 --- a/src/dbc/scala/dbc/Database.scala +++ b/src/dbc/scala/dbc/Database.scala @@ -18,7 +18,7 @@ import java.sql._ * * @author Gilles Dubochet */ -@deprecated(DbcIsDeprecated) case class Database(dbms: Vendor) { +@deprecated(DbcIsDeprecated, "2.9.0") case class Database(dbms: Vendor) { class Closed extends Exception {} diff --git a/src/dbc/scala/dbc/Syntax.scala b/src/dbc/scala/dbc/Syntax.scala index f8eb810ece..85cd1c1a1d 100644 --- a/src/dbc/scala/dbc/Syntax.scala +++ b/src/dbc/scala/dbc/Syntax.scala @@ -17,7 +17,7 @@ import java.math.{BigDecimal, BigInteger}; /** This class .. * */ -@deprecated(DbcIsDeprecated) object Syntax { +@deprecated(DbcIsDeprecated, "2.9.0") object Syntax { import syntax.DataTypeUtil; diff --git a/src/dbc/scala/dbc/Utilities.scala b/src/dbc/scala/dbc/Utilities.scala index d0f1300cb0..c37b1bb98d 100644 --- a/src/dbc/scala/dbc/Utilities.scala +++ b/src/dbc/scala/dbc/Utilities.scala @@ -15,7 +15,7 @@ package scala.dbc; * This object's members must be visible in an expression to use value * auto-conversion. */ -@deprecated(DbcIsDeprecated) object Utilities { +@deprecated(DbcIsDeprecated, "2.9.0") object Utilities { implicit def constantToValue (obj: statement.expression.Constant): Value = obj.constantValue; diff --git a/src/dbc/scala/dbc/Value.scala b/src/dbc/scala/dbc/Value.scala index 1dabec0377..a502f51cb5 100644 --- a/src/dbc/scala/dbc/Value.scala +++ b/src/dbc/scala/dbc/Value.scala @@ -12,7 +12,7 @@ package scala.dbc; /** A SQL-99 value of any type. */ -@deprecated(DbcIsDeprecated) abstract class Value { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Value { /** The SQL-99 type of the value. */ val dataType: DataType; diff --git a/src/dbc/scala/dbc/Vendor.scala b/src/dbc/scala/dbc/Vendor.scala index 2099430646..68f6102526 100644 --- a/src/dbc/scala/dbc/Vendor.scala +++ b/src/dbc/scala/dbc/Vendor.scala @@ -16,7 +16,7 @@ import java.sql.{Connection, Driver}; /** This class .. */ -@deprecated(DbcIsDeprecated) abstract class Vendor { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Vendor { def nativeDriverClass: Class[_]; def uri: java.net.URI; diff --git a/src/dbc/scala/dbc/datatype/ApproximateNumeric.scala b/src/dbc/scala/dbc/datatype/ApproximateNumeric.scala index 1be836039f..31752e18c7 100644 --- a/src/dbc/scala/dbc/datatype/ApproximateNumeric.scala +++ b/src/dbc/scala/dbc/datatype/ApproximateNumeric.scala @@ -15,7 +15,7 @@ package datatype; /** A type category for all SQL types that store varying-precision * numbers. */ -@deprecated(DbcIsDeprecated) abstract class ApproximateNumeric[Type] ( +@deprecated(DbcIsDeprecated, "2.9.0") abstract class ApproximateNumeric[Type] ( override val nativeTypeId: DataType.Id ) extends datatype.Numeric[Type](nativeTypeId) { diff --git a/src/dbc/scala/dbc/datatype/Boolean.scala b/src/dbc/scala/dbc/datatype/Boolean.scala index 89498f3d9e..4a32ce98f1 100644 --- a/src/dbc/scala/dbc/datatype/Boolean.scala +++ b/src/dbc/scala/dbc/datatype/Boolean.scala @@ -13,7 +13,7 @@ package datatype; /** The SQL type for a truth value. */ -@deprecated(DbcIsDeprecated) class Boolean extends DataType { +@deprecated(DbcIsDeprecated, "2.9.0") class Boolean extends DataType { def isEquivalent (datatype:DataType) = datatype match { case dt:Boolean => true diff --git a/src/dbc/scala/dbc/datatype/Character.scala b/src/dbc/scala/dbc/datatype/Character.scala index e3b57a230b..02dec06281 100644 --- a/src/dbc/scala/dbc/datatype/Character.scala +++ b/src/dbc/scala/dbc/datatype/Character.scala @@ -15,7 +15,7 @@ package datatype; /** A SQL type for a string of characters of arbitrary length with * arbitrary character set. */ -@deprecated(DbcIsDeprecated) abstract class Character extends CharacterString { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Character extends CharacterString { def isEquivalent(datatype: DataType) = datatype match { case dt: Character => diff --git a/src/dbc/scala/dbc/datatype/CharacterLargeObject.scala b/src/dbc/scala/dbc/datatype/CharacterLargeObject.scala index ba25acb87c..2c7ef64d66 100644 --- a/src/dbc/scala/dbc/datatype/CharacterLargeObject.scala +++ b/src/dbc/scala/dbc/datatype/CharacterLargeObject.scala @@ -14,7 +14,7 @@ package datatype; /** A SQL type for an unbounded length string of characters with arbitrary * character set. */ -@deprecated(DbcIsDeprecated) class CharacterLargeObject extends CharacterString { +@deprecated(DbcIsDeprecated, "2.9.0") class CharacterLargeObject extends CharacterString { def isEquivalent (datatype:DataType) = datatype match { case dt:CharacterLargeObject => { diff --git a/src/dbc/scala/dbc/datatype/CharacterString.scala b/src/dbc/scala/dbc/datatype/CharacterString.scala index 11ad6ed5e5..54d6e0111f 100644 --- a/src/dbc/scala/dbc/datatype/CharacterString.scala +++ b/src/dbc/scala/dbc/datatype/CharacterString.scala @@ -13,7 +13,7 @@ package datatype; /** A type category for all SQL types that store strings of characters. */ -@deprecated(DbcIsDeprecated) abstract class CharacterString extends String { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class CharacterString extends String { type NativeType = java.lang.String; val nativeTypeId = DataType.STRING; diff --git a/src/dbc/scala/dbc/datatype/CharacterVarying.scala b/src/dbc/scala/dbc/datatype/CharacterVarying.scala index 5951aa07d4..9df487579f 100644 --- a/src/dbc/scala/dbc/datatype/CharacterVarying.scala +++ b/src/dbc/scala/dbc/datatype/CharacterVarying.scala @@ -15,7 +15,7 @@ package datatype; /** A SQL type for a varying length string of characters with arbitrary * maximal length and arbitrary character set. */ -@deprecated(DbcIsDeprecated) abstract class CharacterVarying extends CharacterString { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class CharacterVarying extends CharacterString { def isEquivalent(datatype: DataType) = datatype match { case dt: CharacterVarying => diff --git a/src/dbc/scala/dbc/datatype/ExactNumeric.scala b/src/dbc/scala/dbc/datatype/ExactNumeric.scala index b41486c2bc..a578846977 100644 --- a/src/dbc/scala/dbc/datatype/ExactNumeric.scala +++ b/src/dbc/scala/dbc/datatype/ExactNumeric.scala @@ -15,7 +15,7 @@ package datatype; /** A type category for all SQL types that store constant-precision * numbers. */ -@deprecated(DbcIsDeprecated) abstract class ExactNumeric[Type]( +@deprecated(DbcIsDeprecated, "2.9.0") abstract class ExactNumeric[Type]( override val nativeTypeId: DataType.Id ) extends datatype.Numeric[Type](nativeTypeId) { diff --git a/src/dbc/scala/dbc/datatype/Factory.scala b/src/dbc/scala/dbc/datatype/Factory.scala index eef5f1d0d3..bb9b3f5b61 100644 --- a/src/dbc/scala/dbc/datatype/Factory.scala +++ b/src/dbc/scala/dbc/datatype/Factory.scala @@ -16,7 +16,7 @@ import java.sql.Types._; import java.math.BigInteger; import java.math.BigDecimal; -@deprecated(DbcIsDeprecated) object Factory { +@deprecated(DbcIsDeprecated, "2.9.0") object Factory { final val java_lang_Integer_SIZE = 32; final val java_lang_Long_SIZE = 64; diff --git a/src/dbc/scala/dbc/datatype/Numeric.scala b/src/dbc/scala/dbc/datatype/Numeric.scala index c5a3482a7d..c13f454dde 100644 --- a/src/dbc/scala/dbc/datatype/Numeric.scala +++ b/src/dbc/scala/dbc/datatype/Numeric.scala @@ -13,7 +13,7 @@ package datatype; /** A type category for all SQL types that store numbers. */ -@deprecated(DbcIsDeprecated) abstract class Numeric[Type](_nativeTypeId: DataType.Id) extends DataType { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Numeric[Type](_nativeTypeId: DataType.Id) extends DataType { type NativeType = Type; val nativeTypeId = _nativeTypeId; diff --git a/src/dbc/scala/dbc/datatype/String.scala b/src/dbc/scala/dbc/datatype/String.scala index 85db4e471d..291504f777 100644 --- a/src/dbc/scala/dbc/datatype/String.scala +++ b/src/dbc/scala/dbc/datatype/String.scala @@ -14,7 +14,7 @@ package datatype; /** A type category for all SQL types that store strings of elements. */ -@deprecated(DbcIsDeprecated) abstract class String extends DataType { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class String extends DataType { /** The maximal possible length of the string defined in characters. * This is an implementation-specific value. diff --git a/src/dbc/scala/dbc/datatype/Unknown.scala b/src/dbc/scala/dbc/datatype/Unknown.scala index ee7a6a15fc..14a33c6be9 100644 --- a/src/dbc/scala/dbc/datatype/Unknown.scala +++ b/src/dbc/scala/dbc/datatype/Unknown.scala @@ -13,7 +13,7 @@ package datatype; /** The SQL type for a truth value. */ -@deprecated(DbcIsDeprecated) class Unknown extends DataType { +@deprecated(DbcIsDeprecated, "2.9.0") class Unknown extends DataType { def isEquivalent(datatype: DataType) = datatype match { case dt: Unknown => diff --git a/src/dbc/scala/dbc/exception/IncompatibleSchema.scala b/src/dbc/scala/dbc/exception/IncompatibleSchema.scala index 4e21daba07..c8d53bbf1a 100644 --- a/src/dbc/scala/dbc/exception/IncompatibleSchema.scala +++ b/src/dbc/scala/dbc/exception/IncompatibleSchema.scala @@ -13,7 +13,7 @@ package exception /** A type category for all SQL types that store constant-precision numbers. */ -@deprecated(DbcIsDeprecated) case class IncompatibleSchema ( +@deprecated(DbcIsDeprecated, "2.9.0") case class IncompatibleSchema ( expectedSchema: List[DataType], foundSchema: List[DataType] ) extends Exception; diff --git a/src/dbc/scala/dbc/exception/UnsupportedFeature.scala b/src/dbc/scala/dbc/exception/UnsupportedFeature.scala index 1f286c5bbd..dd6f904077 100644 --- a/src/dbc/scala/dbc/exception/UnsupportedFeature.scala +++ b/src/dbc/scala/dbc/exception/UnsupportedFeature.scala @@ -13,4 +13,4 @@ package exception /** A type category for all SQL types that store constant-precision numbers. */ -@deprecated(DbcIsDeprecated) case class UnsupportedFeature (msg: String) extends Exception; +@deprecated(DbcIsDeprecated, "2.9.0") case class UnsupportedFeature (msg: String) extends Exception; diff --git a/src/dbc/scala/dbc/result/Field.scala b/src/dbc/scala/dbc/result/Field.scala index 08acbf010c..cd3309bb14 100644 --- a/src/dbc/scala/dbc/result/Field.scala +++ b/src/dbc/scala/dbc/result/Field.scala @@ -16,7 +16,7 @@ import scala.dbc.datatype._ import scala.dbc.value._ /** An ISO-9075:2003 (SQL) table field. */ -@deprecated(DbcIsDeprecated) abstract class Field { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Field { /** The content (value) of the field. The type of this value is undefined, * transformation into a useful type will be done by an automatic view @@ -56,7 +56,7 @@ import scala.dbc.value._ } -@deprecated(DbcIsDeprecated) object Field { +@deprecated(DbcIsDeprecated, "2.9.0") object Field { implicit def fieldToValue (field: Field): Value = field.content diff --git a/src/dbc/scala/dbc/result/FieldMetadata.scala b/src/dbc/scala/dbc/result/FieldMetadata.scala index f0ec7cf9eb..3c2de297d0 100644 --- a/src/dbc/scala/dbc/result/FieldMetadata.scala +++ b/src/dbc/scala/dbc/result/FieldMetadata.scala @@ -15,7 +15,7 @@ package result /** The class <code>FieldMetadata</cocde> provides informations attached to * a field about its content and its relationship to the originating database. */ -@deprecated(DbcIsDeprecated) abstract class FieldMetadata { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class FieldMetadata { /** The name of the field. */ def name: String diff --git a/src/dbc/scala/dbc/result/Relation.scala b/src/dbc/scala/dbc/result/Relation.scala index ef4c3e4ad1..4897cd1030 100644 --- a/src/dbc/scala/dbc/result/Relation.scala +++ b/src/dbc/scala/dbc/result/Relation.scala @@ -14,7 +14,7 @@ package result /** An ISO-9075:2003 (SQL) table. This is equivalent to a relation in the * relational model. */ -@deprecated(DbcIsDeprecated) abstract class Relation extends AnyRef with Iterable[Tuple] { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Relation extends AnyRef with Iterable[Tuple] { /** The statement that generated this relation. */ def statement: scala.dbc.statement.Relation diff --git a/src/dbc/scala/dbc/result/Status.scala b/src/dbc/scala/dbc/result/Status.scala index 91ca9131b7..d3152a58ab 100644 --- a/src/dbc/scala/dbc/result/Status.scala +++ b/src/dbc/scala/dbc/result/Status.scala @@ -15,7 +15,7 @@ package result; import scala.dbc.datatype._; /** An object containing the status of a query */ -@deprecated(DbcIsDeprecated) abstract class Status[ResultType] { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Status[ResultType] { /** The statement that generated this status result. */ def statement: scala.dbc.statement.Statement; diff --git a/src/dbc/scala/dbc/result/Tuple.scala b/src/dbc/scala/dbc/result/Tuple.scala index 90149c4905..80ab5c22aa 100644 --- a/src/dbc/scala/dbc/result/Tuple.scala +++ b/src/dbc/scala/dbc/result/Tuple.scala @@ -13,7 +13,7 @@ package result; /** An ISO-9075:2003 (SQL) table row. This is equivalent to a tuple in the relational model. */ -@deprecated(DbcIsDeprecated) abstract class Tuple { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Tuple { /** All the fields contained in the tuple. */ def fields: List[Field]; diff --git a/src/dbc/scala/dbc/statement/AccessMode.scala b/src/dbc/scala/dbc/statement/AccessMode.scala index 35c76981e1..885e0012f2 100644 --- a/src/dbc/scala/dbc/statement/AccessMode.scala +++ b/src/dbc/scala/dbc/statement/AccessMode.scala @@ -12,11 +12,11 @@ package scala.dbc package statement -@deprecated(DbcIsDeprecated) abstract class AccessMode { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class AccessMode { def sqlString: String } -@deprecated(DbcIsDeprecated) object AccessMode { +@deprecated(DbcIsDeprecated, "2.9.0") object AccessMode { case object ReadOnly extends AccessMode { def sqlString = "READ ONLY" } diff --git a/src/dbc/scala/dbc/statement/DerivedColumn.scala b/src/dbc/scala/dbc/statement/DerivedColumn.scala index 61ba5a0224..ae05df986a 100644 --- a/src/dbc/scala/dbc/statement/DerivedColumn.scala +++ b/src/dbc/scala/dbc/statement/DerivedColumn.scala @@ -12,7 +12,7 @@ package scala.dbc package statement -@deprecated(DbcIsDeprecated) abstract class DerivedColumn { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class DerivedColumn { /** The value for the column. This value can be of any type but must be * calculated from fields that appear in a relation that takes part diff --git a/src/dbc/scala/dbc/statement/Expression.scala b/src/dbc/scala/dbc/statement/Expression.scala index 9cd04dfb98..c2da91e9ef 100644 --- a/src/dbc/scala/dbc/statement/Expression.scala +++ b/src/dbc/scala/dbc/statement/Expression.scala @@ -13,7 +13,7 @@ package statement /** An expression that calculates some value from fields. */ -@deprecated(DbcIsDeprecated) abstract class Expression extends Relation { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Expression extends Relation { def fieldTypes: List[DataType] = Nil diff --git a/src/dbc/scala/dbc/statement/Insert.scala b/src/dbc/scala/dbc/statement/Insert.scala index f2f06e27ee..189ccec54f 100644 --- a/src/dbc/scala/dbc/statement/Insert.scala +++ b/src/dbc/scala/dbc/statement/Insert.scala @@ -15,7 +15,7 @@ package statement import scala.dbc.statement.expression._ /** An insertion of values into a table. */ -@deprecated(DbcIsDeprecated) case class Insert(insertionTarget: String, insertionData: InsertionData) +@deprecated(DbcIsDeprecated, "2.9.0") case class Insert(insertionTarget: String, insertionData: InsertionData) extends Status { /** A SQL-99 compliant string representation of the select statement. */ diff --git a/src/dbc/scala/dbc/statement/InsertionData.scala b/src/dbc/scala/dbc/statement/InsertionData.scala index 9ba729b645..e91ad7efe6 100644 --- a/src/dbc/scala/dbc/statement/InsertionData.scala +++ b/src/dbc/scala/dbc/statement/InsertionData.scala @@ -15,17 +15,17 @@ package statement import scala.dbc.statement.expression._ /** Data to be inserted into a table in an <code>Insert</code>. */ -@deprecated(DbcIsDeprecated) abstract class InsertionData { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class InsertionData { def sqlString: String } -@deprecated(DbcIsDeprecated) object InsertionData { +@deprecated(DbcIsDeprecated, "2.9.0") object InsertionData { /** Insertion of data resulting from a query on the database. */ - @deprecated(DbcIsDeprecated) case class Subquery(query: Relation) extends InsertionData { + @deprecated(DbcIsDeprecated, "2.9.0") case class Subquery(query: Relation) extends InsertionData { def sqlString = query.sqlString } /** Insertion of data as explicitly defined values. */ - @deprecated(DbcIsDeprecated) case class Constructor( + @deprecated(DbcIsDeprecated, "2.9.0") case class Constructor( columnNames: Option[List[String]], columnValues: List[Expression] ) extends InsertionData { diff --git a/src/dbc/scala/dbc/statement/IsolationLevel.scala b/src/dbc/scala/dbc/statement/IsolationLevel.scala index 2185393316..b31614c3dd 100644 --- a/src/dbc/scala/dbc/statement/IsolationLevel.scala +++ b/src/dbc/scala/dbc/statement/IsolationLevel.scala @@ -12,11 +12,11 @@ package scala.dbc package statement -@deprecated(DbcIsDeprecated) abstract class IsolationLevel { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class IsolationLevel { def sqlString: String } -@deprecated(DbcIsDeprecated) object IsolationLevel { +@deprecated(DbcIsDeprecated, "2.9.0") object IsolationLevel { case object ReadUncommitted extends IsolationLevel { def sqlString = "ISOLATION LEVEL READ UNCOMMITTED" } diff --git a/src/dbc/scala/dbc/statement/JoinType.scala b/src/dbc/scala/dbc/statement/JoinType.scala index 68e6168867..698612b10d 100644 --- a/src/dbc/scala/dbc/statement/JoinType.scala +++ b/src/dbc/scala/dbc/statement/JoinType.scala @@ -13,12 +13,12 @@ package statement /** A join behaviour in a <code>Jointure</code>. */ -@deprecated(DbcIsDeprecated) abstract class JoinType { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class JoinType { /** A SQL-99 string representation of the join behaviour. */ def sqlString: String } -@deprecated(DbcIsDeprecated) object JoinType { +@deprecated(DbcIsDeprecated, "2.9.0") object JoinType { /** A join behaviour where a joined tuple is created only when a * corresponding tuple exists in both original relations. diff --git a/src/dbc/scala/dbc/statement/Jointure.scala b/src/dbc/scala/dbc/statement/Jointure.scala index 40d9f1e24a..74c871cc3e 100644 --- a/src/dbc/scala/dbc/statement/Jointure.scala +++ b/src/dbc/scala/dbc/statement/Jointure.scala @@ -13,7 +13,7 @@ package statement /** A jointure between two relations. */ -@deprecated(DbcIsDeprecated) abstract class Jointure extends Relation { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Jointure extends Relation { /** The relation on the left part of the join. */ def leftRelation: Relation diff --git a/src/dbc/scala/dbc/statement/Relation.scala b/src/dbc/scala/dbc/statement/Relation.scala index ce617f0f75..787707ee82 100644 --- a/src/dbc/scala/dbc/statement/Relation.scala +++ b/src/dbc/scala/dbc/statement/Relation.scala @@ -13,7 +13,7 @@ package statement; /** A statement that returns a relation. */ -@deprecated(DbcIsDeprecated) abstract class Relation extends Statement { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Relation extends Statement { def isCompatibleType: (DataType,DataType)=>Boolean = ((dt,wdt)=>dt.isSubtypeOf(wdt)); diff --git a/src/dbc/scala/dbc/statement/Select.scala b/src/dbc/scala/dbc/statement/Select.scala index f75cd22082..a9ca0212ed 100644 --- a/src/dbc/scala/dbc/statement/Select.scala +++ b/src/dbc/scala/dbc/statement/Select.scala @@ -15,7 +15,7 @@ package statement /** A statement that when executed on a database will return a relation. * The returned relation will be a subset of a table in the database or * a jointure between such subsets. */ -@deprecated(DbcIsDeprecated) abstract class Select extends Relation { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Select extends Relation { /** Defines if duplicated tuples should be removed from the returned * relation. <h3>Compatibility notice</h3> Some DBMS (PostgreSQL) allow diff --git a/src/dbc/scala/dbc/statement/SetClause.scala b/src/dbc/scala/dbc/statement/SetClause.scala index 4818fdda2a..3af509c026 100644 --- a/src/dbc/scala/dbc/statement/SetClause.scala +++ b/src/dbc/scala/dbc/statement/SetClause.scala @@ -15,7 +15,7 @@ package statement import scala.dbc.statement.expression._ /** Data to be inserted into a table in an <code>Insert</code>. */ -@deprecated(DbcIsDeprecated) case class SetClause(name: String, expr: Expression) { +@deprecated(DbcIsDeprecated, "2.9.0") case class SetClause(name: String, expr: Expression) { val value: Pair[String,Expression] = (name, expr) def sqlString: String = value._1 + " = " + value._2.sqlInnerString } diff --git a/src/dbc/scala/dbc/statement/SetQuantifier.scala b/src/dbc/scala/dbc/statement/SetQuantifier.scala index 62245d74fd..77a4b79b8d 100644 --- a/src/dbc/scala/dbc/statement/SetQuantifier.scala +++ b/src/dbc/scala/dbc/statement/SetQuantifier.scala @@ -13,12 +13,12 @@ package statement /** A set quantifier that defines the collection type of a relation. */ -@deprecated(DbcIsDeprecated) abstract class SetQuantifier { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class SetQuantifier { /** A SQL-99 compliant string representation of the set quantifier. */ def sqlString: String } -@deprecated(DbcIsDeprecated) object SetQuantifier { +@deprecated(DbcIsDeprecated, "2.9.0") object SetQuantifier { /** A set quantifier that defines a relation as being a bag. That means * that duplicates are allowed. diff --git a/src/dbc/scala/dbc/statement/Statement.scala b/src/dbc/scala/dbc/statement/Statement.scala index ad69f5b11f..fc5374262d 100644 --- a/src/dbc/scala/dbc/statement/Statement.scala +++ b/src/dbc/scala/dbc/statement/Statement.scala @@ -13,4 +13,4 @@ package statement /** An ISO-9075:2003 (SQL) statement. */ -@deprecated(DbcIsDeprecated) abstract class Statement +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Statement diff --git a/src/dbc/scala/dbc/statement/Status.scala b/src/dbc/scala/dbc/statement/Status.scala index e1f358077d..0ce64b978d 100644 --- a/src/dbc/scala/dbc/statement/Status.scala +++ b/src/dbc/scala/dbc/statement/Status.scala @@ -15,7 +15,7 @@ import scala.dbc.Database import scala.dbc.result /** A statement that changes the status of the database. */ -@deprecated(DbcIsDeprecated) abstract class Status extends Statement { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Status extends Statement { /** A SQL-99 compliant string representation of the statement. */ def sqlString: String diff --git a/src/dbc/scala/dbc/statement/Table.scala b/src/dbc/scala/dbc/statement/Table.scala index b88f4c1af8..e729f801a3 100644 --- a/src/dbc/scala/dbc/statement/Table.scala +++ b/src/dbc/scala/dbc/statement/Table.scala @@ -15,7 +15,7 @@ package statement /** A reference to a table in the database. * @author Gilles Dubochet * @version 1.0 */ -@deprecated(DbcIsDeprecated) abstract class Table extends Relation { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Table extends Relation { /** The name of the table in the database. */ def tableName: String diff --git a/src/dbc/scala/dbc/statement/Transaction.scala b/src/dbc/scala/dbc/statement/Transaction.scala index a94b509885..1740dae3f9 100644 --- a/src/dbc/scala/dbc/statement/Transaction.scala +++ b/src/dbc/scala/dbc/statement/Transaction.scala @@ -13,7 +13,7 @@ package statement; /** A statement that changes the status of the database. */ -@deprecated(DbcIsDeprecated) case class Transaction [ResultType] ( +@deprecated(DbcIsDeprecated, "2.9.0") case class Transaction [ResultType] ( transactionBody: (scala.dbc.Database=>ResultType), accessMode: Option[AccessMode], isolationLevel: Option[IsolationLevel] diff --git a/src/dbc/scala/dbc/statement/Update.scala b/src/dbc/scala/dbc/statement/Update.scala index 918bfae3cd..836549a4be 100644 --- a/src/dbc/scala/dbc/statement/Update.scala +++ b/src/dbc/scala/dbc/statement/Update.scala @@ -15,7 +15,7 @@ package statement; import scala.dbc.statement.expression._; /** An update of the state of a table. */ -@deprecated(DbcIsDeprecated) case class Update ( +@deprecated(DbcIsDeprecated, "2.9.0") case class Update ( updateTarget: String, setClauses: List[SetClause], whereClause: Option[Expression] diff --git a/src/dbc/scala/dbc/statement/expression/Aggregate.scala b/src/dbc/scala/dbc/statement/expression/Aggregate.scala index 02225b5cfa..c42bffe20e 100644 --- a/src/dbc/scala/dbc/statement/expression/Aggregate.scala +++ b/src/dbc/scala/dbc/statement/expression/Aggregate.scala @@ -13,7 +13,7 @@ package statement package expression -@deprecated(DbcIsDeprecated) abstract class Aggregate extends Expression { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Aggregate extends Expression { def aggregateName: String; diff --git a/src/dbc/scala/dbc/statement/expression/BinaryOperator.scala b/src/dbc/scala/dbc/statement/expression/BinaryOperator.scala index 7a52e10537..32f016dbf6 100644 --- a/src/dbc/scala/dbc/statement/expression/BinaryOperator.scala +++ b/src/dbc/scala/dbc/statement/expression/BinaryOperator.scala @@ -13,7 +13,7 @@ package statement package expression; -@deprecated(DbcIsDeprecated) abstract class BinaryOperator extends Expression { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class BinaryOperator extends Expression { /** The name of the operator. */ def operator: String; diff --git a/src/dbc/scala/dbc/statement/expression/Constant.scala b/src/dbc/scala/dbc/statement/expression/Constant.scala index ae12917f65..70ec7819dc 100644 --- a/src/dbc/scala/dbc/statement/expression/Constant.scala +++ b/src/dbc/scala/dbc/statement/expression/Constant.scala @@ -13,7 +13,7 @@ package statement package expression; -@deprecated(DbcIsDeprecated) abstract class Constant extends Expression { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Constant extends Expression { /** A SQL-99 compliant string representation of the relation sub- * statement. This only has a meaning inside another statement. */ def sqlInnerString: String = constantValue.sqlString; diff --git a/src/dbc/scala/dbc/statement/expression/Field.scala b/src/dbc/scala/dbc/statement/expression/Field.scala index 57177d9ab9..9a90903a99 100644 --- a/src/dbc/scala/dbc/statement/expression/Field.scala +++ b/src/dbc/scala/dbc/statement/expression/Field.scala @@ -13,7 +13,7 @@ package statement package expression; -@deprecated(DbcIsDeprecated) abstract class Field extends Expression { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Field extends Expression { /** The name of the schema in the database where the field is located. */ def schemaName: Option[String] = None; diff --git a/src/dbc/scala/dbc/statement/expression/FunctionCall.scala b/src/dbc/scala/dbc/statement/expression/FunctionCall.scala index 9c2f412413..962cf209b9 100644 --- a/src/dbc/scala/dbc/statement/expression/FunctionCall.scala +++ b/src/dbc/scala/dbc/statement/expression/FunctionCall.scala @@ -13,7 +13,7 @@ package statement package expression; -@deprecated(DbcIsDeprecated) case class FunctionCall ( +@deprecated(DbcIsDeprecated, "2.9.0") case class FunctionCall ( functionName: String, arguments: List[Expression] ) extends Expression { diff --git a/src/dbc/scala/dbc/statement/expression/Select.scala b/src/dbc/scala/dbc/statement/expression/Select.scala index 24b46f2d3d..7a6a4a21c4 100644 --- a/src/dbc/scala/dbc/statement/expression/Select.scala +++ b/src/dbc/scala/dbc/statement/expression/Select.scala @@ -13,7 +13,7 @@ package statement package expression; -@deprecated(DbcIsDeprecated) abstract class Select extends Expression { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Select extends Expression { /** The actual select statement */ def selectStatement: statement.Select; diff --git a/src/dbc/scala/dbc/statement/expression/SetFunction.scala b/src/dbc/scala/dbc/statement/expression/SetFunction.scala index 07bd94ada7..060b2236f2 100644 --- a/src/dbc/scala/dbc/statement/expression/SetFunction.scala +++ b/src/dbc/scala/dbc/statement/expression/SetFunction.scala @@ -13,12 +13,12 @@ package statement package expression; -@deprecated(DbcIsDeprecated) abstract class SetFunction { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class SetFunction { /** A SQL-99 compliant string representation of the set quantifier. */ def sqlString: String; } -@deprecated(DbcIsDeprecated) object SetFunction { +@deprecated(DbcIsDeprecated, "2.9.0") object SetFunction { abstract class Asterisk extends SetFunction { def sqlString = "(*)"; } diff --git a/src/dbc/scala/dbc/statement/expression/TypeCast.scala b/src/dbc/scala/dbc/statement/expression/TypeCast.scala index 54ef99ebc0..dbb8dc1b4d 100644 --- a/src/dbc/scala/dbc/statement/expression/TypeCast.scala +++ b/src/dbc/scala/dbc/statement/expression/TypeCast.scala @@ -13,7 +13,7 @@ package statement package expression; -@deprecated(DbcIsDeprecated) case class TypeCast ( +@deprecated(DbcIsDeprecated, "2.9.0") case class TypeCast ( expression: Expression, castType: DataType ) extends Expression { diff --git a/src/dbc/scala/dbc/statement/expression/UnaryOperator.scala b/src/dbc/scala/dbc/statement/expression/UnaryOperator.scala index 29f01f702b..4172c451fb 100644 --- a/src/dbc/scala/dbc/statement/expression/UnaryOperator.scala +++ b/src/dbc/scala/dbc/statement/expression/UnaryOperator.scala @@ -13,7 +13,7 @@ package statement package expression; -@deprecated(DbcIsDeprecated) abstract class UnaryOperator extends Expression { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class UnaryOperator extends Expression { /** The name of the operator */ def operator: String; diff --git a/src/dbc/scala/dbc/syntax/DataTypeUtil.scala b/src/dbc/scala/dbc/syntax/DataTypeUtil.scala index 573337d01c..a0ebd1713e 100644 --- a/src/dbc/scala/dbc/syntax/DataTypeUtil.scala +++ b/src/dbc/scala/dbc/syntax/DataTypeUtil.scala @@ -15,7 +15,7 @@ package syntax; import java.math.BigDecimal; import java.math.BigInteger; -@deprecated(DbcIsDeprecated) object DataTypeUtil { +@deprecated(DbcIsDeprecated, "2.9.0") object DataTypeUtil { final val java_lang_Integer_SIZE = 32; final val java_lang_Long_SIZE = 64; diff --git a/src/dbc/scala/dbc/syntax/Database.scala b/src/dbc/scala/dbc/syntax/Database.scala index 1fbaaf8210..4357fb7d4c 100644 --- a/src/dbc/scala/dbc/syntax/Database.scala +++ b/src/dbc/scala/dbc/syntax/Database.scala @@ -14,7 +14,7 @@ package syntax; import java.net.URI; -@deprecated(DbcIsDeprecated) object Database { +@deprecated(DbcIsDeprecated, "2.9.0") object Database { def database (server:String, username:String, password:String): dbc.Database = { val uri = new URI(server); diff --git a/src/dbc/scala/dbc/syntax/Statement.scala b/src/dbc/scala/dbc/syntax/Statement.scala index 21294a2f87..baccbfaa64 100644 --- a/src/dbc/scala/dbc/syntax/Statement.scala +++ b/src/dbc/scala/dbc/syntax/Statement.scala @@ -31,7 +31,7 @@ FIXED: */ -@deprecated(DbcIsDeprecated) object Statement { +@deprecated(DbcIsDeprecated, "2.9.0") object Statement { // SELECT ZYGOTE ... diff --git a/src/dbc/scala/dbc/syntax/StatementExpression.scala b/src/dbc/scala/dbc/syntax/StatementExpression.scala index 60211df3aa..65bb0947f7 100644 --- a/src/dbc/scala/dbc/syntax/StatementExpression.scala +++ b/src/dbc/scala/dbc/syntax/StatementExpression.scala @@ -15,7 +15,7 @@ package syntax; import java.math.BigDecimal; import java.math.BigInteger; -@deprecated(DbcIsDeprecated) abstract class StatementExpression { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class StatementExpression { def toStatement: statement.Expression; @@ -171,7 +171,7 @@ import java.math.BigInteger; } -@deprecated(DbcIsDeprecated) object StatementExpression { +@deprecated(DbcIsDeprecated, "2.9.0") object StatementExpression { def not (se:StatementExpression): StatementExpression = new StatementExpression { val toStatement = new statement.expression.UnaryOperator { diff --git a/src/dbc/scala/dbc/value/ApproximateNumeric.scala b/src/dbc/scala/dbc/value/ApproximateNumeric.scala index 435da796c5..fa47d8815b 100644 --- a/src/dbc/scala/dbc/value/ApproximateNumeric.scala +++ b/src/dbc/scala/dbc/value/ApproximateNumeric.scala @@ -12,7 +12,7 @@ package scala.dbc package value; -@deprecated(DbcIsDeprecated) abstract class ApproximateNumeric [Type] extends Value { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class ApproximateNumeric [Type] extends Value { val dataType: datatype.ApproximateNumeric[Type]; @@ -20,7 +20,7 @@ package value; } -@deprecated(DbcIsDeprecated) object ApproximateNumeric { +@deprecated(DbcIsDeprecated, "2.9.0") object ApproximateNumeric { implicit def approximateNumericToFloar (obj:value.ApproximateNumeric[Float]): Float = obj.nativeValue; implicit def approximateNumericToDouble (obj:value.ApproximateNumeric[Double]): Double = obj.nativeValue; diff --git a/src/dbc/scala/dbc/value/Boolean.scala b/src/dbc/scala/dbc/value/Boolean.scala index 399c3a3450..5221ce2328 100644 --- a/src/dbc/scala/dbc/value/Boolean.scala +++ b/src/dbc/scala/dbc/value/Boolean.scala @@ -12,7 +12,7 @@ package scala.dbc package value; -@deprecated(DbcIsDeprecated) abstract class Boolean extends Value { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Boolean extends Value { val dataType: datatype.Boolean; @@ -20,7 +20,7 @@ package value; } -@deprecated(DbcIsDeprecated) object Boolean { +@deprecated(DbcIsDeprecated, "2.9.0") object Boolean { implicit def booleanToBoolean (obj:value.Boolean): scala.Boolean = obj.nativeValue; diff --git a/src/dbc/scala/dbc/value/Character.scala b/src/dbc/scala/dbc/value/Character.scala index e328bb2edc..4ff983c591 100644 --- a/src/dbc/scala/dbc/value/Character.scala +++ b/src/dbc/scala/dbc/value/Character.scala @@ -13,7 +13,7 @@ package value; /** A SQL-99 value of type character string. */ -@deprecated(DbcIsDeprecated) abstract class Character extends Value { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Character extends Value { override val dataType: datatype.Character; @@ -27,7 +27,7 @@ package value; /** An object offering transformation methods (views) on the value. * This object must be visible in an expression to use value auto- * conversion. */ -@deprecated(DbcIsDeprecated) object Character { +@deprecated(DbcIsDeprecated, "2.9.0") object Character { /** A character string value as a native string. */ implicit def characterToString (obj:value.Character): String = obj.nativeValue; diff --git a/src/dbc/scala/dbc/value/CharacterLargeObject.scala b/src/dbc/scala/dbc/value/CharacterLargeObject.scala index 19ceaeee59..b9e81eb3af 100644 --- a/src/dbc/scala/dbc/value/CharacterLargeObject.scala +++ b/src/dbc/scala/dbc/value/CharacterLargeObject.scala @@ -13,7 +13,7 @@ package value; /** A SQL-99 value of type character large object. */ -@deprecated(DbcIsDeprecated) abstract class CharacterLargeObject extends Value { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class CharacterLargeObject extends Value { override val dataType: datatype.CharacterLargeObject; @@ -27,7 +27,7 @@ package value; /** An object offering transformation methods (views) on the value. * This object must be visible in an expression to use value auto- * conversion. */ -@deprecated(DbcIsDeprecated) object CharacterLargeObject { +@deprecated(DbcIsDeprecated, "2.9.0") object CharacterLargeObject { /** A character large object value as a native string. */ implicit def characterLargeObjectToString (obj:value.CharacterLargeObject): String = obj.nativeValue; diff --git a/src/dbc/scala/dbc/value/CharacterVarying.scala b/src/dbc/scala/dbc/value/CharacterVarying.scala index d114a28b07..72e7d06362 100644 --- a/src/dbc/scala/dbc/value/CharacterVarying.scala +++ b/src/dbc/scala/dbc/value/CharacterVarying.scala @@ -13,7 +13,7 @@ package value; /** A SQL-99 value of type character varying string. */ -@deprecated(DbcIsDeprecated) abstract class CharacterVarying extends Value { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class CharacterVarying extends Value { override val dataType: datatype.CharacterVarying; @@ -27,7 +27,7 @@ package value; /** An object offering transformation methods (views) on the value. * This object must be visible in an expression to use value auto- * conversion. */ -@deprecated(DbcIsDeprecated) object CharacterVarying { +@deprecated(DbcIsDeprecated, "2.9.0") object CharacterVarying { /** A character varying string value as a native string. */ implicit def characterVaryingToString (obj:value.CharacterVarying): String = obj.nativeValue; diff --git a/src/dbc/scala/dbc/value/Conversion.scala b/src/dbc/scala/dbc/value/Conversion.scala index 5b3d3ef7af..c9297e37db 100644 --- a/src/dbc/scala/dbc/value/Conversion.scala +++ b/src/dbc/scala/dbc/value/Conversion.scala @@ -13,7 +13,7 @@ package value; import java.math._; -@deprecated(DbcIsDeprecated) object Conversion { +@deprecated(DbcIsDeprecated, "2.9.0") object Conversion { class Illegal (msg:String) extends Exception(msg); diff --git a/src/dbc/scala/dbc/value/ExactNumeric.scala b/src/dbc/scala/dbc/value/ExactNumeric.scala index 5176d15028..7cd8b89a8c 100644 --- a/src/dbc/scala/dbc/value/ExactNumeric.scala +++ b/src/dbc/scala/dbc/value/ExactNumeric.scala @@ -15,7 +15,7 @@ package value; import java.math.BigInteger; import java.math.BigDecimal; -@deprecated(DbcIsDeprecated) abstract class ExactNumeric [Type] extends Value { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class ExactNumeric [Type] extends Value { val dataType: datatype.ExactNumeric[Type]; @@ -23,7 +23,7 @@ import java.math.BigDecimal; } -@deprecated(DbcIsDeprecated) object ExactNumeric { +@deprecated(DbcIsDeprecated, "2.9.0") object ExactNumeric { implicit def exactNumericToByte (obj:value.ExactNumeric[Byte]): Byte = obj.nativeValue; implicit def exactNumericToShort (obj:value.ExactNumeric[Short]): Short = obj.nativeValue; diff --git a/src/dbc/scala/dbc/value/Factory.scala b/src/dbc/scala/dbc/value/Factory.scala index cc7406a945..2d6101f6de 100644 --- a/src/dbc/scala/dbc/value/Factory.scala +++ b/src/dbc/scala/dbc/value/Factory.scala @@ -15,7 +15,7 @@ package value; import java.math.BigInteger; import java.math.BigDecimal; -@deprecated(DbcIsDeprecated) object Factory { +@deprecated(DbcIsDeprecated, "2.9.0") object Factory { def create (result: java.sql.ResultSet, index: Int, expectedDataType: DataType): Value = { expectedDataType.nativeTypeId match { diff --git a/src/dbc/scala/dbc/value/Unknown.scala b/src/dbc/scala/dbc/value/Unknown.scala index 90bf565a58..89764a5831 100644 --- a/src/dbc/scala/dbc/value/Unknown.scala +++ b/src/dbc/scala/dbc/value/Unknown.scala @@ -12,7 +12,7 @@ package scala.dbc package value; -@deprecated(DbcIsDeprecated) abstract class Unknown extends Value { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class Unknown extends Value { val dataType: datatype.Unknown; @@ -20,7 +20,7 @@ package value; } -@deprecated(DbcIsDeprecated) object UnknownType { +@deprecated(DbcIsDeprecated, "2.9.0") object UnknownType { def view (obj:value.Unknown): AnyRef = obj.nativeValue; diff --git a/src/dbc/scala/dbc/vendor/PostgreSQL.scala b/src/dbc/scala/dbc/vendor/PostgreSQL.scala index 4bd10c6629..ac528d5f82 100644 --- a/src/dbc/scala/dbc/vendor/PostgreSQL.scala +++ b/src/dbc/scala/dbc/vendor/PostgreSQL.scala @@ -14,7 +14,7 @@ package vendor; import compat.Platform -@deprecated(DbcIsDeprecated) abstract class PostgreSQL extends Vendor { +@deprecated(DbcIsDeprecated, "2.9.0") abstract class PostgreSQL extends Vendor { def uri:java.net.URI; def user:String; diff --git a/src/jline/project/plugins/project/build.properties b/src/jline/project/plugins/project/build.properties index 24481fef8e..218ed2577f 100644 --- a/src/jline/project/plugins/project/build.properties +++ b/src/jline/project/plugins/project/build.properties @@ -1,3 +1,3 @@ #Project properties -#Tue Apr 05 12:32:56 PDT 2011 +#Wed Mar 23 21:05:33 PDT 2011 plugin.uptodate=true diff --git a/src/jline/src/main/java/scala/tools/jline/TerminalSupport.java b/src/jline/src/main/java/scala/tools/jline/TerminalSupport.java index 03004fea68..1ca12cb73f 100644 --- a/src/jline/src/main/java/scala/tools/jline/TerminalSupport.java +++ b/src/jline/src/main/java/scala/tools/jline/TerminalSupport.java @@ -24,10 +24,6 @@ public abstract class TerminalSupport implements Terminal { public static String DEFAULT_KEYBINDINGS_PROPERTIES = "keybindings.properties"; - public static String DEFAULT_KEYBINDINGS_PROPERTIES_MAC = "macbindings.properties"; - public static boolean isMac() { - return System.getProperty("os.name").toLowerCase().startsWith("mac"); - } public static final String JLINE_SHUTDOWNHOOK = "jline.shutdownhook"; @@ -161,11 +157,7 @@ public abstract class TerminalSupport } public InputStream getDefaultBindings() { - // Mac bindings are slightly different from Unix/Linux. - // For instance, the Delete key behavior is different between them. - return TerminalSupport.class.getResourceAsStream( - isMac() ? DEFAULT_KEYBINDINGS_PROPERTIES_MAC : DEFAULT_KEYBINDINGS_PROPERTIES - ); + return TerminalSupport.class.getResourceAsStream(DEFAULT_KEYBINDINGS_PROPERTIES); } // diff --git a/src/jline/src/main/java/scala/tools/jline/console/ConsoleReader.java b/src/jline/src/main/java/scala/tools/jline/console/ConsoleReader.java index 5e6f5c166a..f493619bcd 100644 --- a/src/jline/src/main/java/scala/tools/jline/console/ConsoleReader.java +++ b/src/jline/src/main/java/scala/tools/jline/console/ConsoleReader.java @@ -1283,7 +1283,7 @@ public class ConsoleReader if (buf.buffer.length() == 0) { return null; } else { - success = deleteCurrentCharacter(); + deleteCurrentCharacter(); } break; diff --git a/src/jline/src/main/resources/scala/tools/jline/macbindings.properties b/src/jline/src/main/resources/scala/tools/jline/macbindings.properties deleted file mode 100644 index 8e810a8364..0000000000 --- a/src/jline/src/main/resources/scala/tools/jline/macbindings.properties +++ /dev/null @@ -1,62 +0,0 @@ -# Keybinding mapping for JLine. The format is: -# [key code]: [logical operation] - -# CTRL-B: move to the previous character -2: PREV_CHAR - -# CTRL-G: move to the previous word -7: PREV_WORD - -# CTRL-F: move to the next character -6: NEXT_CHAR - -# CTRL-A: move to the beginning of the line -1: MOVE_TO_BEG - -# CTRL-D: close out the input stream -4: EXIT - -# CTRL-E: move the cursor to the end of the line -5: MOVE_TO_END - -# BACKSPACE, CTRL-H: delete the previous character -# 8 is the ASCII code for backspace and therefor -# deleting the previous character -8: DELETE_PREV_CHAR - -# TAB, CTRL-I: signal that console completion should be attempted -9: COMPLETE - -# CTRL-J, CTRL-M: newline -10: NEWLINE - -# CTRL-K: erase the current line -11: KILL_LINE - -# ENTER: newline -13: NEWLINE - -# CTRL-L: clear screen -12: CLEAR_SCREEN - -# CTRL-N: scroll to the next element in the history buffer -14: NEXT_HISTORY - -# CTRL-P: scroll to the previous element in the history buffer -16: PREV_HISTORY - -# CTRL-R: redraw the current line -18: REDISPLAY - -# CTRL-U: delete all the characters before the cursor position -21: KILL_LINE_PREV - -# CTRL-V: paste the contents of the clipboard (useful for Windows terminal) -22: PASTE - -# CTRL-W: delete the word directly before the cursor -23: DELETE_PREV_WORD - -# DELETE, CTRL-?: delete the previous character -# 127 is the ASCII code for delete -127: DELETE_NEXT_CHAR diff --git a/src/library/scala/annotation/bridge.scala b/src/library/scala/annotation/bridge.scala new file mode 100644 index 0000000000..690370854e --- /dev/null +++ b/src/library/scala/annotation/bridge.scala @@ -0,0 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.annotation + +/** If this annotation is present on a method, it will be treated as a bridge method. + */ +private[scala] class bridge extends annotation.StaticAnnotation diff --git a/src/library/scala/collection/GenIterable.scala b/src/library/scala/collection/GenIterable.scala index 8d735dd86d..9d25f21c38 100644 --- a/src/library/scala/collection/GenIterable.scala +++ b/src/library/scala/collection/GenIterable.scala @@ -29,7 +29,7 @@ extends GenIterableLike[A, GenIterable[A]] } -object GenIterable extends TraversableFactory[GenIterable] { +object GenIterable extends GenTraversableFactory[GenIterable] { implicit def canBuildFrom[A] = new GenericCanBuildFrom[A] def newBuilder[A] = Iterable.newBuilder } diff --git a/src/library/scala/collection/GenMap.scala b/src/library/scala/collection/GenMap.scala index 7e7b6c7fb0..0556069371 100644 --- a/src/library/scala/collection/GenMap.scala +++ b/src/library/scala/collection/GenMap.scala @@ -26,7 +26,7 @@ extends GenMapLike[A, B, GenMap[A, B]] } -object GenMap extends MapFactory[GenMap] { +object GenMap extends GenMapFactory[GenMap] { def empty[A, B]: immutable.Map[A, B] = immutable.Map.empty /** $mapCanBuildFromInfo */ diff --git a/src/library/scala/collection/GenSeq.scala b/src/library/scala/collection/GenSeq.scala index ac5f953e88..9a7ee9890e 100644 --- a/src/library/scala/collection/GenSeq.scala +++ b/src/library/scala/collection/GenSeq.scala @@ -30,7 +30,7 @@ extends GenSeqLike[A, GenSeq[A]] } -object GenSeq extends TraversableFactory[GenSeq] { +object GenSeq extends GenTraversableFactory[GenSeq] { implicit def canBuildFrom[A] = new GenericCanBuildFrom[A] def newBuilder[A] = Seq.newBuilder } diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala index 1502853d8e..f5e8113d28 100644 --- a/src/library/scala/collection/GenSeqLike.scala +++ b/src/library/scala/collection/GenSeqLike.scala @@ -9,6 +9,7 @@ package scala.collection import generic._ +import annotation.bridge /** A template trait for all sequences which may be traversed * in parallel. @@ -209,6 +210,9 @@ private[collection] trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] */ def startsWith[B](that: GenSeq[B]): Boolean = startsWith(that, 0) + @bridge + def startsWith[B](that: Seq[B]): Boolean = startsWith(that: GenSeq[B]) + /** Tests whether this $coll contains the given sequence at a given index. * * If the both the receiver object, <code>this</code> and @@ -338,6 +342,10 @@ private[collection] trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] */ def union[B >: A, That](that: GenSeq[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = this ++ that + @bridge + def union[B >: A, That](that: Seq[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = + union(that: GenSeq[B])(bf) + /** Computes the multiset difference between this $coll and another sequence. * $willNotTerminateInf * diff --git a/src/library/scala/collection/GenSet.scala b/src/library/scala/collection/GenSet.scala index ec066844b4..fdf6d1edb2 100644 --- a/src/library/scala/collection/GenSet.scala +++ b/src/library/scala/collection/GenSet.scala @@ -30,7 +30,7 @@ extends GenSetLike[A, GenSet[A]] } -object GenSet extends TraversableFactory[GenSet] { +object GenSet extends GenTraversableFactory[GenSet] { implicit def canBuildFrom[A] = new GenericCanBuildFrom[A] def newBuilder[A] = Set.newBuilder } diff --git a/src/library/scala/collection/GenSetLike.scala b/src/library/scala/collection/GenSetLike.scala index d45810d2e7..1c998351b4 100644 --- a/src/library/scala/collection/GenSetLike.scala +++ b/src/library/scala/collection/GenSetLike.scala @@ -8,6 +8,8 @@ package scala.collection +import annotation.bridge + /** A template trait for sets which may possibly * have their operations implemented in parallel. * @@ -49,6 +51,9 @@ private[collection] trait GenSetLike[A, +Repr] */ def intersect(that: GenSet[A]): Repr = this filter that + @bridge + def intersect(that: Set[A]): Repr = intersect(that: GenSet[A]) + /** Computes the intersection between this set and another set. * * '''Note:''' Same as `intersect`. @@ -58,6 +63,9 @@ private[collection] trait GenSetLike[A, +Repr] */ def &(that: GenSet[A]): Repr = this intersect that + @bridge + def &(that: Set[A]): Repr = &(that: GenSet[A]) + /** Computes the union between of set and another set. * * @param that the set to form the union with. @@ -75,6 +83,9 @@ private[collection] trait GenSetLike[A, +Repr] */ def | (that: GenSet[A]): Repr = this union that + @bridge + def | (that: Set[A]): Repr = | (that: GenSet[A]) + /** Computes the difference of this set and another set. * * @param that the set of elements to exclude. @@ -92,6 +103,9 @@ private[collection] trait GenSetLike[A, +Repr] */ def &~(that: GenSet[A]): Repr = this diff that + @bridge + def &~(that: Set[A]): Repr = &~(that: GenSet[A]) + /** Tests whether this set is a subset of another set. * * @param that the set to test. @@ -100,6 +114,9 @@ private[collection] trait GenSetLike[A, +Repr] */ def subsetOf(that: GenSet[A]): Boolean = this forall that + @bridge + def subsetOf(that: Set[A]): Boolean = subsetOf(that: GenSet[A]) + /** Compares this set with another object for equality. * * '''Note:''' This operation contains an unchecked cast: if `that` diff --git a/src/library/scala/collection/GenTraversable.scala b/src/library/scala/collection/GenTraversable.scala index fc1f84d2e5..8e6ab50f1a 100644 --- a/src/library/scala/collection/GenTraversable.scala +++ b/src/library/scala/collection/GenTraversable.scala @@ -31,7 +31,7 @@ extends GenTraversableLike[A, GenTraversable[A]] } -object GenTraversable extends TraversableFactory[GenTraversable] { +object GenTraversable extends GenTraversableFactory[GenTraversable] { implicit def canBuildFrom[A] = new GenericCanBuildFrom[A] def newBuilder[A] = Traversable.newBuilder } diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index b6713b65e4..55c12b8e8c 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -12,7 +12,7 @@ package scala.collection import generic._ import immutable.{ List, Stream } import annotation.unchecked.uncheckedVariance - +import annotation.bridge /** A template trait for iterable collections of type `Iterable[A]`. * $iterableInfo @@ -237,6 +237,10 @@ self => b.result } + @bridge + def zip[A1 >: A, B, That](that: Iterable[B])(implicit bf: CanBuildFrom[Repr, (A1, B), That]): That = + zip(that: GenIterable[B])(bf) + def zipAll[B, A1 >: A, That](that: GenIterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[Repr, (A1, B), That]): That = { val b = bf(repr) val these = this.iterator @@ -250,6 +254,10 @@ self => b.result } + @bridge + def zipAll[B, A1 >: A, That](that: Iterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[Repr, (A1, B), That]): That = + zipAll(that: GenIterable[B], thisElem, thatElem)(bf) + def zipWithIndex[A1 >: A, That](implicit bf: CanBuildFrom[Repr, (A1, Int), That]): That = { val b = bf(repr) var i = 0 @@ -270,6 +278,9 @@ self => !these.hasNext && !those.hasNext } + @bridge + def sameElements[B >: A](that: Iterable[B]): Boolean = sameElements(that: GenIterable[B]) + override /*TraversableLike*/ def toStream: Stream[A] = iterator.toStream /** Method called from equality methods, so that user-defined subclasses can diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index 236a5bdaa3..5e0bd010a6 100755 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -48,7 +48,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea */ def apply(n: Int): A = { val rest = drop(n) - if (n < 0 || rest.isEmpty) throw new IndexOutOfBoundsException + if (n < 0 || rest.isEmpty) throw new IndexOutOfBoundsException("" + n) rest.head } diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala index a832f9089d..92be57aa89 100644 --- a/src/library/scala/collection/MapLike.scala +++ b/src/library/scala/collection/MapLike.scala @@ -11,7 +11,7 @@ package scala.collection import generic._ import mutable.{ Builder, MapBuilder } -import annotation.migration +import annotation.{migration, bridge} import parallel.ParMap /** A template trait for maps, which associate keys with values. @@ -290,6 +290,9 @@ self => def ++[B1 >: B](xs: GenTraversableOnce[(A, B1)]): Map[A, B1] = ((repr: Map[A, B1]) /: xs.seq) (_ + _) + @bridge + def ++[B1 >: B](xs: TraversableOnce[(A, B1)]): Map[A, B1] = ++(xs: GenTraversableOnce[(A, B1)]) + /** Returns a new map with all key/value pairs for which the predicate * `p` returns `true`. * diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index 87649e8b03..0411a2987e 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -14,6 +14,7 @@ import mutable.{ListBuffer, HashMap, ArraySeq} import immutable.{List, Range} import generic._ import parallel.ParSeq +import annotation.bridge /** A template trait for sequences of type `Seq[A]` * $seqInfo @@ -303,6 +304,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] !j.hasNext } + @bridge + def startsWith[B](that: Seq[B], offset: Int): Boolean = startsWith(that: GenSeq[B], offset) + def endsWith[B](that: GenSeq[B]): Boolean = { val i = this.iterator.drop(length - that.length) val j = that.iterator @@ -313,6 +317,10 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] !j.hasNext } + @bridge + def endsWith[B](that: Seq[B]): Boolean = endsWith(that: GenSeq[B]) + + /** Finds first index where this $coll contains a given sequence as a slice. * $mayNotTerminateInf * @param that the sequence to test @@ -321,6 +329,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] */ def indexOfSlice[B >: A](that: GenSeq[B]): Int = indexOfSlice(that, 0) + @bridge + def indexOfSlice[B >: A](that: Seq[B]): Int = indexOfSlice(that: GenSeq[B]) + /** Finds first index after or at a start index where this $coll contains a given sequence as a slice. * $mayNotTerminateInf * @param that the sequence to test @@ -344,6 +355,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] -1 } + @bridge + def indexOfSlice[B >: A](that: Seq[B], from: Int): Int = indexOfSlice(that: GenSeq[B], from) + /** Finds last index where this $coll contains a given sequence as a slice. * $willNotTerminateInf * @param that the sequence to test @@ -352,6 +366,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] */ def lastIndexOfSlice[B >: A](that: GenSeq[B]): Int = lastIndexOfSlice(that, length) + @bridge + def lastIndexOfSlice[B >: A](that: Seq[B]): Int = lastIndexOfSlice(that: GenSeq[B]) + /** Finds last index before or at a given end index where this $coll contains a given sequence as a slice. * @param that the sequence to test * @param end the end index @@ -361,6 +378,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] def lastIndexOfSlice[B >: A](that: GenSeq[B], end: Int): Int = SeqLike.lastIndexOf(thisCollection, 0, length, that.seq, 0, that.length, end) + @bridge + def lastIndexOfSlice[B >: A](that: Seq[B], end: Int): Int = lastIndexOfSlice(that: GenSeq[B], end) + /** Tests whether this $coll contains a given sequence as a slice. * $mayNotTerminateInf * @param that the sequence to test @@ -369,6 +389,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] */ def containsSlice[B](that: GenSeq[B]): Boolean = indexOfSlice(that) != -1 + @bridge + def containsSlice[B](that: Seq[B]): Boolean = containsSlice(that: GenSeq[B]) + /** Tests whether this $coll contains a given value as an element. * $mayNotTerminateInf * @@ -429,6 +452,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] b.result } + @bridge + def diff[B >: A](that: Seq[B]): Repr = diff(that: GenSeq[B]) + /** Computes the multiset intersection between this $coll and another sequence. * $mayNotTerminateInf * @@ -459,6 +485,9 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] b.result } + @bridge + def intersect[B >: A](that: Seq[B]): Repr = intersect(that: GenSeq[B]) + private def occCounts[B](sq: Seq[B]): mutable.Map[B, Int] = { val occ = new mutable.HashMap[B, Int] { override def default(k: B) = 0 } for (y <- sq.seq) occ(y) += 1 @@ -491,6 +520,10 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] b.result } + @bridge + def patch[B >: A, That](from: Int, patch: Seq[B], replaced: Int)(implicit bf: CanBuildFrom[Repr, B, That]): That = + this.patch(from, patch: GenSeq[B], replaced)(bf) + def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(repr) val (prefix, rest) = this.splitAt(index) @@ -536,6 +569,10 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] !i.hasNext && !j.hasNext } + @bridge + def corresponds[B](that: Seq[B])(p: (A,B) => Boolean): Boolean = + corresponds(that: GenSeq[B])(p) + /** Sorts this $coll according to a comparison function. * $willNotTerminateInf * diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala index c5b97c135d..2a208e0e3f 100644 --- a/src/library/scala/collection/SetLike.scala +++ b/src/library/scala/collection/SetLike.scala @@ -11,7 +11,7 @@ package scala.collection import generic._ import mutable.{ Builder, SetBuilder } -import scala.annotation.migration +import annotation.{migration, bridge} import parallel.ParSet /** A template trait for sets. @@ -127,6 +127,9 @@ self => */ def ++ (elems: GenTraversableOnce[A]): This = newBuilder ++= seq ++= elems.seq result + @bridge + def ++ (elems: TraversableOnce[A]): This = ++ (elems: GenTraversableOnce[A]) + /** Creates a new set with a given element removed from this set. * * @param elem the element to be removed @@ -148,7 +151,7 @@ self => * @param that the set to intersect with */ @deprecated("use & instead", "2.8.0") - def ** (that: GenSet[A]): This = &(that) + def ** (that: Set[A]): This = &(that) /** Computes the union between of set and another set. * @@ -158,6 +161,9 @@ self => */ def union(that: GenSet[A]): This = this ++ that + @bridge + def union(that: Set[A]): This = union(that: GenSet[A]) + /** Computes the difference of this set and another set. * * @param that the set of elements to exclude. @@ -166,6 +172,9 @@ self => */ def diff(that: GenSet[A]): This = this -- that + @bridge + def diff(that: Set[A]): This = diff(that: GenSet[A]) + /** An iterator over all subsets of this set of the given size. * If the requested size is impossible, an empty iterator is returned. * diff --git a/src/library/scala/collection/Traversable.scala b/src/library/scala/collection/Traversable.scala index 500c340368..71c5839d43 100644 --- a/src/library/scala/collection/Traversable.scala +++ b/src/library/scala/collection/Traversable.scala @@ -13,6 +13,7 @@ package scala.collection import generic._ import mutable.{Builder, Buffer, ArrayBuffer, ListBuffer} import scala.util.control.Breaks +import annotation.bridge /** A trait for traversable collections. * All operations are guaranteed to be performed in a single-threaded manner. @@ -27,6 +28,12 @@ trait Traversable[+A] extends TraversableLike[A, Traversable[A]] override def seq: Traversable[A] = this + @bridge + def flatten[B](implicit asTraversable: A => /*<:<!!!*/ TraversableOnce[B]): Traversable[B] = super.flatten(asTraversable) + + @bridge + def transpose[B](implicit asTraversable: A => /*<:<!!!*/ TraversableOnce[B]): Traversable[Traversable[B]] = super.transpose(asTraversable) + /* The following methods are inherited from TraversableLike * override def isEmpty: Boolean diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index fe1d5d7d77..c8b8dfda5f 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -10,8 +10,7 @@ package scala.collection import generic._ import mutable.{ Builder, ListBuffer } -import annotation.tailrec -import annotation.migration +import annotation.{tailrec, migration, bridge} import annotation.unchecked.{ uncheckedVariance => uV } import parallel.ParIterable @@ -153,6 +152,10 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] b.result } + @bridge + def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = + ++(that: GenTraversableOnce[B])(bf) + /** Concatenates this $coll with the elements of a traversable collection. * It differs from ++ in that the right operand determines the type of the * resulting collection rather than the left one. diff --git a/src/library/scala/collection/generic/Addable.scala b/src/library/scala/collection/generic/Addable.scala index 8f33a62f10..e2a34c1ed2 100644 --- a/src/library/scala/collection/generic/Addable.scala +++ b/src/library/scala/collection/generic/Addable.scala @@ -10,6 +10,8 @@ package scala.collection package generic +import annotation.bridge + /** This trait represents collection-like objects that can be added to * using a '+' operator. It defines variants of `+` and `++` * as convenience methods in terms of single-element addition `+`. @@ -53,4 +55,7 @@ trait Addable[A, +Repr <: Addable[A, Repr]] { self => * @return a new $coll with the given elements added. */ def ++ (xs: GenTraversableOnce[A]): Repr = (repr /: xs.seq) (_ + _) + + @bridge + def ++ (xs: TraversableOnce[A]): Repr = ++ (xs: GenTraversableOnce[A]) } diff --git a/src/library/scala/collection/generic/GenMapFactory.scala b/src/library/scala/collection/generic/GenMapFactory.scala new file mode 100644 index 0000000000..f3537e8c6b --- /dev/null +++ b/src/library/scala/collection/generic/GenMapFactory.scala @@ -0,0 +1,62 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package generic + + +import mutable.{Builder, MapBuilder} + + +/** A template for companion objects of `Map` and subclasses thereof. + * + * @define coll map + * @define Coll Map + * @define factoryInfo + * This object provides a set of operations needed to create `$Coll` values. + * @author Martin Odersky + * @version 2.8 + * @since 2.8 + * @define canBuildFromInfo + * The standard `CanBuildFrom` instance for `$Coll` objects. + * @see CanBuildFrom + * @define mapCanBuildFromInfo + * The standard `CanBuildFrom` instance for `$Coll` objects. + * The created value is an instance of class `MapCanBuildFrom`. + * @see CanBuildFrom + * @see GenericCanBuildFrom + */ +abstract class GenMapFactory[CC[A, B] <: GenMap[A, B] with GenMapLike[A, B, CC[A, B]]] { + + /** The type constructor of the collection that can be built by this factory */ + type Coll = CC[_, _] + + /** An empty $Coll */ + def empty[A, B]: CC[A, B] + + /** A collection of type $Coll that contains given key/value bindings. + * @param elems the key/value pairs that make up the $coll + * @tparam A the type of the keys + * @tparam B the type of the associated values + * @return a new $coll consisting key/value pairs given by `elems`. + */ + def apply[A, B](elems: (A, B)*): CC[A, B] = (newBuilder[A, B] ++= elems).result + + /** The default builder for $Coll objects. + * @tparam A the type of the keys + * @tparam B the type of the associated values + */ + def newBuilder[A, B]: Builder[(A, B), CC[A, B]] = new MapBuilder[A, B, CC[A, B]](empty[A, B]) + + /** The standard `CanBuildFrom` class for maps. + */ + class MapCanBuildFrom[A, B] extends CanBuildFrom[Coll, (A, B), CC[A, B]] { + def apply(from: Coll) = newBuilder[A, B] + def apply() = newBuilder + } +} diff --git a/src/library/scala/collection/generic/GenSeqFactory.scala b/src/library/scala/collection/generic/GenSeqFactory.scala new file mode 100644 index 0000000000..6fcecc422b --- /dev/null +++ b/src/library/scala/collection/generic/GenSeqFactory.scala @@ -0,0 +1,26 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + + +package scala.collection +package generic + +/** A template for companion objects of Seq and subclasses thereof. + * + * @since 2.8 + */ +abstract class GenSeqFactory[CC[X] <: GenSeq[X] with GenericTraversableTemplate[X, CC]] extends GenTraversableFactory[CC] { + + /** This method is called in a pattern match { case Seq(...) => }. + * + * @param x the selector value + * @return sequence wrapped in an option, if this is a Seq, otherwise none + */ + def unapplySeq[A](x: CC[A]): Some[CC[A]] = Some(x) +} diff --git a/src/library/scala/collection/generic/GenSetFactory.scala b/src/library/scala/collection/generic/GenSetFactory.scala new file mode 100644 index 0000000000..d83f248aff --- /dev/null +++ b/src/library/scala/collection/generic/GenSetFactory.scala @@ -0,0 +1,44 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + + +package scala.collection +package generic + +import mutable.Builder + +/** A template for companion objects of `Set` and subclasses thereof. + * + * @define coll set + * @define Coll Set + * @define factoryInfo + * This object provides a set of operations needed to create `$Coll` values. + * @author Martin Odersky + * @version 2.8 + * @since 2.8 + * @define canBuildFromInfo + * The standard `CanBuildFrom` instance for `$Coll` objects. + * @see CanBuildFrom + * @define setCanBuildFromInfo + * The standard `CanBuildFrom` instance for `$Coll` objects. + * @see CanBuildFrom + * @see GenericCanBuildFrom + */ +abstract class GenSetFactory[CC[X] <: GenSet[X] with GenSetLike[X, CC[X]]] + extends GenericCompanion[CC] { + + def newBuilder[A]: Builder[A, CC[A]] + + /** $setCanBuildFromInfo + */ + def setCanBuildFrom[A] = new CanBuildFrom[CC[_], A, CC[A]] { + def apply(from: CC[_]) = newBuilder[A] + def apply() = newBuilder[A] + } +} diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala new file mode 100644 index 0000000000..c2718e5ee2 --- /dev/null +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -0,0 +1,245 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2006-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + +package scala.collection +package generic + +/** A template for companion objects of `Traversable` and subclasses thereof. + * This class provides a set of operations to create `$Coll` objects. + * It is typically inherited by companion objects of subclasses of `Traversable`. + * + * @since 2.8 + * + * @define coll collection + * @define Coll Traversable + * @define factoryInfo + * This object provides a set of operations to create `$Coll` values. + * @author Martin Odersky + * @version 2.8 + * @define canBuildFromInfo + * The standard `CanBuildFrom` instance for $Coll objects. + * @see CanBuildFrom + * @define genericCanBuildFromInfo + * The standard `CanBuildFrom` instance for $Coll objects. + * The created value is an instance of class `GenericCanBuildFrom`, + * which forwards calls to create a new builder to the + * `genericBuilder` method of the requesting collection. + * @see CanBuildFrom + * @see GenericCanBuildFrom + */ +abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTraversableTemplate[X, CC]] + extends GenericCompanion[CC] { + + /** A generic implementation of the `CanBuildFrom` trait, which forwards + * all calls to `apply(from)` to the `genericBuilder` method of + * $coll `from`, and which forwards all calls of `apply()` to the + * `newBuilder` method of this factory. + */ + class GenericCanBuildFrom[A] extends CanBuildFrom[CC[_], A, CC[A]] { + /** Creates a new builder on request of a collection. + * @param from the collection requesting the builder to be created. + * @return the result of invoking the `genericBuilder` method on `from`. + */ + def apply(from: Coll) = from.genericBuilder[A] + + /** Creates a new builder from scratch + * @return the result of invoking the `newBuilder` method of this factory. + */ + def apply() = newBuilder[A] + } + + /** Concatenates all argument collections into a single $coll. + * + * @param xss the collections that are to be concatenated. + * @return the concatenation of all the collections. + */ + def concat[A](xss: Traversable[A]*): CC[A] = { + val b = newBuilder[A] + // At present we're using IndexedSeq as a proxy for "has a cheap size method". + if (xss forall (_.isInstanceOf[IndexedSeq[_]])) + b.sizeHint(xss map (_.size) sum) + + for (xs <- xss.seq) b ++= xs + b.result + } + + /** Produces a $coll containing the results of some element computation a number of times. + * @param n the number of elements contained in the $coll. + * @param elem the element computation + * @return A $coll that contains the results of `n` evaluations of `elem`. + */ + def fill[A](n: Int)(elem: => A): CC[A] = { + val b = newBuilder[A] + b.sizeHint(n) + var i = 0 + while (i < n) { + b += elem + i += 1 + } + b.result + } + + /** Produces a two-dimensional $coll containing the results of some element computation a number of times. + * @param n1 the number of elements in the 1st dimension + * @param n2 the number of elements in the 2nd dimension + * @param elem the element computation + * @return A $coll that contains the results of `n1 x n2` evaluations of `elem`. + */ + def fill[A](n1: Int, n2: Int)(elem: => A): CC[CC[A]] = + tabulate(n1)(_ => fill(n2)(elem)) + + /** Produces a three-dimensional $coll containing the results of some element computation a number of times. + * @param n1 the number of elements in the 1st dimension + * @param n2 the number of elements in the 2nd dimension + * @param n3 the number of elements in the 3nd dimension + * @param elem the element computation + * @return A $coll that contains the results of `n1 x n2 x n3` evaluations of `elem`. + */ + def fill[A](n1: Int, n2: Int, n3: Int)(elem: => A): CC[CC[CC[A]]] = + tabulate(n1)(_ => fill(n2, n3)(elem)) + + /** Produces a four-dimensional $coll containing the results of some element computation a number of times. + * @param n1 the number of elements in the 1st dimension + * @param n2 the number of elements in the 2nd dimension + * @param n3 the number of elements in the 3nd dimension + * @param n4 the number of elements in the 4th dimension + * @param elem the element computation + * @return A $coll that contains the results of `n1 x n2 x n3 x n4` evaluations of `elem`. + */ + def fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => A): CC[CC[CC[CC[A]]]] = + tabulate(n1)(_ => fill(n2, n3, n4)(elem)) + + /** Produces a five-dimensional $coll containing the results of some element computation a number of times. + * @param n1 the number of elements in the 1st dimension + * @param n2 the number of elements in the 2nd dimension + * @param n3 the number of elements in the 3nd dimension + * @param n4 the number of elements in the 4th dimension + * @param n5 the number of elements in the 5th dimension + * @param elem the element computation + * @return A $coll that contains the results of `n1 x n2 x n3 x n4 x n5` evaluations of `elem`. + */ + def fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => A): CC[CC[CC[CC[CC[A]]]]] = + tabulate(n1)(_ => fill(n2, n3, n4, n5)(elem)) + + /** Produces a $coll containing values of a given function over a range of integer values starting from 0. + * @param n The number of elements in the $coll + * @param f The function computing element values + * @return A $coll consisting of elements `f(0), ..., f(n -1)` + */ + def tabulate[A](n: Int)(f: Int => A): CC[A] = { + val b = newBuilder[A] + b.sizeHint(n) + var i = 0 + while (i < n) { + b += f(i) + i += 1 + } + b.result + } + + /** Produces a two-dimensional $coll containing values of a given function over ranges of integer values starting from 0. + * @param n1 the number of elements in the 1st dimension + * @param n2 the number of elements in the 2nd dimension + * @param f The function computing element values + * @return A $coll consisting of elements `f(i1, i2)` + * for `0 <= i1 < n1` and `0 <= i2 < n2`. + */ + def tabulate[A](n1: Int, n2: Int)(f: (Int, Int) => A): CC[CC[A]] = + tabulate(n1)(i1 => tabulate(n2)(f(i1, _))) + + /** Produces a three-dimensional $coll containing values of a given function over ranges of integer values starting from 0. + * @param n1 the number of elements in the 1st dimension + * @param n2 the number of elements in the 2nd dimension + * @param n3 the number of elements in the 3nd dimension + * @param f The function computing element values + * @return A $coll consisting of elements `f(i1, i2, i3)` + * for `0 <= i1 < n1`, `0 <= i2 < n2`, and `0 <= i3 < n3`. + */ + def tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => A): CC[CC[CC[A]]] = + tabulate(n1)(i1 => tabulate(n2, n3)(f(i1, _, _))) + + /** Produces a four-dimensional $coll containing values of a given function over ranges of integer values starting from 0. + * @param n1 the number of elements in the 1st dimension + * @param n2 the number of elements in the 2nd dimension + * @param n3 the number of elements in the 3nd dimension + * @param n4 the number of elements in the 4th dimension + * @param f The function computing element values + * @return A $coll consisting of elements `f(i1, i2, i3, i4)` + * for `0 <= i1 < n1`, `0 <= i2 < n2`, `0 <= i3 < n3`, and `0 <= i4 < n4`. + */ + def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => A): CC[CC[CC[CC[A]]]] = + tabulate(n1)(i1 => tabulate(n2, n3, n4)(f(i1, _, _, _))) + + /** Produces a five-dimensional $coll containing values of a given function over ranges of integer values starting from 0. + * @param n1 the number of elements in the 1st dimension + * @param n2 the number of elements in the 2nd dimension + * @param n3 the number of elements in the 3nd dimension + * @param n4 the number of elements in the 4th dimension + * @param n5 the number of elements in the 5th dimension + * @param f The function computing element values + * @return A $coll consisting of elements `f(i1, i2, i3, i4, i5)` + * for `0 <= i1 < n1`, `0 <= i2 < n2`, `0 <= i3 < n3`, `0 <= i4 < n4`, and `0 <= i5 < n5`. + */ + def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => A): CC[CC[CC[CC[CC[A]]]]] = + tabulate(n1)(i1 => tabulate(n2, n3, n4, n5)(f(i1, _, _, _, _))) + + /** Produces a $coll containing a sequence of increasing of integers. + * + * @param from the first element of the $coll + * @param end the end value of the $coll (the first value NOT contained) + * @return a $coll with values `start, start + 1, ..., end - 1` + */ + def range[T: Integral](start: T, end: T): CC[T] = range(start, end, implicitly[Integral[T]].one) + + /** Produces a $coll containing equally spaced values in some integer interval. + * @param start the start value of the $coll + * @param end the end value of the $coll (the first value NOT contained) + * @param step the difference between successive elements of the $coll (must be positive or negative) + * @return a $coll with values `start, start + step, ...` up to, but excluding `end` + */ + def range[T: Integral](start: T, end: T, step: T): CC[T] = { + val num = implicitly[Integral[T]] + import num._ + + if (step == zero) throw new IllegalArgumentException("zero step") + val b = newBuilder[T] + b sizeHint immutable.NumericRange.count(start, end, step, false) + var i = start + while (if (step < zero) end < i else i < end) { + b += i + i += step + } + b.result + } + + /** Produces a $coll containing repeated applications of a function to a start value. + * + * @param start the start value of the $coll + * @param len the number of elements contained inthe $coll + * @param f the function that's repeatedly applied + * @return a $coll with `len` values in the sequence `start, f(start), f(f(start)), ...` + */ + def iterate[A](start: A, len: Int)(f: A => A): CC[A] = { + val b = newBuilder[A] + if (len > 0) { + b.sizeHint(len) + var acc = start + var i = 1 + b += acc + + while (i < len) { + acc = f(acc) + i += 1 + b += acc + } + } + b.result + } +} + diff --git a/src/library/scala/collection/generic/GenericSeqCompanion.scala b/src/library/scala/collection/generic/GenericSeqCompanion.scala new file mode 100644 index 0000000000..41e8d6dd39 --- /dev/null +++ b/src/library/scala/collection/generic/GenericSeqCompanion.scala @@ -0,0 +1,24 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2006-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + + +package scala.collection +package generic + +import annotation.bridge + +trait GenericSeqCompanion[CC[X] <: Traversable[X]] + extends GenericCompanion[CC] { + + @bridge + override def empty[A]: CC[A] = super.empty[A] + + @bridge + override def apply[A](elems: A*): CC[A] = super.apply(elems: _*) + +} diff --git a/src/library/scala/collection/generic/MapFactory.scala b/src/library/scala/collection/generic/MapFactory.scala index 122d1c9313..a60e3032c1 100644 --- a/src/library/scala/collection/generic/MapFactory.scala +++ b/src/library/scala/collection/generic/MapFactory.scala @@ -11,7 +11,7 @@ package generic import mutable.{Builder, MapBuilder} - +import annotation.bridge /** A template for companion objects of `Map` and subclasses thereof. * @@ -31,32 +31,10 @@ import mutable.{Builder, MapBuilder} * @see CanBuildFrom * @see GenericCanBuildFrom */ -abstract class MapFactory[CC[A, B] <: GenMap[A, B] with GenMapLike[A, B, CC[A, B]]] { - - /** The type constructor of the collection that can be built by this factory */ - type Coll = CC[_, _] +abstract class MapFactory[CC[A, B] <: Map[A, B] with MapLike[A, B, CC[A, B]]] extends GenMapFactory[CC] { - /** An empty $Coll */ def empty[A, B]: CC[A, B] - /** A collection of type $Coll that contains given key/value bindings. - * @param elems the key/value pairs that make up the $coll - * @tparam A the type of the keys - * @tparam B the type of the associated values - * @return a new $coll consisting key/value pairs given by `elems`. - */ - def apply[A, B](elems: (A, B)*): CC[A, B] = (newBuilder[A, B] ++= elems).result - - /** The default builder for $Coll objects. - * @tparam A the type of the keys - * @tparam B the type of the associated values - */ - def newBuilder[A, B]: Builder[(A, B), CC[A, B]] = new MapBuilder[A, B, CC[A, B]](empty[A, B]) - - /** The standard `CanBuildFrom` class for maps. - */ - class MapCanBuildFrom[A, B] extends CanBuildFrom[Coll, (A, B), CC[A, B]] { - def apply(from: Coll) = newBuilder[A, B] - def apply() = newBuilder - } + @bridge + override def apply[A, B](elems: (A, B)*): CC[A, B] = super.apply(elems: _*) } diff --git a/src/library/scala/collection/generic/ParFactory.scala b/src/library/scala/collection/generic/ParFactory.scala index e8c2b239c3..637a1dca6a 100644 --- a/src/library/scala/collection/generic/ParFactory.scala +++ b/src/library/scala/collection/generic/ParFactory.scala @@ -21,7 +21,7 @@ import scala.collection.parallel.Combiner * @define Coll ParIterable */ abstract class ParFactory[CC[X] <: ParIterable[X] with GenericParTemplate[X, CC]] -extends TraversableFactory[CC] +extends GenTraversableFactory[CC] with GenericParCompanion[CC] { //type EPC[T, C] = collection.parallel.EnvironmentPassingCombiner[T, C] diff --git a/src/library/scala/collection/generic/ParMapFactory.scala b/src/library/scala/collection/generic/ParMapFactory.scala index 1a9efdf7a7..06105c9756 100644 --- a/src/library/scala/collection/generic/ParMapFactory.scala +++ b/src/library/scala/collection/generic/ParMapFactory.scala @@ -20,7 +20,7 @@ import scala.collection.mutable.Builder * @define Coll ParMap */ abstract class ParMapFactory[CC[X, Y] <: ParMap[X, Y] with ParMapLike[X, Y, CC[X, Y], _]] -extends MapFactory[CC] +extends GenMapFactory[CC] with GenericParMapCompanion[CC] { type MapColl = CC[_, _] diff --git a/src/library/scala/collection/generic/ParSetFactory.scala b/src/library/scala/collection/generic/ParSetFactory.scala index 4cf39f9041..221e893593 100644 --- a/src/library/scala/collection/generic/ParSetFactory.scala +++ b/src/library/scala/collection/generic/ParSetFactory.scala @@ -23,7 +23,7 @@ import collection.parallel.ParSetLike abstract class ParSetFactory[CC[X] <: ParSet[X] with ParSetLike[X, CC[X], _] with GenericParTemplate[X, CC]] - extends SetFactory[CC] + extends GenSetFactory[CC] with GenericParCompanion[CC] { def newBuilder[A]: Combiner[A, CC[A]] = newCombiner[A] diff --git a/src/library/scala/collection/generic/SeqFactory.scala b/src/library/scala/collection/generic/SeqFactory.scala index 5e733d8444..544d8f4d6f 100644 --- a/src/library/scala/collection/generic/SeqFactory.scala +++ b/src/library/scala/collection/generic/SeqFactory.scala @@ -11,16 +11,12 @@ package scala.collection package generic +import annotation.bridge + /** A template for companion objects of Seq and subclasses thereof. * * @since 2.8 */ -abstract class SeqFactory[CC[X] <: GenSeq[X] with GenericTraversableTemplate[X, CC]] extends TraversableFactory[CC] { +abstract class SeqFactory[CC[X] <: Seq[X] with GenericTraversableTemplate[X, CC]] + extends GenSeqFactory[CC] with TraversableFactory[CC] - /** This method is called in a pattern match { case Seq(...) => }. - * - * @param x the selector value - * @return sequence wrapped in an option, if this is a Seq, otherwise none - */ - def unapplySeq[A](x: CC[A]): Some[CC[A]] = Some(x) -} diff --git a/src/library/scala/collection/generic/SetFactory.scala b/src/library/scala/collection/generic/SetFactory.scala index 3b8b5d3d47..348743a120 100644 --- a/src/library/scala/collection/generic/SetFactory.scala +++ b/src/library/scala/collection/generic/SetFactory.scala @@ -12,33 +12,14 @@ package scala.collection package generic import mutable.Builder +import annotation.bridge -/** A template for companion objects of `Set` and subclasses thereof. - * - * @define coll set - * @define Coll Set - * @define factoryInfo - * This object provides a set of operations needed to create `$Coll` values. - * @author Martin Odersky - * @version 2.8 - * @since 2.8 - * @define canBuildFromInfo - * The standard `CanBuildFrom` instance for `$Coll` objects. - * @see CanBuildFrom - * @define setCanBuildFromInfo - * The standard `CanBuildFrom` instance for `$Coll` objects. - * @see CanBuildFrom - * @see GenericCanBuildFrom - */ -abstract class SetFactory[CC[X] <: GenSet[X] with GenSetLike[X, CC[X]]] - extends GenericCompanion[CC] { +abstract class SetFactory[CC[X] <: Set[X] with SetLike[X, CC[X]]] + extends GenSetFactory[CC] with GenericSeqCompanion[CC] { - def newBuilder[A]: Builder[A, CC[A]] + @bridge + override def empty[A]: CC[A] = super.empty[A] - /** $setCanBuildFromInfo - */ - def setCanBuildFrom[A] = new CanBuildFrom[CC[_], A, CC[A]] { - def apply(from: CC[_]) = newBuilder[A] - def apply() = newBuilder[A] - } + @bridge + override def apply[A](elems: A*): CC[A] = super.apply(elems: _*) } diff --git a/src/library/scala/collection/generic/Subtractable.scala b/src/library/scala/collection/generic/Subtractable.scala index 1e151f9212..1ca9d706f0 100644 --- a/src/library/scala/collection/generic/Subtractable.scala +++ b/src/library/scala/collection/generic/Subtractable.scala @@ -10,6 +10,8 @@ package scala.collection package generic +import annotation.bridge + /** This trait represents collection-like objects that can be reduced * using a '+' operator. It defines variants of `-` and `--` * as convenience methods in terms of single-element removal `-`. @@ -56,4 +58,7 @@ trait Subtractable[A, +Repr <: Subtractable[A, Repr]] { self => * except one less occurrence of each of the elements of `elems`. */ def --(xs: GenTraversableOnce[A]): Repr = (repr /: xs.seq) (_ - _) + + @bridge + def --(xs: TraversableOnce[A]): Repr = --(xs: GenTraversableOnce[A]) } diff --git a/src/library/scala/collection/generic/TraversableFactory.scala b/src/library/scala/collection/generic/TraversableFactory.scala index 66e5d2db77..e71de1252c 100644 --- a/src/library/scala/collection/generic/TraversableFactory.scala +++ b/src/library/scala/collection/generic/TraversableFactory.scala @@ -10,6 +10,8 @@ package scala.collection package generic +import annotation.bridge + /** A template for companion objects of `Traversable` and subclasses thereof. * This class provides a set of operations to create `$Coll` objects. * It is typically inherited by companion objects of subclasses of `Traversable`. @@ -33,213 +35,49 @@ package generic * @see CanBuildFrom * @see GenericCanBuildFrom */ -abstract class TraversableFactory[CC[X] <: GenTraversable[X] with GenericTraversableTemplate[X, CC]] - extends GenericCompanion[CC] { - - /** A generic implementation of the `CanBuildFrom` trait, which forwards - * all calls to `apply(from)` to the `genericBuilder` method of - * $coll `from`, and which forwards all calls of `apply()` to the - * `newBuilder` method of this factory. - */ - class GenericCanBuildFrom[A] extends CanBuildFrom[CC[_], A, CC[A]] { - /** Creates a new builder on request of a collection. - * @param from the collection requesting the builder to be created. - * @return the result of invoking the `genericBuilder` method on `from`. - */ - def apply(from: Coll) = from.genericBuilder[A] - - /** Creates a new builder from scratch - * @return the result of invoking the `newBuilder` method of this factory. - */ - def apply() = newBuilder[A] - } - - /** Concatenates all argument collections into a single $coll. - * - * @param xss the collections that are to be concatenated. - * @return the concatenation of all the collections. - */ - def concat[A](xss: Traversable[A]*): CC[A] = { - val b = newBuilder[A] - // At present we're using IndexedSeq as a proxy for "has a cheap size method". - if (xss forall (_.isInstanceOf[IndexedSeq[_]])) - b.sizeHint(xss map (_.size) sum) - - for (xs <- xss.seq) b ++= xs - b.result - } - - /** Produces a $coll containing the results of some element computation a number of times. - * @param n the number of elements contained in the $coll. - * @param elem the element computation - * @return A $coll that contains the results of `n` evaluations of `elem`. - */ - def fill[A](n: Int)(elem: => A): CC[A] = { - val b = newBuilder[A] - b.sizeHint(n) - var i = 0 - while (i < n) { - b += elem - i += 1 - } - b.result - } - - /** Produces a two-dimensional $coll containing the results of some element computation a number of times. - * @param n1 the number of elements in the 1st dimension - * @param n2 the number of elements in the 2nd dimension - * @param elem the element computation - * @return A $coll that contains the results of `n1 x n2` evaluations of `elem`. - */ - def fill[A](n1: Int, n2: Int)(elem: => A): CC[CC[A]] = - tabulate(n1)(_ => fill(n2)(elem)) - - /** Produces a three-dimensional $coll containing the results of some element computation a number of times. - * @param n1 the number of elements in the 1st dimension - * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension - * @param elem the element computation - * @return A $coll that contains the results of `n1 x n2 x n3` evaluations of `elem`. - */ - def fill[A](n1: Int, n2: Int, n3: Int)(elem: => A): CC[CC[CC[A]]] = - tabulate(n1)(_ => fill(n2, n3)(elem)) - - /** Produces a four-dimensional $coll containing the results of some element computation a number of times. - * @param n1 the number of elements in the 1st dimension - * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension - * @param n4 the number of elements in the 4th dimension - * @param elem the element computation - * @return A $coll that contains the results of `n1 x n2 x n3 x n4` evaluations of `elem`. - */ - def fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => A): CC[CC[CC[CC[A]]]] = - tabulate(n1)(_ => fill(n2, n3, n4)(elem)) - - /** Produces a five-dimensional $coll containing the results of some element computation a number of times. - * @param n1 the number of elements in the 1st dimension - * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension - * @param n4 the number of elements in the 4th dimension - * @param n5 the number of elements in the 5th dimension - * @param elem the element computation - * @return A $coll that contains the results of `n1 x n2 x n3 x n4 x n5` evaluations of `elem`. - */ - def fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => A): CC[CC[CC[CC[CC[A]]]]] = - tabulate(n1)(_ => fill(n2, n3, n4, n5)(elem)) - - /** Produces a $coll containing values of a given function over a range of integer values starting from 0. - * @param n The number of elements in the $coll - * @param f The function computing element values - * @return A $coll consisting of elements `f(0), ..., f(n -1)` - */ - def tabulate[A](n: Int)(f: Int => A): CC[A] = { - val b = newBuilder[A] - b.sizeHint(n) - var i = 0 - while (i < n) { - b += f(i) - i += 1 - } - b.result - } - - /** Produces a two-dimensional $coll containing values of a given function over ranges of integer values starting from 0. - * @param n1 the number of elements in the 1st dimension - * @param n2 the number of elements in the 2nd dimension - * @param f The function computing element values - * @return A $coll consisting of elements `f(i1, i2)` - * for `0 <= i1 < n1` and `0 <= i2 < n2`. - */ - def tabulate[A](n1: Int, n2: Int)(f: (Int, Int) => A): CC[CC[A]] = - tabulate(n1)(i1 => tabulate(n2)(f(i1, _))) - - /** Produces a three-dimensional $coll containing values of a given function over ranges of integer values starting from 0. - * @param n1 the number of elements in the 1st dimension - * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension - * @param f The function computing element values - * @return A $coll consisting of elements `f(i1, i2, i3)` - * for `0 <= i1 < n1`, `0 <= i2 < n2`, and `0 <= i3 < n3`. - */ - def tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => A): CC[CC[CC[A]]] = - tabulate(n1)(i1 => tabulate(n2, n3)(f(i1, _, _))) - - /** Produces a four-dimensional $coll containing values of a given function over ranges of integer values starting from 0. - * @param n1 the number of elements in the 1st dimension - * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension - * @param n4 the number of elements in the 4th dimension - * @param f The function computing element values - * @return A $coll consisting of elements `f(i1, i2, i3, i4)` - * for `0 <= i1 < n1`, `0 <= i2 < n2`, `0 <= i3 < n3`, and `0 <= i4 < n4`. - */ - def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => A): CC[CC[CC[CC[A]]]] = - tabulate(n1)(i1 => tabulate(n2, n3, n4)(f(i1, _, _, _))) - - /** Produces a five-dimensional $coll containing values of a given function over ranges of integer values starting from 0. - * @param n1 the number of elements in the 1st dimension - * @param n2 the number of elements in the 2nd dimension - * @param n3 the number of elements in the 3nd dimension - * @param n4 the number of elements in the 4th dimension - * @param n5 the number of elements in the 5th dimension - * @param f The function computing element values - * @return A $coll consisting of elements `f(i1, i2, i3, i4, i5)` - * for `0 <= i1 < n1`, `0 <= i2 < n2`, `0 <= i3 < n3`, `0 <= i4 < n4`, and `0 <= i5 < n5`. - */ - def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => A): CC[CC[CC[CC[CC[A]]]]] = - tabulate(n1)(i1 => tabulate(n2, n3, n4, n5)(f(i1, _, _, _, _))) - - /** Produces a $coll containing a sequence of increasing of integers. - * - * @param from the first element of the $coll - * @param end the end value of the $coll (the first value NOT contained) - * @return a $coll with values `start, start + 1, ..., end - 1` - */ - def range[T: Integral](start: T, end: T): CC[T] = range(start, end, implicitly[Integral[T]].one) - - /** Produces a $coll containing equally spaced values in some integer interval. - * @param start the start value of the $coll - * @param end the end value of the $coll (the first value NOT contained) - * @param step the difference between successive elements of the $coll (must be positive or negative) - * @return a $coll with values `start, start + step, ...` up to, but excluding `end` - */ - def range[T: Integral](start: T, end: T, step: T): CC[T] = { - val num = implicitly[Integral[T]] - import num._ - - if (step == zero) throw new IllegalArgumentException("zero step") - val b = newBuilder[T] - b sizeHint immutable.NumericRange.count(start, end, step, false) - var i = start - while (if (step < zero) end < i else i < end) { - b += i - i += step - } - b.result - } - - /** Produces a $coll containing repeated applications of a function to a start value. - * - * @param start the start value of the $coll - * @param len the number of elements contained inthe $coll - * @param f the function that's repeatedly applied - * @return a $coll with `len` values in the sequence `start, f(start), f(f(start)), ...` - */ - def iterate[A](start: A, len: Int)(f: A => A): CC[A] = { - val b = newBuilder[A] - if (len > 0) { - b.sizeHint(len) - var acc = start - var i = 1 - b += acc - - while (i < len) { - acc = f(acc) - i += 1 - b += acc - } - } - b.result - } +trait TraversableFactory[CC[X] <: Traversable[X] with GenericTraversableTemplate[X, CC]] + extends GenTraversableFactory[CC] with GenericSeqCompanion[CC] { + + @bridge + override def concat[A](xss: Traversable[A]*): CC[A] = super.concat(xss: _*) + + @bridge + override def fill[A](n: Int)(elem: => A): CC[A] = super.fill(n)(elem) + + @bridge + override def fill[A](n1: Int, n2: Int)(elem: => A): CC[CC[A]] = super.fill(n1, n2)(elem) + + @bridge + override def fill[A](n1: Int, n2: Int, n3: Int)(elem: => A): CC[CC[CC[A]]] = super.fill(n1, n2, n3)(elem) + + @bridge + override def fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => A): CC[CC[CC[CC[A]]]] = super.fill(n1, n2, n3, n4)(elem) + + @bridge + override def fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => A): CC[CC[CC[CC[CC[A]]]]] = super.fill(n1, n2, n3, n4, n5)(elem) + + @bridge + override def tabulate[A](n: Int)(f: Int => A): CC[A] = super.tabulate(n)(f) + + @bridge + override def tabulate[A](n1: Int, n2: Int)(f: (Int, Int) => A): CC[CC[A]] = super.tabulate(n1, n2)(f) + + @bridge + override def tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => A): CC[CC[CC[A]]] = super.tabulate(n1, n2, n3)(f) + + @bridge + override def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => A): CC[CC[CC[CC[A]]]] = super.tabulate(n1, n2, n3, n4)(f) + + @bridge + override def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => A): CC[CC[CC[CC[CC[A]]]]] = super.tabulate(n1, n2, n3, n4, n5)(f) + + @bridge + override def range[T: Integral](start: T, end: T): CC[T] = super.range(start, end) + + @bridge + override def range[T: Integral](start: T, end: T, step: T): CC[T] = super.range(start, end, step) + + @bridge + override def iterate[A](start: A, len: Int)(f: A => A): CC[A] = super.iterate(start, len)(f) } diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 2a5ba9839f..2b1e4bff13 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -10,6 +10,7 @@ package scala.collection.immutable import scala.collection.parallel.immutable.ParRange +import annotation.bridge /** The `Range` class represents integer values in range * ''[start;end)'' with non-zero step value `step`. @@ -326,4 +327,10 @@ object Range { def apply(start: Int, end: Int, step: Int) = NumericRange(start, end, step) def inclusive(start: Int, end: Int, step: Int) = NumericRange.inclusive(start, end, step) } + + @deprecated("use Range instead") + trait ByOne extends Range { + @bridge override def foreach[@specialized(Unit) U](f: Int => U) = + super.foreach(f) + } } diff --git a/src/library/scala/collection/mutable/BufferLike.scala b/src/library/scala/collection/mutable/BufferLike.scala index 3c9e336e6f..c48dd5d621 100644 --- a/src/library/scala/collection/mutable/BufferLike.scala +++ b/src/library/scala/collection/mutable/BufferLike.scala @@ -13,7 +13,7 @@ package mutable import generic._ import script._ -import annotation.migration +import annotation.{migration, bridge} /** A template trait for buffers of type `Buffer[A]`. * @@ -271,6 +271,9 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]] ) def ++(xs: GenTraversableOnce[A]): This = clone() ++= xs.seq + @bridge + def ++(xs: TraversableOnce[A]): This = ++(xs: GenTraversableOnce[A]) + /** Creates a new collection with all the elements of this collection except `elem`. * * @param elem the element to remove. diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index 59648f160c..2c03f329a7 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -12,7 +12,7 @@ package scala.collection package mutable import generic._ -import annotation.migration +import annotation.{migration, bridge} /** This class implements priority queues using a heap. * To prioritize elements of type A there must be an implicit @@ -127,7 +127,10 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) * @param xs a traversable object. * @return a new priority queue containing elements of both `xs` and `this`. */ - def ++(xs: GenTraversableOnce[A]) = { this.clone() ++= xs.seq } + def ++(xs: GenTraversableOnce[A]): PriorityQueue[A] = { this.clone() ++= xs.seq } + + @bridge + def ++(xs: TraversableOnce[A]): PriorityQueue[A] = ++ (xs: GenTraversableOnce[A]) /** Adds all elements to the queue. * diff --git a/src/library/scala/collection/parallel/immutable/package.scala b/src/library/scala/collection/parallel/immutable/package.scala index c62459deeb..19f8665667 100644 --- a/src/library/scala/collection/parallel/immutable/package.scala +++ b/src/library/scala/collection/parallel/immutable/package.scala @@ -6,19 +6,8 @@ ** |/ ** \* */ - package scala.collection.parallel - - - - - - - - - - package object immutable { /* package level methods */ @@ -36,7 +25,7 @@ package object immutable { */ private[parallel] class Repetition[T](elem: T, val length: Int) extends ParSeq[T] { self => - def apply(idx: Int) = if (0 <= idx && idx < length) elem else throw new IndexOutOfBoundsException + def apply(idx: Int) = if (0 <= idx && idx < length) elem else throw new IndexOutOfBoundsException("" + idx) override def seq = throw new UnsupportedOperationException def update(idx: Int, elem: T) = throw new UnsupportedOperationException @@ -58,15 +47,4 @@ package object immutable { def splitter = new ParIterator with SCPI } - } - - - - - - - - - - diff --git a/src/library/scala/reflect/generic/Scopes.scala b/src/library/scala/reflect/generic/Scopes.scala index 9f8a8ecd19..9aff63d958 100755 --- a/src/library/scala/reflect/generic/Scopes.scala +++ b/src/library/scala/reflect/generic/Scopes.scala @@ -4,7 +4,7 @@ package generic trait Scopes { self: Universe => abstract class AbsScope extends Iterable[Symbol] { - def enter(sym: Symbol): Symbol + private[reflect] def enter(sym: Symbol): Symbol } type Scope <: AbsScope diff --git a/src/library/scala/reflect/generic/Symbols.scala b/src/library/scala/reflect/generic/Symbols.scala index 49cf7df1ef..3614bfdeb4 100755 --- a/src/library/scala/reflect/generic/Symbols.scala +++ b/src/library/scala/reflect/generic/Symbols.scala @@ -27,7 +27,7 @@ trait Symbols { self: Universe => /** The name of the symbol before decoding, e.g. `\$eq\$eq` instead of `==`. */ - def encodedName: String + def encodedName: String = name.toString /** The decoded name of the symbol, e.g. `==` instead of `\$eq\$eq`. */ diff --git a/src/library/scala/reflect/generic/Types.scala b/src/library/scala/reflect/generic/Types.scala index 6dcd90e66c..c0eded6ab7 100755 --- a/src/library/scala/reflect/generic/Types.scala +++ b/src/library/scala/reflect/generic/Types.scala @@ -36,20 +36,21 @@ trait Types { self: Universe => } type Type >: Null <: AbsType + type SingletonType >: Null <: Type val NoType: Type val NoPrefix: Type - type ThisType <: Type + type ThisType <: SingletonType val ThisType: ThisTypeExtractor type TypeRef <: Type val TypeRef: TypeRefExtractor - type SingleType <: Type + type SingleType <: SingletonType val SingleType: SingleTypeExtractor - type SuperType <: Type + type SuperType <: SingletonType val SuperType: SuperTypeExtractor type TypeBounds <: Type diff --git a/src/library/scala/runtime/RichInt.scala b/src/library/scala/runtime/RichInt.scala index 771d430c92..cb02b6d3a8 100644 --- a/src/library/scala/runtime/RichInt.scala +++ b/src/library/scala/runtime/RichInt.scala @@ -10,6 +10,7 @@ package scala.runtime import scala.collection.immutable.Range +import annotation.bridge // Note that this does not implement IntegralProxy[Int] so that it can return // the Int-specific Range class from until/to. @@ -20,10 +21,16 @@ final class RichInt(val self: Int) extends ScalaNumberProxy[Int] with RangedProx def until(end: Int): Range = Range(self, end) def until(end: Int, step: Int): Range = Range(self, end, step) + @bridge + def until(end: Int): Range with Range.ByOne = new Range(self, end, 1) with Range.ByOne + /** like `until`, but includes the last index */ def to(end: Int): Range.Inclusive = Range.inclusive(self, end) def to(end: Int, step: Int): Range.Inclusive = Range.inclusive(self, end, step) + @bridge + def to(end: Int): Range with Range.ByOne = new Range.Inclusive(self, end, 1) with Range.ByOne + override def min(that: Int): Int = if (self < that) self else that override def max(that: Int): Int = if (self > that) self else that override def abs: Int = if (self < 0) -self else self diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/util/automata/BaseBerrySethi.scala index c6a3d40c4f..4b1003ba33 100644 --- a/src/library/scala/util/automata/BaseBerrySethi.scala +++ b/src/library/scala/util/automata/BaseBerrySethi.scala @@ -85,14 +85,12 @@ abstract class BaseBerrySethi { case x: Meta => compFollow1(fol1, x.r) case x: Star => compFollow1(fol1 ++ compFirst(x.r), x.r) case x: Sequ => - var first = emptySet x.rs.foldRight(fol1) { (p, fol) => val first = compFollow1(fol, p) if (p.isNullable) fol ++ first else first } - first case _ => throw new IllegalArgumentException("unexpected pattern: " + r.getClass()) } diff --git a/src/swing/scala/swing/Component.scala b/src/swing/scala/swing/Component.scala index b7a93ef448..fc4936cfde 100644 --- a/src/swing/scala/swing/Component.scala +++ b/src/swing/scala/swing/Component.scala @@ -122,7 +122,7 @@ abstract class Component extends UIElement { - @deprecated("Use mouse instead") lazy val Mouse = mouse + @deprecated("Use mouse instead", "2.8.0") lazy val Mouse = mouse /** * Contains publishers for various mouse events. They are separated for diff --git a/src/swing/scala/swing/GUIApplication.scala b/src/swing/scala/swing/GUIApplication.scala index 23844bb063..8c63115707 100644 --- a/src/swing/scala/swing/GUIApplication.scala +++ b/src/swing/scala/swing/GUIApplication.scala @@ -16,7 +16,7 @@ import javax.swing._ /** * Convenience class with utility methods for GUI applications. */ -@deprecated("Use SwingApplication instead") class GUIApplication { +@deprecated("Use SwingApplication instead", "2.8.0") class GUIApplication { /** * Called before the GUI is created. Override to customize. diff --git a/src/swing/scala/swing/ListView.scala b/src/swing/scala/swing/ListView.scala index 0c019f773c..c5a50752ea 100644 --- a/src/swing/scala/swing/ListView.scala +++ b/src/swing/scala/swing/ListView.scala @@ -195,13 +195,13 @@ class ListView[A] extends Component { object indices extends Indices(peer.getSelectedIndices) { def -=(n: Int): this.type = { peer.removeSelectionInterval(n,n); this } def +=(n: Int): this.type = { peer.addSelectionInterval(n,n); this } - @deprecated("Use ListView.selection.leadIndex") + @deprecated("Use ListView.selection.leadIndex", "2.8.0") def leadIndex: Int = peer.getSelectionModel.getLeadSelectionIndex - @deprecated("Use ListView.selection.anchorIndex") + @deprecated("Use ListView.selection.anchorIndex", "2.8.0") def anchorIndex: Int = peer.getSelectionModel.getAnchorSelectionIndex } - @deprecated("Use ListView.selectIndices") + @deprecated("Use ListView.selectIndices", "2.8.0") def selectIndices(ind: Int*) = peer.setSelectedIndices(ind.toArray) /** @@ -209,9 +209,9 @@ class ListView[A] extends Component { */ object items extends scala.collection.SeqProxy[A] { def self = peer.getSelectedValues.map(_.asInstanceOf[A]) - @deprecated("Use ListView.selection.leadIndex") + @deprecated("Use ListView.selection.leadIndex", "2.8.0") def leadIndex: Int = peer.getSelectionModel.getLeadSelectionIndex - @deprecated("Use ListView.selection.anchorIndex") + @deprecated("Use ListView.selection.anchorIndex", "2.8.0") def anchorIndex: Int = peer.getSelectionModel.getAnchorSelectionIndex } diff --git a/src/swing/scala/swing/SimpleGUIApplication.scala b/src/swing/scala/swing/SimpleGUIApplication.scala index 5f32a63afe..74d5d5ee04 100644 --- a/src/swing/scala/swing/SimpleGUIApplication.scala +++ b/src/swing/scala/swing/SimpleGUIApplication.scala @@ -21,7 +21,7 @@ import javax.swing._ * the EDT (see Swing.onEDT and Swing.onEDTWait). Lazy values are okay for the same reason * if they are initialized on the EDT always. */ -@deprecated("Use SimpleSwingApplication instead") abstract class SimpleGUIApplication extends GUIApplication { +@deprecated("Use SimpleSwingApplication instead", "2.8.0") abstract class SimpleGUIApplication extends GUIApplication { /** * A GUI application's version of the main method. Called by the default diff --git a/src/swing/scala/swing/UIElement.scala b/src/swing/scala/swing/UIElement.scala index 5f1d39bb64..8e34b0c38c 100644 --- a/src/swing/scala/swing/UIElement.scala +++ b/src/swing/scala/swing/UIElement.scala @@ -100,7 +100,7 @@ trait UIElement extends Proxy with LazyPublisher { def bounds = peer.getBounds def size = peer.getSize @deprecated("Explicit size assignement for UIElements is not supported anymore. " + - "Use a layout manager or subclass Window.") + "Use a layout manager or subclass Window.", "2.8.0") def size_=(dim: Dimension) = peer.setSize(dim) def locale = peer.getLocale diff --git a/src/swing/scala/swing/event/ComponentEvent.scala b/src/swing/scala/swing/event/ComponentEvent.scala index f312cb33d8..d8cff46168 100644 --- a/src/swing/scala/swing/event/ComponentEvent.scala +++ b/src/swing/scala/swing/event/ComponentEvent.scala @@ -15,11 +15,11 @@ trait ComponentEvent extends UIEvent { val source: Component } -@deprecated("Use UIElementMoved instead.") +@deprecated("Use UIElementMoved instead.", "2.8.0") case class ComponentMoved(source: Component) extends ComponentEvent -@deprecated("Use UIElementResized instead.") +@deprecated("Use UIElementResized instead.", "2.8.0") case class ComponentResized(source: Component) extends ComponentEvent -@deprecated("Use UIElementShown instead.") +@deprecated("Use UIElementShown instead.", "2.8.0") case class ComponentShown(source: Component) extends ComponentEvent -@deprecated("Use UIElementHidden instead.") +@deprecated("Use UIElementHidden instead.", "2.8.0") case class ComponentHidden(source: Component) extends ComponentEvent diff --git a/test/files/neg/bug1333.check b/test/files/neg/bug1333.check deleted file mode 100644 index 11ba633194..0000000000 --- a/test/files/neg/bug1333.check +++ /dev/null @@ -1,4 +0,0 @@ -bug1333.scala:1: error: case classes limited by implementation: maximum of 2 constructor parameter lists. -case class A(a: Int)(b: Int)(c: Int) - ^ -one error found diff --git a/test/files/neg/bug1333.scala b/test/files/neg/bug1333.scala deleted file mode 100644 index e16b38cefc..0000000000 --- a/test/files/neg/bug1333.scala +++ /dev/null @@ -1 +0,0 @@ -case class A(a: Int)(b: Int)(c: Int) diff --git a/test/files/neg/unit-returns-value.check b/test/files/neg/unit-returns-value.check new file mode 100644 index 0000000000..18368f45ab --- /dev/null +++ b/test/files/neg/unit-returns-value.check @@ -0,0 +1,4 @@ +unit-returns-value.scala:4: error: enclosing method f has result type Unit: return value discarded + if (b) return 5 + ^ +one error found diff --git a/test/files/neg/unit-returns-value.flags b/test/files/neg/unit-returns-value.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/unit-returns-value.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/unit-returns-value.scala b/test/files/neg/unit-returns-value.scala new file mode 100644 index 0000000000..27a1111c5b --- /dev/null +++ b/test/files/neg/unit-returns-value.scala @@ -0,0 +1,11 @@ +object Test { + def f { + var b = false + if (b) return 5 + } + + // no warning + def g { + return println("hello") + } +} diff --git a/test/files/pos/bug3972.scala b/test/files/pos/bug3972.scala new file mode 100644 index 0000000000..5dfc10fcef --- /dev/null +++ b/test/files/pos/bug3972.scala @@ -0,0 +1,11 @@ +object CompilerCrash { + def main(args: Array[String]) { + args match { + case Array("a", a @ _*) => { } // The code compiles fine if this line is commented out or "@ _*" is deleted or this line is swapped for the next line + case Array("b") => { } // The code compiles fine if this line is commented out + case Array("c", c) => { + 0 // The code compiles fine if this line is commented out + } + } + } +} diff --git a/test/files/pos/bug4269.scala b/test/files/pos/bug4269.scala new file mode 100644 index 0000000000..99a30785b4 --- /dev/null +++ b/test/files/pos/bug4269.scala @@ -0,0 +1,5 @@ +class A { + PartialFunction.condOpt(Nil) { + case items@List(_*) if true => + } +} diff --git a/test/files/run/bug1333.check b/test/files/run/bug1333.check new file mode 100644 index 0000000000..6303af7f1c --- /dev/null +++ b/test/files/run/bug1333.check @@ -0,0 +1,3 @@ +10 +-10 +-1 diff --git a/test/files/run/bug1333.scala b/test/files/run/bug1333.scala new file mode 100644 index 0000000000..1696629cbb --- /dev/null +++ b/test/files/run/bug1333.scala @@ -0,0 +1,14 @@ +object Test { + case class A(x: Int)(y: Int)(z: String) + + def f(x: Any) = x match { + case A(x) => x + case _ => -1 + } + + def main(args: Array[String]): Unit = { + println(f(A(10)(20)("abc"))) + println(f(A(-10)(20)("abc"))) + println(f(List(1))) + } +} diff --git a/test/files/run/bug2800.check b/test/files/run/bug2800.check new file mode 100644 index 0000000000..546ee52413 --- /dev/null +++ b/test/files/run/bug2800.check @@ -0,0 +1,14 @@ +false +false +List() +false +false +false +false +Vector(1) +false +false +true +false +false +false diff --git a/test/files/run/bug2800.scala b/test/files/run/bug2800.scala new file mode 100644 index 0000000000..84d1de0507 --- /dev/null +++ b/test/files/run/bug2800.scala @@ -0,0 +1,36 @@ +object Test { + def f1 = ("": Any) match { case List(x @ _*) => x ; case _ => false } + def f2 = (5: Any) match { case List(x @ _*) => x ; case _ => false } + def f3 = (Nil: Any) match { case List(x @ _*) => x ; case _ => false } + def f4 = (Array(1): Any) match { case List(x @ _*) => x ; case _ => false } + + def f5 = ("": Any) match { case Array(x @ _*) => x ; case _ => false } + def f6 = (5: Any) match { case Array(x @ _*) => x ; case _ => false } + def f7 = (Nil: Any) match { case Array(x @ _*) => x ; case _ => false } + def f8 = (Array(1): Any) match { case Array(x @ _*) => x ; case _ => false } + + def f9 = ("": Any) match { case x @ List(_*) => x ; case _ => false } + def f10 = ("": Any) match { case List(_*) => true ; case _ => false } + def f11 = (Nil: Any) match { case List(_*) => true ; case _ => false } + def f12 = ("": Any) match { case x @ Array(_*) => x ; case _ => false } + def f13 = ("": Any) match { case Array(_*) => true ; case _ => false } + def f14 = (Nil: Any) match { case Array(_*) => true ; case _ => false } + + + def main(args: Array[String]): Unit = { + println(f1) + println(f2) + println(f3) + println(f4) + println(f5) + println(f6) + println(f7) + println(f8) + println(f9) + println(f10) + println(f11) + println(f12) + println(f13) + println(f14) + } +} diff --git a/test/pending/run/bug3050.scala b/test/files/run/bug3050.scala index aaec99ec14..d1f3f13bec 100644 --- a/test/pending/run/bug3050.scala +++ b/test/files/run/bug3050.scala @@ -4,6 +4,6 @@ object Test { try { ("": Any) match { case List(_*) => true } } catch { case _ => false } - assert(x == false) + assert(!x) } } diff --git a/test/files/run/bug3530.check b/test/files/run/bug3530.check index 633c15d9d7..1f906680e9 100644 --- a/test/files/run/bug3530.check +++ b/test/files/run/bug3530.check @@ -1 +1,12 @@ -Some List +two +three +list: 4 +list: 0 +list: 5 +not a list + +two +three +list: 4 +list: 0 +list: 5 diff --git a/test/files/run/bug3530.scala b/test/files/run/bug3530.scala index f2c0034691..f6f7fb4229 100644 --- a/test/files/run/bug3530.scala +++ b/test/files/run/bug3530.scala @@ -1,9 +1,35 @@ object Test { + def f(x: Any) = println(x match { + case List(_, _) => "two" + case List(_, _, _) => "three" + case xs @ List(_*) => "list: " + xs.length + case _ => "not a list" + }) + + def f2[T](x: List[T]) = println(x match { + case List(_, _) => "two" + case List(_, _, _) => "three" + case List(xs @ _*) => "list: " + xs.length + // bug: the default case is marked unreachable + // case _ => "not a list" + }) + def main(args: Array[String]) { - val list = List(1,2,3) - list match { - case List(_, _) => println("List with two elements") - case List(_*) => println("Some List") - } + f(List(1, 2)) + f(List('a', 'b', 'c')) + f(List('a', 'b', 'c', 'd')) + f(Nil) + f(List(1,2,3,4,5)) + f(null) + + println + + f2(List(1, 2)) + f2(List('a', 'b', 'c')) + f2(List('a', 'b', 'c', 'd')) + f2(Nil) + f2(List(1,2,3,4,5)) + // bug: this NPEs on xs.length + // f2(null) } }
\ No newline at end of file diff --git a/test/files/jvm/interpreter.scala b/test/pending/jvm/interpreter.scala index 752a129950..752a129950 100644 --- a/test/files/jvm/interpreter.scala +++ b/test/pending/jvm/interpreter.scala |