diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 23d517eba97e..7347249b7668 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -412,8 +412,6 @@ trait Definitions extends reflect.api.StandardDefinitions { lazy val JavaRepeatedParamClass = specialPolyClass(tpnme.JAVA_REPEATED_PARAM_CLASS_NAME, COVARIANT)(tparam => arrayType(tparam.tpe)) lazy val RepeatedParamClass = specialPolyClass(tpnme.REPEATED_PARAM_CLASS_NAME, COVARIANT)(tparam => seqType(tparam.tpe)) - lazy val MarkerCPSTypes = getClassIfDefined("scala.util.continuations.cpsParam") - def isByNameParamType(tp: Type) = tp.typeSymbol == ByNameParamClass def isScalaRepeatedParamType(tp: Type) = tp.typeSymbol == RepeatedParamClass def isJavaRepeatedParamType(tp: Type) = tp.typeSymbol == JavaRepeatedParamClass diff --git a/src/compiler/scala/reflect/internal/Flags.scala b/src/compiler/scala/reflect/internal/Flags.scala index c6901d1cf655..e6820cf78a9d 100644 --- a/src/compiler/scala/reflect/internal/Flags.scala +++ b/src/compiler/scala/reflect/internal/Flags.scala @@ -260,7 +260,7 @@ class Flags extends ModifierFlags { /** When a symbol for a default getter is created, it inherits these * flags from the method with the default. Other flags applied at creation - * time are SYNTHETIC, DEFAULTPARAM, and possibly OVERRIDE. + * time are SYNTHETIC, DEFAULTPARAM, and possibly OVERRIDE, and maybe PRESUPER. */ final val DefaultGetterFlags = PRIVATE | PROTECTED | FINAL diff --git a/src/compiler/scala/reflect/internal/Required.scala b/src/compiler/scala/reflect/internal/Required.scala index ba6d65a306a3..6d146354a388 100644 --- a/src/compiler/scala/reflect/internal/Required.scala +++ b/src/compiler/scala/reflect/internal/Required.scala @@ -5,10 +5,7 @@ import settings.MutableSettings trait Required { self: SymbolTable => - type AbstractFileType >: Null <: { - def path: String - def canonicalPath: String - } + type AbstractFileType >: Null <: api.RequiredFile def picklerPhase: Phase diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala index 2c2a8a1b8706..5b91270de1bf 100644 --- a/src/compiler/scala/reflect/internal/StdNames.scala +++ b/src/compiler/scala/reflect/internal/StdNames.scala @@ -272,6 +272,7 @@ trait StdNames { val BITMAP_PREFIX = "bitmap$" val CHECK_IF_REFUTABLE_STRING = "check$ifrefutable$" val DEFAULT_GETTER_STRING = "$default$" + val DEFAULT_GETTER_INIT_STRING = "$lessinit$greater" // CONSTRUCTOR.encoded, less is more val DO_WHILE_PREFIX = "doWhile$" val EVIDENCE_PARAM_PREFIX = "evidence$" val EXCEPTION_RESULT_PREFIX = "exceptionResult" @@ -413,14 +414,19 @@ trait StdNames { name.subName(0, name.length - SETTER_SUFFIX.length) } + // Nominally, name$default$N, encoded for def defaultGetterName(name: Name, pos: Int): TermName = { - val prefix = if (isConstructorName(name)) "init" else name + val prefix = if (isConstructorName(name)) DEFAULT_GETTER_INIT_STRING else name newTermName(prefix + DEFAULT_GETTER_STRING + pos) } + // Nominally, name from name$default$N, CONSTRUCTOR for def defaultGetterToMethod(name: Name): TermName = { val p = name.pos(DEFAULT_GETTER_STRING) - if (p < name.length) name.toTermName.subName(0, p) - else name.toTermName + if (p < name.length) { + val q = name.toTermName.subName(0, p) + // i.e., if (q.decoded == CONSTRUCTOR.toString) CONSTRUCTOR else q + if (q.toString == DEFAULT_GETTER_INIT_STRING) CONSTRUCTOR else q + } else name.toTermName } // If the name ends with $nn where nn are diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/compiler/scala/reflect/internal/SymbolTable.scala index 9158c2a4d4c9..aa60fb4aba45 100644 --- a/src/compiler/scala/reflect/internal/SymbolTable.scala +++ b/src/compiler/scala/reflect/internal/SymbolTable.scala @@ -280,16 +280,8 @@ abstract class SymbolTable extends api.Universe object perRunCaches { import java.lang.ref.WeakReference import scala.runtime.ScalaRunTime.stringOf + import scala.collection.generic.Clearable - import language.reflectiveCalls - - // We can allow ourselves a structural type, these methods - // amount to a few calls per run at most. This does suggest - // a "Clearable" trait may be useful. - private type Clearable = { - def size: Int - def clear(): Unit - } // Weak references so the garbage collector will take care of // letting us know when a cache is really out of commission. private val caches = mutable.HashSet[WeakReference[Clearable]]() @@ -298,10 +290,14 @@ abstract class SymbolTable extends api.Universe println(caches.size + " structures are in perRunCaches.") caches.zipWithIndex foreach { case (ref, index) => val cache = ref.get() - println("(" + index + ")" + ( - if (cache == null) " has been collected." - else " has " + cache.size + " entries:\n" + stringOf(cache) - )) + cache match { + case xs: Traversable[_] => + println("(" + index + ")" + ( + if (cache == null) " has been collected." + else " has " + xs.size + " entries:\n" + stringOf(xs) + )) + case _ => + } } } // if (settings.debug.value) { @@ -315,8 +311,9 @@ abstract class SymbolTable extends api.Universe def clearAll() = { if (settings.debug.value) { - val size = caches flatMap (ref => Option(ref.get)) map (_.size) sum; - log("Clearing " + caches.size + " caches totalling " + size + " entries.") + // val size = caches flatMap (ref => Option(ref.get)) map (_.size) sum; + log("Clearing " + caches.size + " caches.") + // totalling " + size + " entries.") } caches foreach { ref => val cache = ref.get() diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 026cd35d23c8..799671f9e381 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -6,7 +6,8 @@ package scala.reflect package internal -import scala.collection.{ mutable, immutable } +import scala.collection.{ mutable, immutable, generic } +import generic.Clearable import scala.ref.WeakReference import mutable.ListBuffer import Flags._ @@ -97,7 +98,7 @@ trait Types extends api.Types { self: SymbolTable => */ private final val propagateParameterBoundsToTypeVars = sys.props contains "scalac.debug.prop-constraints" - protected val enableTypeVarExperimentals = settings.Xexperimental.value || !settings.XoldPatmat.value + protected val enableTypeVarExperimentals = settings.Xexperimental.value /** Empty immutable maps to avoid allocations. */ private val emptySymMap = immutable.Map[Symbol, Symbol]() @@ -115,7 +116,7 @@ trait Types extends api.Types { self: SymbolTable => protected def newUndoLog = new UndoLog - class UndoLog { + class UndoLog extends Clearable { private type UndoPairs = List[(TypeVar, TypeConstraint)] private var log: UndoPairs = List() @@ -139,7 +140,7 @@ trait Types extends api.Types { self: SymbolTable => log ::= ((tv, tv.constr.cloneInternal)) } - private[scala] def clear() { + def clear() { if (settings.debug.value) self.log("Clearing " + log.size + " entries from the undoLog.") @@ -1609,12 +1610,26 @@ trait Types extends api.Types { self: SymbolTable => override def typeConstructor = copyRefinedType(this, parents map (_.typeConstructor), decls) - /* MO to AM: This is probably not correct - * If they are several higher-kinded parents with different bounds we need - * to take the intersection of their bounds - */ - override def normalize = { - if (isHigherKinded) { + final override def normalize: Type = + if (phase.erasedTypes) normalizeImpl + else { + if (normalized eq null) normalized = normalizeImpl + normalized + } + + private var normalized: Type = _ + private def normalizeImpl = { + // TODO see comments around def intersectionType and def merge + def flatten(tps: List[Type]): List[Type] = tps flatMap { case RefinedType(parents, ds) if ds.isEmpty => flatten(parents) case tp => List(tp) } + val flattened = flatten(parents).distinct + if (decls.isEmpty && flattened.tail.isEmpty) { + flattened.head + } else if (flattened != parents) { + refinedType(flattened, if (typeSymbol eq NoSymbol) NoSymbol else typeSymbol.owner, decls, NoPosition) + } else if (isHigherKinded) { + // MO to AM: This is probably not correct + // If they are several higher-kinded parents with different bounds we need + // to take the intersection of their bounds typeFun( typeParams, RefinedType( @@ -1624,8 +1639,7 @@ trait Types extends api.Types { self: SymbolTable => }, decls, typeSymbol)) - } - else super.normalize + } else super.normalize } /** A refined type P1 with ... with Pn { decls } is volatile if @@ -2898,6 +2912,7 @@ trait Types extends api.Types { self: SymbolTable => // existential. // were we compared to skolems at a higher skolemizationLevel? // EXPERIMENTAL: value will not be considered unless enableTypeVarExperimentals is true + // see SI-5729 for why this is still experimental private var encounteredHigherLevel = false private def shouldRepackType = enableTypeVarExperimentals && encounteredHigherLevel @@ -3320,7 +3335,7 @@ trait Types extends api.Types { self: SymbolTable => if (phase.erasedTypes) if (parents.isEmpty) ObjectClass.tpe else parents.head else { - val clazz = owner.newRefinementClass(NoPosition) + val clazz = owner.newRefinementClass(pos) // TODO: why were we passing in NoPosition instead of pos? val result = RefinedType(parents, decls, clazz) clazz.setInfo(result) result diff --git a/src/compiler/scala/reflect/runtime/AbstractFile.scala b/src/compiler/scala/reflect/runtime/AbstractFile.scala index bf3b47298ba6..414bba020b9b 100644 --- a/src/compiler/scala/reflect/runtime/AbstractFile.scala +++ b/src/compiler/scala/reflect/runtime/AbstractFile.scala @@ -1,6 +1,7 @@ -package scala.reflect.runtime +package scala.reflect +package runtime -class AbstractFile(val jfile: java.io.File) { - def path: String = jfile.getPath() - def canonicalPath: String = jfile.getCanonicalPath() -} \ No newline at end of file +class AbstractFile(val jfile: java.io.File) extends api.RequiredFile { + def path: String = jfile.getPath() + def canonicalPath: String = jfile.getCanonicalPath() +} diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 8c6c927640a2..ff092416fde5 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -354,9 +354,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb // where I need it, and then an override in Global with the setting. override protected val etaExpandKeepsStar = settings.etaExpandKeepsStar.value // Here comes another one... - override protected val enableTypeVarExperimentals = ( - settings.Xexperimental.value || !settings.XoldPatmat.value - ) + override protected val enableTypeVarExperimentals = settings.Xexperimental.value // True if -Xscript has been set, indicating a script run. def isScriptRun = opt.script.isDefined @@ -462,6 +460,13 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb val global: Global.this.type = Global.this } with Analyzer + // phaseName = "patmat" + object patmat extends { + val global: Global.this.type = Global.this + val runsAfter = List("typer") + val runsRightAfter = Some("typer") + } with PatternMatching + // phaseName = "superaccessors" object superAccessors extends { val global: Global.this.type = Global.this @@ -682,6 +687,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb analyzer.namerFactory -> "resolve names, attach symbols to named trees", analyzer.packageObjects -> "load package objects", analyzer.typerFactory -> "the meat and potatoes: type the trees", + patmat -> "translate match expressions", superAccessors -> "add super accessors in traits and nested classes", extensionMethods -> "add extension methods for inline classes", pickler -> "serialize symbol tables", diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index b3ed446563c0..028c5741c991 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -383,7 +383,7 @@ trait DocComments { self: Global => } // !!! todo: inherit from Comment? - case class DocComment(raw: String, pos: Position = NoPosition) { + case class DocComment(raw: String, pos: Position = NoPosition, codePos: Position = NoPosition) { /** Returns: * template: the doc comment minus all @define and @usecase sections @@ -412,7 +412,7 @@ trait DocComments { self: Global => val comment = "/** " + raw.substring(commentStart, end) + "*/" val commentPos = subPos(commentStart, end) - UseCase(DocComment(comment, commentPos), code, codePos) + UseCase(DocComment(comment, commentPos, codePos), code, codePos) } private def subPos(start: Int, end: Int) = @@ -461,7 +461,18 @@ trait DocComments { self: Global => findIn(classes ::: List(pkgs.head, definitions.RootClass)) } - def getType(str: String): Type = { + def getType(_str: String, variable: String): Type = { + /* + * work around the backticks issue suggested by Simon in + * https://groups.google.com/forum/?hl=en&fromgroups#!topic/scala-internals/z7s1CCRCz74 + * ideally, we'd have a removeWikiSyntax method in the CommentFactory to completely eliminate the wiki markup + */ + val str = + if (_str.length >= 2 && _str.startsWith("`") && _str.endsWith("`")) + _str.substring(1, _str.length - 2) + else + _str + def getParts(start: Int): List[String] = { val end = skipIdent(str, start) if (end == start) List() @@ -471,7 +482,11 @@ trait DocComments { self: Global => } } val parts = getParts(0) - assert(parts.nonEmpty, "parts is empty '" + str + "' in site " + site) + if (parts.isEmpty) { + reporter.error(comment.codePos, "Incorrect variable expansion for " + variable + " in use case. Does the " + + "variable expand to wiki syntax when documenting " + site + "?") + return ErrorType + } val partnames = (parts.init map newTermName) :+ newTypeName(parts.last) val (start, rest) = parts match { case "this" :: _ => (site.thisType, partnames.tail) @@ -490,7 +505,7 @@ trait DocComments { self: Global => for (alias <- aliases) yield lookupVariable(alias.name.toString.substring(1), site) match { case Some(repl) => - val tpe = getType(repl.trim) + val tpe = getType(repl.trim, alias.name.toString) if (tpe != NoType) tpe else { val alias1 = alias.cloneSymbol(definitions.RootClass, alias.rawflags, newTypeName(repl)) diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 34b37073fd35..a355db4d9a8d 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -234,6 +234,11 @@ trait Trees extends reflect.internal.Trees { self: Global => } } + // used when a phase is disabled + object noopTransformer extends Transformer { + override def transformUnit(unit: CompilationUnit): Unit = {} + } + override protected def xtransform(transformer: super.Transformer, tree: Tree): Tree = tree match { case DocDef(comment, definition) => transformer.treeCopy.DocDef(tree, comment, transformer.transform(definition)) diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 5e5b09405c1f..4aeb537f9b8d 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -821,7 +821,7 @@ abstract class GenICode extends SubComponent { ctx2 case _ => - abort("Cannot instantiate " + tpt + "of kind: " + generatedType) + abort("Cannot instantiate " + tpt + " of kind: " + generatedType) } case Apply(fun @ _, List(expr)) if (definitions.isBox(fun.symbol)) => 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 d3f42ffe6e13..4463857aa559 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -70,8 +70,7 @@ class Template(universe: doc.Universe, tpl: DocTemplateEntity) extends HtmlPage

{ templatesToHtml(tpl.inTemplate.toRoot.reverse.tail, xml.Text(".")) }

} - +
{ tpl.companion match { diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js index e9ed7181e48d..b767722b8c3e 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js @@ -454,7 +454,7 @@ function resizeFilterBlock() { function printAlphabet() { var html = '#'; var c; - for (c = 'a'; c < 'z'; c = String.fromCharCode(c.charCodeAt(0) + 1)) { + for (c = 'a'; c <= 'z'; c = String.fromCharCode(c.charCodeAt(0) + 1)) { html += [ ' Tree): Tree = { - val casesNoSynthCatchAll = dropSyntheticCatchAll(cases) - if (casesNoSynthCatchAll exists treeInfo.isDefaultCase) orig - else { - val defaultCase = CaseDef(Ident(nme.WILDCARD), EmptyTree, defaultAction(selector.duplicate)) - wrap(Match(/*gen.mkUnchecked*/(selector), casesNoSynthCatchAll :+ defaultCase)) - } - } - override def caseVirtualizedMatch(orig: Tree, _match: Tree, targs: List[Tree], scrut: Tree, matcher: Tree): Tree = { import CODE._ - ((matcher APPLY (scrut)) DOT nme.getOrElse) APPLY (defaultAction(scrut.duplicate)) // TODO: pass targs - } - override def caseVirtualizedMatchOpt(orig: Tree, prologue: List[Tree], cases: List[Tree], matchEndDef: Tree, wrap: Tree => Tree): Tree = { import CODE._ - val scrutRef = REF(prologue.head.symbol) // scrut valdef is always emitted (except for nested matchers that handle alternatives) - - val casesNewSynthCatchAll = cases.init :+ (deriveLabelDef(cases.last){ - case Apply(matchEnd, List(Throw(Apply(Select(New(exTpt), nme.CONSTRUCTOR), _)))) if exTpt.tpe.typeSymbol eq MatchErrorClass => - assert(matchEnd.symbol == matchEndDef.symbol, "matchEnd discrepancy "+(matchEnd, matchEndDef)) - matchEnd APPLY (defaultAction(scrutRef)) - case x => x - } setSymbol cases.last.symbol setType null) - - val LabelDef(_, List(matchRes), rhs) = matchEndDef - val matchEnd = matchEndDef.symbol - matchRes setType B1.tpe - rhs setType B1.tpe - matchEndDef setType B1.tpe - matchRes.symbol setInfo B1.tpe - matchEnd setInfo MethodType(List(matchRes.symbol), B1.tpe) - cases foreach (c => c.symbol setInfo MethodType(List(), B1.tpe)) - - wrap(Block(prologue ++ casesNewSynthCatchAll, matchEndDef)) - } - } + localTyper.typedPos(fun.pos) { + Block( + List(ClassDef(anonClass, NoMods, List(List()), List(List()), List(applyMethodDef), fun.pos)), + Typed(New(anonClass.tpe), TypeTree(fun.tpe))) + } - withDefaultTransformer(substParam(fun.body)) - } - body.changeOwner(fun.symbol -> methSym) + } - val methDef = DefDef(methSym, body) + def synthPartialFunction(fun: Function) = { + if (!settings.XoldPatmat.value) debugwarn("Under the new pattern matching scheme, PartialFunction should have been synthesized during typers.") + + val targs = fun.tpe.typeArgs + val (formals, restpe) = (targs.init, targs.last) + + val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation serialVersionUIDAnnotation + val parents = List(appliedType(AbstractPartialFunctionClass, targs: _*), SerializableClass.tpe) + anonClass setInfo ClassInfoType(parents, newScope, anonClass) + + // duplicate before applyOrElseMethodDef is run so that it does not mess up our trees and label symbols (we have a fresh set) + // otherwise `TreeSymSubstituter(fun.vparams map (_.symbol), params)` won't work as the subst has been run already + val bodyForIDA = { + val duped = fun.body.duplicate + val oldParams = new mutable.ListBuffer[Symbol]() + val newParams = new mutable.ListBuffer[Symbol]() + + val oldSyms0 = + duped filter { + case l@LabelDef(_, params, _) => + params foreach {p => + val oldSym = p.symbol + p.symbol = oldSym.cloneSymbol + oldParams += oldSym + newParams += p.symbol + } + true + case _ => false + } map (_.symbol) + val oldSyms = oldParams.toList ++ oldSyms0 + val newSyms = newParams.toList ++ (oldSyms0 map (_.cloneSymbol)) + // println("duping "+ oldSyms +" --> "+ (newSyms map (_.ownerChain))) - // Have to repack the type to avoid mismatches when existentials - // appear in the result - see SI-4869. - methDef.tpt setType localTyper.packedType(body, methSym) - methDef - } + val substLabels = new TreeSymSubstituter(oldSyms, newSyms) - // duplicate before applyOrElseMethodDef is run so that it does not mess up our trees and label symbols (we have a fresh set) - // otherwise `TreeSymSubstituter(fun.vparams map (_.symbol), params)` won't work as the subst has been run already - val bodyForIDA = { - val duped = fun.body.duplicate - val oldParams = new mutable.ListBuffer[Symbol]() - val newParams = new mutable.ListBuffer[Symbol]() - - val oldSyms0 = - duped filter { - case l@LabelDef(_, params, _) => - params foreach {p => - val oldSym = p.symbol - p.symbol = oldSym.cloneSymbol - oldParams += oldSym - newParams += p.symbol - } - true - case _ => false - } map (_.symbol) - val oldSyms = oldParams.toList ++ oldSyms0 - val newSyms = newParams.toList ++ (oldSyms0 map (_.cloneSymbol)) - // println("duping "+ oldSyms +" --> "+ (newSyms map (_.ownerChain))) + substLabels(duped) + } - val substLabels = new TreeSymSubstituter(oldSyms, newSyms) + // def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = + val applyOrElseMethodDef = { + val methSym = anonClass.newMethod(fun.pos, nme.applyOrElse) setFlag (FINAL | OVERRIDE) + + val List(argtpe) = formals + val A1 = methSym newTypeParameter(newTypeName("A1")) setInfo TypeBounds.upper(argtpe) + val B1 = methSym newTypeParameter(newTypeName("B1")) setInfo TypeBounds.lower(restpe) + val methFormals = List(A1.tpe, functionType(List(A1.tpe), B1.tpe)) + val params@List(x, default) = methSym newSyntheticValueParams methFormals + methSym setInfoAndEnter polyType(List(A1, B1), MethodType(params, B1.tpe)) + + val substParam = new TreeSymSubstituter(fun.vparams map (_.symbol), List(x)) + val body = localTyper.typedPos(fun.pos) { import CODE._ + def defaultAction(scrut: Tree) = REF(default) APPLY (REF(x)) + + substParam(fun.body) match { + case orig@Match(selector, cases) => + if (cases exists treeInfo.isDefaultCase) orig + else { + val defaultCase = CaseDef(Ident(nme.WILDCARD), EmptyTree, defaultAction(selector.duplicate)) + Match(/*gen.mkUnchecked*/(selector), cases :+ defaultCase) + } - substLabels(duped) } + } + body.changeOwner(fun.symbol -> methSym) - def isDefinedAtMethodDef = { - val methSym = anonClass.newMethod(nme.isDefinedAt, fun.pos, FINAL) - val params = methSym newSyntheticValueParams formals - methSym setInfoAndEnter MethodType(params, BooleanClass.tpe) - - val substParam = new TreeSymSubstituter(fun.vparams map (_.symbol), params) - def doSubst(x: Tree) = substParam(resetLocalAttrsKeepLabels(x)) // see pos/t1761 for why `resetLocalAttrs`, but must keep label symbols around - - object isDefinedAtTransformer extends gen.MatchMatcher { - // TODO: optimize duplication, but make sure ValDef's introduced by wrap are treated correctly - override def caseMatch(orig: Tree, selector: Tree, cases: List[CaseDef], wrap: Tree => Tree): Tree = { import CODE._ - val casesNoSynthCatchAll = dropSyntheticCatchAll(cases) - if (casesNoSynthCatchAll exists treeInfo.isDefaultCase) TRUE_typed - else - doSubst(wrap( - Match(/*gen.mkUnchecked*/(selector), - (casesNoSynthCatchAll map (c => deriveCaseDef(c)(x => TRUE_typed))) :+ ( - DEFAULT ==> FALSE_typed) - ))) - } - override def caseVirtualizedMatch(orig: Tree, _match: Tree, targs: List[Tree], scrut: Tree, matcher: Tree): Tree = { - object noOne extends Transformer { - override val treeCopy = newStrictTreeCopier // must duplicate everything - val one = _match.tpe member newTermName("one") - override def transform(tree: Tree): Tree = tree match { - case Apply(fun, List(a)) if fun.symbol == one => - // blow one's argument away since all we want to know is whether the match succeeds or not - // (the alternative, making `one` CBN, would entail moving away from Option) - Apply(fun.duplicate, List(gen.mkZeroContravariantAfterTyper(a.tpe))) - case _ => - super.transform(tree) - } - } - doSubst(Apply(Apply(TypeApply(Select(_match.duplicate, _match.tpe.member(newTermName("isSuccess"))), targs map (_.duplicate)), List(scrut.duplicate)), List(noOne.transform(matcher)))) - } + val methDef = DefDef(methSym, body) - override def caseVirtualizedMatchOpt(orig: Tree, prologue: List[Tree], cases: List[Tree], matchEndDef: Tree, wrap: Tree => Tree) = { - val matchEnd = matchEndDef.symbol - val LabelDef(_, List(matchRes), rhs) = matchEndDef - matchRes setType BooleanClass.tpe - rhs setType BooleanClass.tpe - matchEndDef setType BooleanClass.tpe - matchRes.symbol setInfo BooleanClass.tpe - matchEnd setInfo MethodType(List(matchRes.symbol), BooleanClass.tpe) - cases foreach (c => c.symbol setInfo MethodType(List(), BooleanClass.tpe)) - // println("matchEnd: "+ matchEnd) - - // when the type of the selector contains a skolem owned by the applyOrElseMethod, should reskolemize everything, - // for now, just cast the RHS (since we're just trying to keep the typer happy, the cast is meaningless) - // ARGH -- this is why I would prefer the typedMatchAnonFun approach (but alas, CPS blocks that) - val newPrologue = prologue match { - case List(vd@ValDef(mods, name, tpt, rhs)) => List(treeCopy.ValDef(vd, mods, name, tpt, gen.mkAsInstanceOf(rhs, tpt.tpe, true, false))) - case _ => prologue - } - object casesReturnTrue extends Transformer { - // override val treeCopy = newStrictTreeCopier // will duplicate below - override def transform(tree: Tree): Tree = tree match { - // don't compute the result of the match, return true instead - case Apply(fun, List(res)) if fun.symbol eq matchEnd => - // println("matchend call "+ fun.symbol) - Apply(fun, List(TRUE_typed)) setType BooleanClass.tpe - case _ => super.transform(tree) - } - } - val newCatchAll = cases.last match { - case LabelDef(n, ps, Apply(matchEnd1, List(Throw(Apply(Select(New(exTpt), nme.CONSTRUCTOR), _))))) if exTpt.tpe.typeSymbol eq MatchErrorClass => - assert(matchEnd1.symbol == matchEnd, "matchEnd discrepancy "+(matchEnd, matchEndDef)) - List(treeCopy.LabelDef(cases.last, n, ps, matchEnd APPLY (FALSE_typed)) setSymbol cases.last.symbol) - case x => Nil - } - val casesWithoutCatchAll = if(newCatchAll.isEmpty) cases else cases.init - doSubst(wrap(Block(newPrologue ++ casesReturnTrue.transformTrees(casesWithoutCatchAll) ++ newCatchAll, matchEndDef))) - - // val duped = idaBlock //.duplicate // TODO: duplication of labeldefs is BROKEN - // duped foreach { - // case l@LabelDef(name, params, rhs) if gen.hasSynthCaseSymbol(l) => println("newInfo"+ l.symbol.info) - // case _ => - // } - } - } + // Have to repack the type to avoid mismatches when existentials + // appear in the result - see SI-4869. + methDef.tpt setType localTyper.packedType(body, methSym) + methDef + } - val body = isDefinedAtTransformer(bodyForIDA) - body.changeOwner(fun.symbol -> methSym) + val isDefinedAtMethodDef = { + val methSym = anonClass.newMethod(nme.isDefinedAt, fun.pos, FINAL) + val params = methSym newSyntheticValueParams formals + methSym setInfoAndEnter MethodType(params, BooleanClass.tpe) - DefDef(methSym, body) - } + val substParam = new TreeSymSubstituter(fun.vparams map (_.symbol), params) + def doSubst(x: Tree) = substParam(resetLocalAttrsKeepLabels(x)) // see pos/t1761 for why `resetLocalAttrs`, but must keep label symbols around - val members = - if (isPartial) { - assert(!opt.virtPatmat, "PartialFunction should have been synthesized during typer "+ fun); - List(applyOrElseMethodDef, isDefinedAtMethodDef) - } else List(applyMethodDef) + val body = bodyForIDA match { + case Match(selector, cases) => + if (cases exists treeInfo.isDefaultCase) TRUE_typed + else + doSubst(Match(/*gen.mkUnchecked*/(selector), + (cases map (c => deriveCaseDef(c)(x => TRUE_typed))) :+ ( + DEFAULT ==> FALSE_typed))) - // println("MEMBERS "+ members) - val res = localTyper.typedPos(fun.pos) { - Block( - List(ClassDef(anonClass, NoMods, List(List()), List(List()), members, fun.pos)), - Typed(New(anonClass.tpe), TypeTree(fun.tpe))) - } - // println("MEMBERS TYPED "+ members) - res } + body.changeOwner(fun.symbol -> methSym) + + DefDef(methSym, body) + } + + localTyper.typedPos(fun.pos) { + Block( + List(ClassDef(anonClass, NoMods, List(List()), List(List()), List(applyOrElseMethodDef, isDefinedAtMethodDef), fun.pos)), + Typed(New(anonClass.tpe), TypeTree(fun.tpe))) + } + } def transformArgs(pos: Position, fun: Symbol, args: List[Tree], formals: List[Type]) = { val isJava = fun.isJavaDefined diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 4c717729290c..7dc105690cac 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -248,13 +248,12 @@ trait MethodSynthesis { else List(Getter(vd)) ) def beanAccessors(vd: ValDef): List[DerivedFromValDef] = { + val setter = if (vd.mods.isMutable) List(BeanSetter(vd)) else Nil if (forMSIL) Nil - else if (vd.symbol hasAnnotation BeanPropertyAttr) { - if (vd.mods.isMutable) List(BeanGetter(vd), BeanSetter(vd)) - else List(BeanGetter(vd)) - } + else if (vd.symbol hasAnnotation BeanPropertyAttr) + BeanGetter(vd) :: setter else if (vd.symbol hasAnnotation BooleanBeanPropertyAttr) - List(BooleanBeanGetter(vd)) + BooleanBeanGetter(vd) :: setter else Nil } def allValDefDerived(vd: ValDef) = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 45f7d7e618d7..4e7dac890b39 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1347,6 +1347,11 @@ trait Namers extends MethodSynthesis { /** Convert Java generic array type T[] to (T with Object)[] * (this is necessary because such arrays have a representation which is incompatible * with arrays of primitive types.) + * + * @note the comparison to Object only works for abstract types bounded by classes that are strict subclasses of Object + * if the bound is exactly Object, it will have been converted to Any, and the comparison will fail + * + * see also sigToType */ private object RestrictJavaArraysMap extends TypeMap { def apply(tp: Type): Type = tp match { diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index 898a9fee9f98..90e388c30a02 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -155,6 +155,8 @@ trait NamesDefaults { self: Analyzer => val sym = blockTyper.context.owner.newValue(unit.freshTermName("qual$"), qual.pos) setInfo qual.tpe blockTyper.context.scope enter sym val vd = atPos(sym.pos)(ValDef(sym, qual) setType NoType) + // it stays in Vegas: SI-5720, SI-5727 + qual changeOwner (blockTyper.context.owner -> sym) var baseFunTransformed = atPos(baseFun.pos.makeTransparent) { // don't use treeCopy: it would assign opaque position. diff --git a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala similarity index 93% rename from src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala rename to src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index e5b5746e8daf..61e02edaff46 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -1,5 +1,6 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * + * Copyright 2012 LAMP/EPFL * @author Adriaan Moors */ @@ -9,32 +10,75 @@ package typechecker import symtab._ import Flags.{MUTABLE, METHOD, LABEL, SYNTHETIC} import language.postfixOps +import scala.tools.nsc.transform.TypingTransformers +import scala.tools.nsc.transform.Transform -/** Translate pattern matching into method calls (these methods form a zero-plus monad), similar in spirit to how for-comprehensions are compiled. +/** Translate pattern matching. + * + * Either into optimized if/then/else's, + * or virtualized as method calls (these methods form a zero-plus monad), similar in spirit to how for-comprehensions are compiled. * * For each case, express all patterns as extractor calls, guards as 0-ary extractors, and sequence them using `flatMap` * (lifting the body of the case into the monad using `one`). * * Cases are combined into a pattern match using the `orElse` combinator (the implicit failure case is expressed using the monad's `zero`). - + * * TODO: - * - interaction with CPS + * - exhaustivity + * - DCE (unreachability/refutability/optimization) + * - use TypeTags for type testing * - Array patterns * - implement spec more closely (see TODO's) - * - DCE - * - use TypeTags for type testing * * (longer-term) TODO: * - user-defined unapplyProd * - recover GADT typing by locally inserting implicit witnesses to type equalities derived from the current case, and considering these witnesses during subtyping (?) * - recover exhaustivity and unreachability checking using a variation on the type-safe builder pattern */ -trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => - import global._ +trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL { // self: Analyzer => + val global: Global // need to repeat here because otherwise last mixin defines global as + // SymbolTable. If we had DOT this would not be an issue + import global._ // the global environment + import definitions._ // standard classes and methods + + val phaseName: String = "patmat" + + def newTransformer(unit: CompilationUnit): Transformer = + if (opt.virtPatmat) new MatchTransformer(unit) + else noopTransformer + + // duplicated from CPSUtils (avoid dependency from compiler -> cps plugin...) + private lazy val MarkerCPSAdaptPlus = definitions.getClassIfDefined("scala.util.continuations.cpsPlus") + private lazy val MarkerCPSAdaptMinus = definitions.getClassIfDefined("scala.util.continuations.cpsMinus") + private lazy val MarkerCPSSynth = definitions.getClassIfDefined("scala.util.continuations.cpsSynth") + private lazy val stripTriggerCPSAnns = List(MarkerCPSSynth, MarkerCPSAdaptMinus, MarkerCPSAdaptPlus) + private lazy val MarkerCPSTypes = definitions.getClassIfDefined("scala.util.continuations.cpsParam") + private lazy val strippedCPSAnns = MarkerCPSTypes :: stripTriggerCPSAnns + private def removeCPSAdaptAnnotations(tp: Type) = tp filterAnnotations (ann => !(strippedCPSAnns exists (ann matches _))) + + class MatchTransformer(unit: CompilationUnit) extends TypingTransformer(unit) { + override def transform(tree: Tree): Tree = tree match { + case Match(sel, cases) => + val origTp = tree.tpe + // setType origTp intended for CPS -- TODO: is it necessary? + localTyper.typed(translator.translateMatch(treeCopy.Match(tree, transform(sel), transformTrees(cases).asInstanceOf[List[CaseDef]]))) setType origTp + case Try(block, catches, finalizer) => + treeCopy.Try(tree, transform(block), translator.translateTry(transformTrees(catches).asInstanceOf[List[CaseDef]], tree.tpe, tree.pos), transform(finalizer)) + case _ => super.transform(tree) + } + + def translator: MatchTranslation with CodegenCore = { + new OptimizingMatchTranslator(localTyper) + } + } + import definitions._ + import analyzer._ //Typer val SYNTH_CASE = Flags.CASE | SYNTHETIC + case class DefaultOverrideMatchAttachment(default: Tree) + object vpmName { val one = newTermName("one") val drop = newTermName("drop") @@ -51,22 +95,6 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => def counted(str: String, i: Int) = newTermName(str+i) } - object MatchTranslator { - def apply(typer: Typer): MatchTranslation with CodegenCore = { - import typer._ - // typing `_match` to decide which MatchTranslator to create adds 4% to quick.comp.timer - val matchStrategy: Tree = ( - if (!context.isNameInScope(vpmName._match)) null // fast path, avoiding the next line if there's no __match to be seen - else newTyper(context.makeImplicit(reportAmbiguousErrors = false)).silent(_.typed(Ident(vpmName._match), EXPRmode, WildcardType), reportAmbiguousErrors = false) match { - case SilentResultValue(ms) => ms - case _ => null - } - ) - if (matchStrategy eq null) new OptimizingMatchTranslator(typer) - else new PureMatchTranslator(typer, matchStrategy) - } - } - class PureMatchTranslator(val typer: Typer, val matchStrategy: Tree) extends MatchTranslation with TreeMakers with PureCodegen class OptimizingMatchTranslator(val typer: Typer) extends MatchTranslation with TreeMakers with MatchOptimizations @@ -136,15 +164,44 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => * thus, you must typecheck the result (and that will in turn translate nested matches) * this could probably optimized... (but note that the matchStrategy must be solved for each nested patternmatch) */ - def translateMatch(scrut: Tree, cases: List[CaseDef], pt: Type, scrutType: Type, matchFailGenOverride: Option[Tree => Tree] = None): Tree = { + def translateMatch(match_ : Match): Tree = { + val Match(selector, cases) = match_ + // we don't transform after uncurry // (that would require more sophistication when generating trees, // and the only place that emits Matches after typers is for exception handling anyway) - if(phase.id >= currentRun.uncurryPhase.id) debugwarn("running translateMatch at "+ phase +" on "+ scrut +" match "+ cases) + if(phase.id >= currentRun.uncurryPhase.id) debugwarn("running translateMatch at "+ phase +" on "+ selector +" match "+ cases) // println("translating "+ cases.mkString("{", "\n", "}")) - val scrutSym = freshSym(scrut.pos, pureType(scrutType)) setFlag SYNTH_CASE + + def repeatedToSeq(tp: Type): Type = (tp baseType RepeatedParamClass) match { + case TypeRef(_, RepeatedParamClass, arg :: Nil) => seqType(arg) + case _ => tp + } + + val selectorTp = repeatedToSeq(elimAnonymousClass(selector.tpe.widen.withoutAnnotations)) + + val origPt = match_.tpe + // when one of the internal cps-type-state annotations is present, strip all CPS annotations + // a cps-type-state-annotated type makes no sense as an expected type (matchX.tpe is used as pt in translateMatch) + // (only test availability of MarkerCPSAdaptPlus assuming they are either all available or none of them are) + val ptUnCPS = + if (MarkerCPSAdaptPlus != NoSymbol && (stripTriggerCPSAnns exists origPt.hasAnnotation)) + removeCPSAdaptAnnotations(origPt) + else origPt + + // we've packed the type for each case in typedMatch so that if all cases have the same existential case, we get a clean lub + // here, we should open up the existential again + // relevant test cases: pos/existentials-harmful.scala, pos/gadt-gilles.scala, pos/t2683.scala, pos/virtpatmat_exist4.scala + // TODO: fix skolemizeExistential (it should preserve annotations, right?) + val pt = repeatedToSeq(ptUnCPS.skolemizeExistential(context.owner, context.tree) withAnnotations ptUnCPS.annotations) + + // the alternative to attaching the default case override would be to simply + // append the default to the list of cases and suppress the unreachable case error that may arise (once we detect that...) + val matchFailGenOverride = match_ firstAttachment {case DefaultOverrideMatchAttachment(default) => ((scrut: Tree) => default)} + + val selectorSym = freshSym(selector.pos, pureType(selectorTp)) setFlag SYNTH_CASE // pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala with -Xexperimental - combineCases(scrut, scrutSym, cases map translateCase(scrutSym, pt), pt, matchOwner, matchFailGenOverride) + combineCases(selector, selectorSym, cases map translateCase(selectorSym, pt), pt, matchOwner, matchFailGenOverride) } // return list of typed CaseDefs that are supported by the backend (typed/bind/wildcard) @@ -231,7 +288,7 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => val pos = patTree.pos def translateExtractorPattern(extractor: ExtractorCall): TranslationStep = { - if (!extractor.isTyped) throw new TypeError(pos, "Could not typecheck extractor call: "+ extractor) + if (!extractor.isTyped) ErrorUtils.issueNormalTypeError(patTree, "Could not typecheck extractor call: "+ extractor)(context) // if (extractor.resultInMonad == ErrorType) throw new TypeError(pos, "Unsupported extractor type: "+ extractor.tpe) // must use type `tp`, which is provided by extractor's result, not the type expected by binder, @@ -296,7 +353,7 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => **/ case Apply(fun, args) => ExtractorCall.fromCaseClass(fun, args) map translateExtractorPattern getOrElse { - error("cannot find unapply member for "+ fun +" with args "+ args) + ErrorUtils.issueNormalTypeError(patTree, "Could not find unapply member for "+ fun +" with args "+ args)(context) noFurtherSubPats() } @@ -552,18 +609,29 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => ProductExtractorTreeMaker(binder, lengthGuard(binder), Substitution(subPatBinders, subPatRefs(binder))) } -/* TODO: remove special case when the following bug is fixed -class Foo(x: Other) { x._1 } // BUG: can't refer to _1 if its defining class has not been type checked yet -case class Other(y: String) --- this is ok: -case class Other(y: String) -class Foo(x: Other) { x._1 } // no error in this order -*/ + // reference the (i-1)th case accessor if it exists, otherwise the (i-1)th tuple component override protected def tupleSel(binder: Symbol)(i: Int): Tree = { import CODE._ - // reference the (i-1)th case accessor if it exists, otherwise the (i-1)th tuple component - val caseAccs = binder.info.typeSymbol.caseFieldAccessors - if (caseAccs isDefinedAt (i-1)) REF(binder) DOT caseAccs(i-1) - else codegen.tupleSel(binder)(i) + // caseFieldAccessors is messed up after typers (reversed, names mangled for non-public fields) + // TODO: figure out why... + val accessors = binder.caseFieldAccessors + // luckily, the constrParamAccessors are still sorted properly, so sort the field-accessors using them + // (need to undo name-mangling, including the sneaky trailing whitespace) + val constrParamAccessors = binder.constrParamAccessors + + def indexInCPA(acc: Symbol) = + constrParamAccessors indexWhere { orig => + // println("compare: "+ (orig, acc, orig.name, acc.name, (acc.name == orig.name), (acc.name startsWith (orig.name append "$")))) + val origName = orig.name.toString.trim + val accName = acc.name.toString.trim + (accName == origName) || (accName startsWith (origName + "$")) + } + + // println("caseFieldAccessors: "+ (accessors, binder.caseFieldAccessors map indexInCPA)) + // println("constrParamAccessors: "+ constrParamAccessors) + + val accessorsSorted = accessors sortBy indexInCPA + if (accessorsSorted isDefinedAt (i-1)) REF(binder) DOT accessorsSorted(i-1) + else codegen.tupleSel(binder)(i) // this won't type check for case classes, as they do not inherit ProductN } override def toString(): String = "case class "+ (if (constructorTp eq null) fun else paramType.typeSymbol) +" with arguments "+ args @@ -863,7 +931,7 @@ class Foo(x: Other) { x._1 } // no error in this order // implements the run-time aspects of (ยง8.2) (typedPattern has already done the necessary type transformations) // TODO: normalize construction, which yields a combination of a EqualityTestTreeMaker (when necessary) and a TypeTestTreeMaker case class TypeAndEqualityTestTreeMaker(prevBinder: Symbol, patBinder: Symbol, pt: Type, pos: Position) extends CondTreeMaker { - val nextBinderTp = glb(List(patBinder.info.widen, pt)) + val nextBinderTp = glb(List(patBinder.info.widen, pt)).normalize /** Type patterns consist of types, type variables, and wildcards. A type pattern T is of one of the following forms: - A reference to a class C, p.C, or T#C. @@ -1586,7 +1654,7 @@ class Foo(x: Other) { x._1 } // no error in this order else (REF(scrutSym) DOT (nme.toInt)) Some(BLOCK( VAL(scrutSym) === scrut, - Match(gen.mkSynthSwitchSelector(scrutToInt), caseDefsWithDefault) // add switch annotation + Match(scrutToInt, caseDefsWithDefault) // a switch )) } } else None diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 31d064c8244d..57e82ed706d6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -299,6 +299,7 @@ trait SyntheticMethods extends ast.TreeDSL { newAcc resetFlag (ACCESSOR | PARAMACCESSOR) ddef.rhs.duplicate } + // TODO: shouldn't the next line be: `original resetFlag CASEACCESSOR`? ddef.symbol resetFlag CASEACCESSOR lb += logResult("case accessor new")(newAcc) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 41b896eb93c3..d7413b48f590 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -26,12 +26,14 @@ import util.Statistics._ * @author Martin Odersky * @version 1.0 */ -trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser { +trait Typers extends Modes with Adaptations with Taggings { self: Analyzer => import global._ import definitions._ + import patmat.DefaultOverrideMatchAttachment + final def forArgMode(fun: Tree, mode: Int) = if (treeInfo.isSelfOrSuperConstrCall(fun)) mode | SCCmode else mode @@ -83,8 +85,11 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser private def isPastTyper = phase.id > currentRun.typerPhase.id - // don't translate matches in presentation compiler: it loses vital symbols that are needed to do hyperlinking - @inline private def doMatchTranslation = !forInteractive && opt.virtPatmat && (phase.id < currentRun.uncurryPhase.id) + // when true: + // - we may virtualize matches (if -Xexperimental and there's a suitable __match in scope) + // - we synthesize PartialFunction implementations for `x => x match {...}` and `match {...}` when the expected type is PartialFunction + // this is disabled by: -Xoldpatmat, scaladoc or interactive compilation + @inline private def newPatternMatching = opt.virtPatmat && !forScaladoc && !forInteractive // && (phase.id < currentRun.uncurryPhase.id) abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with Tagging with TyperContextErrors { import context0.unit @@ -2208,54 +2213,61 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser def adaptCase(cdef: CaseDef, mode: Int, tpe: Type): CaseDef = deriveCaseDef(cdef)(adapt(_, mode, tpe)) + def ptOrLub(tps: List[Type], pt: Type ) = if (isFullyDefined(pt)) (pt, false) else weakLub(tps map (_.deconst)) + def ptOrLubPacked(trees: List[Tree], pt: Type) = if (isFullyDefined(pt)) (pt, false) else weakLub(trees map (c => packedType(c, context.owner).deconst)) + // takes untyped sub-trees of a match and type checks them - def typedMatch(selector0: Tree, cases: List[CaseDef], mode: Int, resTp: Type) = { - val (selector, doTranslation) = selector0 match { - case Annotated(Ident(nme.synthSwitch), selector) => (selector, false) - case s => (s, true) - } - val selector1 = checkDead(typed(selector, EXPRmode | BYVALmode, WildcardType)) - val selectorTp = packCaptured(selector1.tpe.widen.withoutAnnotations) + def typedMatch(selector: Tree, cases: List[CaseDef], mode: Int, pt: Type, tree: Tree = EmptyTree): Match = { + val selector1 = checkDead(typed(selector, EXPRmode | BYVALmode, WildcardType)) + val selectorTp = packCaptured(selector1.tpe.widen) + val casesTyped = typedCases(cases, selectorTp, pt) - val casesTyped = typedCases(cases, selectorTp, resTp) - val caseTypes = casesTyped map (c => packedType(c, context.owner).deconst) - val (ownType, needAdapt) = if (isFullyDefined(resTp)) (resTp, false) else weakLub(caseTypes) + val (resTp, needAdapt) = + if (opt.virtPatmat) ptOrLubPacked(casesTyped, pt) + else ptOrLub(casesTyped map (_.tpe), pt) - val casesAdapted = if (!needAdapt) casesTyped else casesTyped map (adaptCase(_, mode, ownType)) + val casesAdapted = if (!needAdapt) casesTyped else casesTyped map (adaptCase(_, mode, resTp)) - (selector1, selectorTp, casesAdapted, ownType, doTranslation) + treeCopy.Match(tree, selector1, casesAdapted) setType resTp } - // match has been typed, now translate it - def translatedMatch(selector1: Tree, selectorTp: Type, casesAdapted: List[CaseDef], ownType: Type, doTranslation: Boolean, matchFailGen: Option[Tree => Tree] = None) = { - def repeatedToSeq(tp: Type): Type = (tp baseType RepeatedParamClass) match { - case TypeRef(_, RepeatedParamClass, arg :: Nil) => seqType(arg) - case _ => tp - } + // match has been typed -- virtualize it if we're feeling experimental + // (virtualized matches are expanded during type checking so they have the full context available) + // otherwise, do nothing: matches are translated during phase `patmat` (unless -Xoldpatmat) + def virtualizedMatch(match_ : Match, mode: Int, pt: Type) = { + import patmat.{vpmName, PureMatchTranslator, OptimizingMatchTranslator} + + // TODO: add fallback __match sentinel to predef + val matchStrategy: Tree = + if (!(newPatternMatching && opt.experimental && context.isNameInScope(vpmName._match))) null // fast path, avoiding the next line if there's no __match to be seen + else newTyper(context.makeImplicit(reportAmbiguousErrors = false)).silent(_.typed(Ident(vpmName._match), EXPRmode, WildcardType), reportAmbiguousErrors = false) match { + case SilentResultValue(ms) => ms + case _ => null + } - if (!doTranslation) { // a switch - Match(selector1, casesAdapted) setType ownType // setType of the Match to avoid recursing endlessly - } else { - val scrutType = repeatedToSeq(elimAnonymousClass(selectorTp)) - // we've packed the type for each case in typedMatch so that if all cases have the same existential case, we get a clean lub - // here, we should open up the existential again - // relevant test cases: pos/existentials-harmful.scala, pos/gadt-gilles.scala, pos/t2683.scala, pos/virtpatmat_exist4.scala - // TODO: fix skolemizeExistential (it should preserve annotations, right?) - val ownTypeSkolemized = ownType.skolemizeExistential(context.owner, context.tree) withAnnotations ownType.annotations - MatchTranslator(this).translateMatch(selector1, casesAdapted, repeatedToSeq(ownTypeSkolemized), scrutType, matchFailGen) - } + if (matchStrategy ne null) // virtualize + typed((new PureMatchTranslator(this.asInstanceOf[patmat.global.analyzer.Typer] /*TODO*/, matchStrategy)).translateMatch(match_), mode, pt) + else + match_ // will be translated in phase `patmat` } - // synthesize and type check a (Partial)Function implementation based on a match specified by `cases` - // Match(EmptyTree, cases) ==> new Function { def apply(params) = `translateMatch('`(param1,...,paramN)` match { cases }')` } + // synthesize and type check a PartialFunction implementation based on a match specified by `cases` + // Match(EmptyTree, cases) ==> new PartialFunction { def apply(params) = `translateMatch('`(param1,...,paramN)` match { cases }')` } // for fresh params, the selector of the match we'll translated simply gathers those in a tuple + // NOTE: restricted to PartialFunction -- leave Function trees if the expected type does not demand a partial function class MatchFunTyper(tree: Tree, cases: List[CaseDef], mode: Int, pt0: Type) { + // TODO: remove FunctionN support -- this is currently designed so that it can emit FunctionN and PartialFunction subclasses + // however, we should leave Function nodes until Uncurry so phases after typer can still detect normal Function trees + // we need to synthesize PartialFunction impls, though, to avoid nastiness in Uncurry in transforming&duplicating generated pattern matcher trees + // TODO: remove PartialFunction support from UnCurry private val pt = deskolemizeGADTSkolems(pt0) private val targs = pt.normalize.typeArgs private val arity = if (isFunctionType(pt)) targs.length - 1 else 1 // TODO pt should always be a (Partial)Function, right? private val ptRes = if (targs.isEmpty) WildcardType else targs.last // may not be fully defined private val isPartial = pt.typeSymbol == PartialFunctionClass + assert(isPartial) + private val anonClass = context.owner.newAnonymousFunctionClass(tree.pos) private val funThis = This(anonClass) @@ -2297,7 +2309,8 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser val methodBodyTyper = newTyper(context.makeNewScope(context.tree, methodSym)) // should use the DefDef for the context's tree, but it doesn't exist yet (we need the typer we're creating to create it) paramSyms foreach (methodBodyTyper.context.scope enter _) - val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.typedMatch(selector, cases, mode, ptRes) + val match_ = methodBodyTyper.typedMatch(selector, cases, mode, ptRes) + val resTp = match_.tpe val methFormals = paramSyms map (_.tpe) val parents = @@ -2307,7 +2320,7 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser anonClass setInfo ClassInfoType(parents, newScope, anonClass) methodSym setInfoAndEnter MethodType(paramSyms, resTp) - DefDef(methodSym, methodBodyTyper.translatedMatch(selector1, selectorTp, casesAdapted, resTp, doTranslation)) + DefDef(methodSym, methodBodyTyper.virtualizedMatch(match_, mode, resTp)) } } @@ -2336,16 +2349,17 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser val methodBodyTyper = newTyper(context.makeNewScope(context.tree, methodSym)) // should use the DefDef for the context's tree, but it doesn't exist yet (we need the typer we're creating to create it) paramSyms foreach (methodBodyTyper.context.scope enter _) - val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.typedMatch(selector, cases, mode, ptRes) + val match_ = methodBodyTyper.typedMatch(selector, cases, mode, ptRes) + val resTp = match_.tpe anonClass setInfo ClassInfoType(parentsPartial(List(argTp, resTp)), newScope, anonClass) B1 setInfo TypeBounds.lower(resTp) anonClass.info.decls enter methodSym // methodSym's info need not change (B1's bound has been updated instead) - // use applyOrElse's first parameter since the scrut's type has been widened - def doDefault(scrut_ignored: Tree) = REF(default) APPLY (REF(x)) + match_ setType B1.tpe - val body = methodBodyTyper.translatedMatch(selector1, selectorTp, casesAdapted, B1.tpe, doTranslation, Some(doDefault)) + // the default uses applyOrElse's first parameter since the scrut's type has been widened + val body = methodBodyTyper.virtualizedMatch(match_ withAttachment DefaultOverrideMatchAttachment(REF(default) APPLY (REF(x))), mode, B1.tpe) DefDef(methodSym, body) } @@ -2362,17 +2376,18 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser paramSyms foreach (methodBodyTyper.context.scope enter _) methodSym setInfoAndEnter MethodType(paramSyms, BooleanClass.tpe) - val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.typedMatch(selector, casesTrue, mode, BooleanClass.tpe) - val body = methodBodyTyper.translatedMatch(selector1, selectorTp, casesAdapted, resTp, doTranslation, Some(scrutinee => FALSE_typed)) + val match_ = methodBodyTyper.typedMatch(selector, casesTrue, mode, BooleanClass.tpe) + val body = methodBodyTyper.virtualizedMatch(match_ withAttachment DefaultOverrideMatchAttachment(FALSE_typed), mode, BooleanClass.tpe) DefDef(methodSym, body) } } - val members = if (isPartial) { - // TODO: don't check for MarkerCPSTypes -- check whether all targs are subtype of any (which they are not under CPS) - if ((MarkerCPSTypes ne NoSymbol) && (targs exists (_ hasAnnotation MarkerCPSTypes))) List(applyMethod, isDefinedAtMethod) - else List(applyOrElseMethodDef, isDefinedAtMethod) + lazy val members = if (isPartial) { + // somehow @cps annotations upset the typer when looking at applyOrElse's signature, but not apply's + // TODO: figure out the details (T @cps[U] is not a subtype of Any, but then why does it work for the apply method?) + if (targs forall (_ <:< AnyClass.tpe)) List(applyOrElseMethodDef, isDefinedAtMethod) + else List(applyMethod, isDefinedAtMethod) } else List(applyMethod) def translated = @@ -2447,7 +2462,7 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser fun.body match { // later phase indicates scaladoc is calling (where shit is messed up, I tell you) // -- so fall back to old patmat, which is more forgiving - case Match(sel, cases) if (sel ne EmptyTree) && doMatchTranslation => + case Match(sel, cases) if (sel ne EmptyTree) && newPatternMatching && (pt.typeSymbol == PartialFunctionClass) => // go to outer context -- must discard the context that was created for the Function since we're discarding the function // thus, its symbol, which serves as the current context.owner, is not the right owner // you won't know you're using the wrong owner until lambda lift crashes (unless you know better than to use the wrong owner) @@ -3638,8 +3653,6 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser def isPatternMode = inPatternMode(mode) //Console.println("typed1("+tree.getClass()+","+Integer.toHexString(mode)+","+pt+")") - def ptOrLub(tps: List[Type]) = if (isFullyDefined(pt)) (pt, false) else weakLub(tps map (_.deconst)) - //@M! get the type of the qualifier in a Select tree, otherwise: NoType def prefixType(fun: Tree): Type = fun match { case Select(qualifier, _) => qualifier.tpe @@ -3829,7 +3842,7 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser && thenTp =:= elseTp ) (thenp1.tpe, false) // use unpacked type // TODO: skolemize (lub of packed types) when that no longer crashes on files/pos/t4070b.scala - else ptOrLub(List(thenp1.tpe, elsep1.tpe)) + else ptOrLub(List(thenp1.tpe, elsep1.tpe), pt) if (needAdapt) { //isNumericValueType(owntype)) { thenp1 = adapt(thenp1, mode, owntype) @@ -3839,34 +3852,26 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser } } - def typedTranslatedMatch(tree: Tree, selector: Tree, cases: List[CaseDef]): Tree = { - if (doMatchTranslation) { - if (selector ne EmptyTree) { - val (selector1, selectorTp, casesAdapted, ownType, doTranslation) = typedMatch(selector, cases, mode, pt) - typed(translatedMatch(selector1, selectorTp, casesAdapted, ownType, doTranslation), mode, pt) - } else (new MatchFunTyper(tree, cases, mode, pt)).translated - } else if (selector == EmptyTree) { - if (opt.virtPatmat) debugwarn("virtpatmat should not encounter empty-selector matches "+ tree) - val arity = if (isFunctionType(pt)) pt.normalize.typeArgs.length - 1 else 1 - val params = for (i <- List.range(0, arity)) yield - atPos(tree.pos.focusStart) { - ValDef(Modifiers(PARAM | SYNTHETIC), - unit.freshTermName("x" + i + "$"), TypeTree(), EmptyTree) - } - val ids = for (p <- params) yield Ident(p.name) - val selector1 = atPos(tree.pos.focusStart) { if (arity == 1) ids.head else gen.mkTuple(ids) } - val body = treeCopy.Match(tree, selector1, cases) - typed1(atPos(tree.pos) { Function(params, body) }, mode, pt) - } else { - val selector1 = checkDead(typed(selector, EXPRmode | BYVALmode, WildcardType)) - var cases1 = typedCases(cases, packCaptured(selector1.tpe.widen), pt) - val (owntype, needAdapt) = ptOrLub(cases1 map (_.tpe)) - if (needAdapt) { - cases1 = cases1 map (adaptCase(_, mode, owntype)) + // under -Xexperimental (and not -Xoldpatmat), and when there's a suitable __match in scope, virtualize the pattern match + // otherwise, type the Match and leave it until phase `patmat` (immediately after typer) + // empty-selector matches are transformed into synthetic PartialFunction implementations when the expected type demands it + def typedVirtualizedMatch(tree: Tree, selector: Tree, cases: List[CaseDef]): Tree = + if (selector == EmptyTree) { + if (newPatternMatching && (pt.typeSymbol == PartialFunctionClass)) (new MatchFunTyper(tree, cases, mode, pt)).translated + else { + val arity = if (isFunctionType(pt)) pt.normalize.typeArgs.length - 1 else 1 + val params = for (i <- List.range(0, arity)) yield + atPos(tree.pos.focusStart) { + ValDef(Modifiers(PARAM | SYNTHETIC), + unit.freshTermName("x" + i + "$"), TypeTree(), EmptyTree) + } + val ids = for (p <- params) yield Ident(p.name) + val selector1 = atPos(tree.pos.focusStart) { if (arity == 1) ids.head else gen.mkTuple(ids) } + val body = treeCopy.Match(tree, selector1, cases) + typed1(atPos(tree.pos) { Function(params, body) }, mode, pt) } - treeCopy.Match(tree, selector1, cases1) setType owntype - } - } + } else + virtualizedMatch(typedMatch(selector, cases, mode, pt, tree), mode, pt) def typedReturn(expr: Tree) = { val enclMethod = context.enclMethod @@ -4637,7 +4642,11 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser typedValDef(vdef) case ddef @ DefDef(_, _, _, _, _, _) => - newTyper(context.makeNewScope(tree, sym)).typedDefDef(ddef) + // flag default getters for constructors. An actual flag would be nice. See SI-5543. + //val flag = ddef.mods.hasDefaultFlag && ddef.mods.hasFlag(PRESUPER) + val flag = ddef.mods.hasDefaultFlag && sym.owner.isModuleClass && + nme.defaultGetterToMethod(sym.name) == nme.CONSTRUCTOR + newTyper(context.makeNewScope(tree, sym)).constrTyperIf(flag).typedDefDef(ddef) case tdef @ TypeDef(_, _, _, _) => typedTypeDef(tdef) @@ -4708,7 +4717,7 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser typedIf(cond, thenp, elsep) case tree @ Match(selector, cases) => - typedTranslatedMatch(tree, selector, cases) + typedVirtualizedMatch(tree, selector, cases) case Return(expr) => typedReturn(expr) @@ -4718,15 +4727,12 @@ trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser var catches1 = typedCases(catches, ThrowableClass.tpe, pt) val finalizer1 = if (finalizer.isEmpty) finalizer else typed(finalizer, UnitClass.tpe) - val (owntype, needAdapt) = ptOrLub(block1.tpe :: (catches1 map (_.tpe))) + val (owntype, needAdapt) = ptOrLub(block1.tpe :: (catches1 map (_.tpe)), pt) if (needAdapt) { block1 = adapt(block1, mode, owntype) catches1 = catches1 map (adaptCase(_, mode, owntype)) } - if (doMatchTranslation) - catches1 = (MatchTranslator(this)).translateTry(catches1, owntype, tree.pos) - treeCopy.Try(tree, block1, catches1, finalizer1) setType owntype case Throw(expr) => diff --git a/src/compiler/scala/tools/nsc/util/WeakHashSet.scala b/src/compiler/scala/tools/nsc/util/WeakHashSet.scala index 6a10422b004d..5bbb766e215f 100644 --- a/src/compiler/scala/tools/nsc/util/WeakHashSet.scala +++ b/src/compiler/scala/tools/nsc/util/WeakHashSet.scala @@ -4,6 +4,7 @@ import scala.collection.mutable import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.Builder import scala.collection.mutable.SetBuilder +import scala.collection.generic.Clearable import scala.runtime.AbstractFunction1 /** A bare-bones implementation of a mutable `Set` that uses weak references @@ -12,7 +13,7 @@ import scala.runtime.AbstractFunction1 * This implementation offers only add/remove/test operations, * therefore it does not fulfill the contract of Scala collection sets. */ -class WeakHashSet[T <: AnyRef] extends AbstractFunction1[T, Boolean] { +class WeakHashSet[T <: AnyRef] extends AbstractFunction1[T, Boolean] with Clearable { private val underlying = mutable.HashSet[WeakReferenceWithEquals[T]]() /** Add the given element to this set. */ diff --git a/src/continuations/library/scala/util/continuations/ControlContext.scala b/src/continuations/library/scala/util/continuations/ControlContext.scala index 19c2bc4038a2..910ca60eb032 100644 --- a/src/continuations/library/scala/util/continuations/ControlContext.scala +++ b/src/continuations/library/scala/util/continuations/ControlContext.scala @@ -13,7 +13,7 @@ import annotation.{ Annotation, StaticAnnotation, TypeConstraint } /** This annotation is used to mark a parameter as part of a continuation * context. * - * The type `A @cps[B,C]` is desugared to `ControlContext[A,B,C]` at compile + * The type `A @cpsParam[B,C]` is desugared to `ControlContext[A,B,C]` at compile * time. * * @tparam B The type of computation state after computation has executed, and diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala index bed8e93d1b64..862b19d0a482 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala @@ -3,8 +3,9 @@ package scala.tools.selectivecps import scala.tools.nsc.Global +import scala.tools.nsc.typechecker.Modes -abstract class CPSAnnotationChecker extends CPSUtils { +abstract class CPSAnnotationChecker extends CPSUtils with Modes { val global: Global import global._ import definitions._ @@ -177,59 +178,38 @@ abstract class CPSAnnotationChecker extends CPSUtils { override def adaptAnnotations(tree: Tree, mode: Int, pt: Type): Tree = { if (!cpsEnabled) return tree - vprintln("adapt annotations " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt) + vprintln("adapt annotations " + tree + " / " + tree.tpe + " / " + modeString(mode) + " / " + pt) - val annots1 = cpsParamAnnotation(tree.tpe) - val annots2 = cpsParamAnnotation(pt) + val patMode = (mode & global.analyzer.PATTERNmode) != 0 + val exprMode = (mode & global.analyzer.EXPRmode) != 0 + val byValMode = (mode & global.analyzer.BYVALmode) != 0 - if ((mode & global.analyzer.PATTERNmode) != 0) { - if (!annots1.isEmpty) { - return tree modifyType removeAllCPSAnnotations - } - } + val annotsTree = cpsParamAnnotation(tree.tpe) + val annotsExpected = cpsParamAnnotation(pt) -/* + // not sure I rephrased this comment correctly: + // replacing `patMode` in the condition below by `patMode || ((mode & global.analyzer.TYPEmode) != 0 && (mode & global.analyzer.BYVALmode))` // doesn't work correctly -- still relying on addAnnotations to remove things from ValDef symbols - if ((mode & global.analyzer.TYPEmode) != 0 && (mode & global.analyzer.BYVALmode) != 0) { - if (!annots1.isEmpty) { - println("removing annotation from " + tree + "/" + tree.tpe) - val s = tree.setType(removeAllCPSAnnotations(tree.tpe)) - println(s) - s - } - } -*/ - - if ((mode & global.analyzer.EXPRmode) != 0) { - if (annots1.isEmpty && !annots2.isEmpty && ((mode & global.analyzer.BYVALmode) == 0)) { // shiftUnit - // add a marker annotation that will make tree.tpe behave as pt, subtyping wise - // tree will look like having any possible annotation - //println("adapt annotations " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt) - //val same = annots2 forall { case AnnotationInfo(atp: TypeRef, _, _) => atp.typeArgs(0) =:= atp.typeArgs(1) } - // TBD: use same or not? see infer0.scala/infer1.scala - - // CAVEAT: - // for monomorphic answer types we want to have @plus @cps (for better checking) - // for answer type modification we want to have only @plus (because actual answer type may differ from pt) - - //val known = global.analyzer.isFullyDefined(pt) - - if (/*same &&*/ !hasPlusMarker(tree.tpe)) { - //if (known) - return tree modifyType (_ withAnnotations newPlusMarker() :: annots2) // needed for #1807 - //else - // return tree.setType(tree.tpe.withAnnotations(adapt::Nil)) - } - tree - } else if (!annots1.isEmpty && ((mode & global.analyzer.BYVALmode) != 0)) { // dropping annotation - // add a marker annotation that will make tree.tpe behave as pt, subtyping wise - // tree will look like having no annotation - if (!hasMinusMarker(tree.tpe)) { - return tree modifyType addMinusMarker - } - } - } - tree + if (patMode && !annotsTree.isEmpty) tree modifyType removeAllCPSAnnotations + else if (exprMode && !byValMode && !hasPlusMarker(tree.tpe) && annotsTree.isEmpty && annotsExpected.nonEmpty) { // shiftUnit + // add a marker annotation that will make tree.tpe behave as pt, subtyping wise + // tree will look like having any possible annotation + //println("adapt annotations " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt) + + // CAVEAT: + // for monomorphic answer types we want to have @plus @cps (for better checking) + // for answer type modification we want to have only @plus (because actual answer type may differ from pt) + + val res = tree modifyType (_ withAnnotations newPlusMarker() :: annotsExpected) // needed for #1807 + vprintln("adapted annotations (not by val) of " + tree + " to " + res.tpe) + res + } else if (exprMode && byValMode && !hasMinusMarker(tree.tpe) && annotsTree.nonEmpty) { // dropping annotation + // add a marker annotation that will make tree.tpe behave as pt, subtyping wise + // tree will look like having no annotation + val res = tree modifyType addMinusMarker + vprintln("adapted annotations (by val) of " + tree + " to " + res.tpe) + res + } else tree } def updateAttributesFromChildren(tpe: Type, childAnnots: List[AnnotationInfo], byName: List[Tree]): Type = { @@ -454,11 +434,10 @@ abstract class CPSAnnotationChecker extends CPSUtils { transChildrenInOrder(tree, tpe, List(cond), List(thenp, elsep)) case Match(select, cases) => - // TODO: can there be cases that are not CaseDefs?? check collect vs map! - transChildrenInOrder(tree, tpe, List(select), cases:::(cases collect { case CaseDef(_, _, body) => body })) + transChildrenInOrder(tree, tpe, List(select), cases:::(cases map { case CaseDef(_, _, body) => body })) case Try(block, catches, finalizer) => - val tpe1 = transChildrenInOrder(tree, tpe, Nil, block::catches:::(catches collect { case CaseDef(_, _, body) => body })) + val tpe1 = transChildrenInOrder(tree, tpe, Nil, block::catches:::(catches map { case CaseDef(_, _, body) => body })) val annots = cpsParamAnnotation(tpe1) if (annots.nonEmpty) { diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala index e1d699debc84..e9e9cf0fabf5 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala @@ -241,6 +241,8 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with // where D$idef = def L$i(..) = {L$i.body; L${i+1}(..)} case ldef @ LabelDef(name, params, rhs) => + // println("trans LABELDEF "+(name, params, tree.tpe, hasAnswerTypeAnn(tree.tpe))) + // TODO why does the labeldef's type have a cpsMinus annotation, whereas the rhs does not? (BYVALmode missing/too much somewhere?) if (hasAnswerTypeAnn(tree.tpe)) { // currentOwner.newMethod(name, tree.pos, Flags.SYNTHETIC) setInfo ldef.symbol.info val sym = ldef.symbol resetFlag Flags.LABEL @@ -456,10 +458,11 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with val (anfStats, anfExpr) = rec(stms, cpsA, List()) // println("\nanf-block:\n"+ ((stms :+ expr) mkString ("{", "\n", "}")) +"\nBECAME\n"+ ((anfStats :+ anfExpr) mkString ("{", "\n", "}"))) - + // println("synth case? "+ (anfStats map (t => (t, t.isDef, gen.hasSynthCaseSymbol(t))))) // SUPER UGLY HACK: handle virtpatmat-style matches, whose labels have already been turned into DefDefs if (anfStats.nonEmpty && (anfStats forall (t => !t.isDef || gen.hasSynthCaseSymbol(t)))) { val (prologue, rest) = (anfStats :+ anfExpr) span (s => !s.isInstanceOf[DefDef]) // find first case + // println("rest: "+ rest) // val (defs, calls) = rest partition (_.isInstanceOf[DefDef]) if (rest nonEmpty){ // the filter drops the ()'s emitted when transValue encountered a LabelDef diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala index a78de8e6c852..dcb7cd601f12 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala @@ -65,6 +65,7 @@ abstract class SelectiveCPSTransform extends PluginComponent with class CPSTransformer(unit: CompilationUnit) extends TypingTransformer(unit) { + private val patmatTransformer = patmat.newTransformer(unit) override def transform(tree: Tree): Tree = { if (!cpsEnabled) return tree @@ -212,7 +213,7 @@ abstract class SelectiveCPSTransform extends PluginComponent with val catch2 = localTyper.typedCases(List(catchIfDefined), ThrowableClass.tpe, targettp) //typedCases(tree, catches, ThrowableClass.tpe, pt) - localTyper.typed(Block(List(funDef), treeCopy.Try(tree, treeCopy.Block(block1, stms, expr2), catch2, finalizer1))) + patmatTransformer.transform(localTyper.typed(Block(List(funDef), treeCopy.Try(tree, treeCopy.Block(block1, stms, expr2), catch2, finalizer1)))) /* diff --git a/src/library/rootdoc.txt b/src/library/rootdoc.txt index 6145429f1e0a..da27a0084ba9 100644 --- a/src/library/rootdoc.txt +++ b/src/library/rootdoc.txt @@ -22,6 +22,6 @@ Many other packages exist. See the complete list on the left. Identifiers in the scala package and the [[scala.Predef]] object are always in scope by default. -Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example, List is an alias for scala.collection.immutable.[[scala.collection.immutable.List]]. +Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example, `List` is an alias for scala.collection.immutable.[[scala.collection.immutable.List]]. -Other aliases refer to classes providing by the underlying platform. For example, on the JVM, String is an alias for java.lang.String. +Other aliases refer to classes provided by the underlying platform. For example, on the JVM, `String` is an alias for `java.lang.String`. diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index fd61cfd0a1d0..36e95b303d90 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -468,7 +468,7 @@ object Array extends FallbackArrayBuilding { * @see [[http://www.scala-lang.org/docu/files/collections-api/collections_38.html#anchor "The Scala 2.8 Collections' API"]] * section on `Array` by Martin Odersky for more information. * @define coll array - * @define Coll Array + * @define Coll `Array` * @define orderDependent * @define orderDependentFold * @define mayNotTerminateInf diff --git a/src/library/scala/Dynamic.scala b/src/library/scala/Dynamic.scala index dcf75997423c..faf834d310f2 100644 --- a/src/library/scala/Dynamic.scala +++ b/src/library/scala/Dynamic.scala @@ -9,12 +9,25 @@ package scala /** A marker trait that enables dynamic invocations. Instances `x` of this - * trait allow calls `x.meth(args)` for arbitrary method names `meth` and - * argument lists `args`. If a call is not natively supported by `x`, it - * is rewritten to `x.applyDynamic("meth")(args)`. + * trait allow method invocations `x.meth(args)` for arbitrary method + * names `meth` and argument lists `args` as well as field accesses + * `x.field` for arbitrary field names `field`. * - * As of scala 2.9, `scalac` must receive the `-Xexperimental` option for - * `Dynamic` to receive this treatment. + * If a call is not natively supported by `x` (i.e. if type checking + * fails), it is rewritten according to the following rules: + * + * {{{ + * foo.method("blah") ~~> foo.applyDynamic("method")("blah") + * foo.method(x = "blah") ~~> foo.applyDynamicNamed("method")(("x", "blah")) + * foo.method(x = 1, 2) ~~> foo.applyDynamicNamed("method")(("x", 1), ("", 2)) + * foo.field ~~> foo.selectDynamic("field") + * foo.varia = 10 ~~> foo.updateDynamic("varia")(10) + * foo.arr(10) = 13 ~~> foo.selectDynamic("arr").update(10, 13) + * foo.arr(10) ~~> foo.applyDynamics("arr")(10) + * }}} + * + * As of Scala 2.10, defining direct or indirect subclasses of this trait + * is only possible if the language feature `dynamics` is enabled. */ trait Dynamic diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index a58297d7d49f..44c8fba45f0b 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -83,7 +83,7 @@ object Option { * @define p `p` * @define f `f` * @define coll option - * @define Coll Option + * @define Coll `Option` * @define orderDependent * @define orderDependentFold * @define mayNotTerminateInf diff --git a/src/library/scala/collection/BitSet.scala b/src/library/scala/collection/BitSet.scala index 59b53faf7efe..90e837b219ff 100644 --- a/src/library/scala/collection/BitSet.scala +++ b/src/library/scala/collection/BitSet.scala @@ -22,7 +22,7 @@ trait BitSet extends SortedSet[Int] /** $factoryInfo * @define coll bitset - * @define Coll BitSet + * @define Coll `BitSet` */ object BitSet extends BitSetFactory[BitSet] { val empty: BitSet = immutable.BitSet.empty diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala index e4f9fd436a37..c0aaa9f28eea 100644 --- a/src/library/scala/collection/BitSetLike.scala +++ b/src/library/scala/collection/BitSetLike.scala @@ -30,7 +30,7 @@ import mutable.StringBuilder * @version 2.8 * @since 2.8 * @define coll bitset - * @define Coll BitSet + * @define Coll `BitSet` */ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSetLike[Int, This] { self => diff --git a/src/library/scala/collection/GenIterableLike.scala b/src/library/scala/collection/GenIterableLike.scala index 8fa598196992..79113ddaa789 100644 --- a/src/library/scala/collection/GenIterableLike.scala +++ b/src/library/scala/collection/GenIterableLike.scala @@ -16,7 +16,7 @@ import generic.{ CanBuildFrom => CBF, _ } * This trait contains abstract methods and methods that can be implemented * directly in terms of other methods. * - * @define Coll GenIterable + * @define Coll `GenIterable` * @define coll general iterable collection * * @author Martin Odersky diff --git a/src/library/scala/collection/GenMapLike.scala b/src/library/scala/collection/GenMapLike.scala index 114169c84926..d611eaea4339 100644 --- a/src/library/scala/collection/GenMapLike.scala +++ b/src/library/scala/collection/GenMapLike.scala @@ -11,7 +11,7 @@ package scala.collection /** A trait for all maps upon which operations may be * implemented in parallel. * - * @define Coll GenMap + * @define Coll `GenMap` * @define coll general map * @author Martin Odersky * @author Aleksandar Prokopec diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala index 4500a849b112..903594b69d06 100644 --- a/src/library/scala/collection/GenTraversableLike.scala +++ b/src/library/scala/collection/GenTraversableLike.scala @@ -43,7 +43,7 @@ import annotation.migration * @define traversableInfo * This is a base trait of all kinds of Scala collections. * - * @define Coll GenTraversable + * @define Coll `GenTraversable` * @define coll general collection * @define collectExample * @tparam A the collection element type. diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index fd8595ccb8f4..f4e3848d9828 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -14,7 +14,7 @@ package scala.collection * Methods in this trait are either abstract or can be implemented in terms * of other methods. * - * @define Coll GenTraversableOnce + * @define Coll `GenTraversableOnce` * @define coll collection or iterator * @define possiblyparinfo * This trait may possibly have operations implemented in parallel. diff --git a/src/library/scala/collection/IndexedSeq.scala b/src/library/scala/collection/IndexedSeq.scala index 4a3586a375e5..56dd0bfffff2 100644 --- a/src/library/scala/collection/IndexedSeq.scala +++ b/src/library/scala/collection/IndexedSeq.scala @@ -26,7 +26,7 @@ trait IndexedSeq[+A] extends Seq[A] /** $factoryInfo * The current default implementation of a $Coll is a `Vector`. * @define coll indexed sequence - * @define Coll IndexedSeq + * @define Coll `IndexedSeq` */ object IndexedSeq extends SeqFactory[IndexedSeq] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala index d1f7d1cb369a..11f481e42509 100644 --- a/src/library/scala/collection/IndexedSeqLike.scala +++ b/src/library/scala/collection/IndexedSeqLike.scala @@ -26,7 +26,7 @@ import scala.annotation.tailrec * access and length computation. They are defined in terms of abstract methods * `apply` for indexing and `length`. * - * Indexed sequences do not add any new methods wrt `Seq`, but promise + * Indexed sequences do not add any new methods to `Seq`, but promise * efficient implementations of random access patterns. * * @tparam A the element type of the $coll diff --git a/src/library/scala/collection/Iterable.scala b/src/library/scala/collection/Iterable.scala index b1752a5c6775..f543c6f80f83 100644 --- a/src/library/scala/collection/Iterable.scala +++ b/src/library/scala/collection/Iterable.scala @@ -40,7 +40,7 @@ trait Iterable[+A] extends Traversable[A] /** $factoryInfo * The current default implementation of a $Coll is a `Vector`. * @define coll iterable collection - * @define Coll Iterable + * @define Coll `Iterable` */ object Iterable extends TraversableFactory[Iterable] { diff --git a/src/library/scala/collection/LinearSeq.scala b/src/library/scala/collection/LinearSeq.scala index be143cf96bc6..21ed91f7f351 100644 --- a/src/library/scala/collection/LinearSeq.scala +++ b/src/library/scala/collection/LinearSeq.scala @@ -26,7 +26,7 @@ trait LinearSeq[+A] extends Seq[A] /** $factoryInfo * The current default implementation of a $Coll is a `Vector`. * @define coll linear sequence - * @define Coll LinearSeq + * @define Coll `LinearSeq` */ object LinearSeq extends SeqFactory[LinearSeq] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, LinearSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala index 0c07d5bb74e4..a124e60c96b5 100644 --- a/src/library/scala/collection/Map.scala +++ b/src/library/scala/collection/Map.scala @@ -33,7 +33,7 @@ trait Map[A, +B] extends Iterable[(A, B)] with GenMap[A, B] with MapLike[A, B, M } /** $factoryInfo - * @define Coll Map + * @define Coll `Map` * @define coll map */ object Map extends MapFactory[Map] { diff --git a/src/library/scala/collection/Seq.scala b/src/library/scala/collection/Seq.scala index fd03a49af448..34705ee05844 100644 --- a/src/library/scala/collection/Seq.scala +++ b/src/library/scala/collection/Seq.scala @@ -27,7 +27,7 @@ trait Seq[+A] extends PartialFunction[Int, A] /** $factoryInfo * The current default implementation of a $Coll is a `List`. * @define coll sequence - * @define Coll Seq + * @define Coll `Seq` */ object Seq extends SeqFactory[Seq] { /** $genericCanBuildFromInfo */ diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index a9535adc23aa..044bd624ae74 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -45,7 +45,7 @@ import scala.math.Ordering * @version 1.0, 16/07/2003 * @since 2.8 * - * @define Coll Seq + * @define Coll `Seq` * @define coll sequence * @define thatinfo the class of the returned collection. Where possible, `That` is * the same class as the current collection class `Repr`, but this @@ -380,8 +380,8 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ * $mayNotTerminateInf * * @param elem the element to test. - * @return `true` if this $coll has an element that is - * is equal (wrt `==`) to `elem`, `false` otherwise. + * @return `true` if this $coll has an element that is equal (as + * determined by `==`) to `elem`, `false` otherwise. */ def contains(elem: Any): Boolean = exists (_ == elem) @@ -553,8 +553,8 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ /** Sorts this $coll according to a comparison function. * $willNotTerminateInf * - * The sort is stable. That is, elements that are equal wrt `lt` appear in the - * same order in the sorted sequence as in the original. + * The sort is stable. That is, elements that are equal (as determined by + * `lt`) appear in the same order in the sorted sequence as in the original. * * @param lt the comparison function which tests whether * its first argument precedes its second argument in @@ -592,8 +592,8 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ /** Sorts this $coll according to an Ordering. * - * The sort is stable. That is, elements that are equal wrt `lt` appear in the - * same order in the sorted sequence as in the original. + * The sort is stable. That is, elements that are equal (as determined by + * `lt`) appear in the same order in the sorted sequence as in the original. * * @see scala.math.Ordering * diff --git a/src/library/scala/collection/Set.scala b/src/library/scala/collection/Set.scala index 4c67aad60353..7424c9cb9a1f 100644 --- a/src/library/scala/collection/Set.scala +++ b/src/library/scala/collection/Set.scala @@ -35,7 +35,7 @@ trait Set[A] extends (A => Boolean) * The current default implementation of a $Coll is one of `EmptySet`, `Set1`, `Set2`, `Set3`, `Set4` in * class `immutable.Set` for sets of sizes up to 4, and a `immutable.HashSet` for sets of larger sizes. * @define coll set - * @define Coll Set + * @define Coll `Set` */ object Set extends SetFactory[Set] { def newBuilder[A] = immutable.Set.newBuilder[A] diff --git a/src/library/scala/collection/concurrent/Map.scala b/src/library/scala/collection/concurrent/Map.scala index 83445738d977..a724be42cccb 100644 --- a/src/library/scala/collection/concurrent/Map.scala +++ b/src/library/scala/collection/concurrent/Map.scala @@ -19,7 +19,7 @@ package scala.collection.concurrent * @tparam A the key type of the map * @tparam B the value type of the map * - * @define Coll ConcurrentMap + * @define Coll `ConcurrentMap` * @define coll concurrent map * @define concurrentmapinfo * This is a base trait for all Scala concurrent map implementations. It diff --git a/src/library/scala/collection/generic/ArrayTagTraversableFactory.scala b/src/library/scala/collection/generic/ArrayTagTraversableFactory.scala index d9ab17559eb8..ddae0a4d64a4 100644 --- a/src/library/scala/collection/generic/ArrayTagTraversableFactory.scala +++ b/src/library/scala/collection/generic/ArrayTagTraversableFactory.scala @@ -15,7 +15,7 @@ import language.higherKinds * subclasses thereof. * * @define coll collection - * @define Coll Traversable + * @define Coll `Traversable` * @define genericCanBuildFromInfo * The standard `CanBuildFrom` instance for $Coll objects. * @author Aleksandar Prokopec diff --git a/src/library/scala/collection/generic/BitSetFactory.scala b/src/library/scala/collection/generic/BitSetFactory.scala index 796b12b0ac13..da80b3964b10 100644 --- a/src/library/scala/collection/generic/BitSetFactory.scala +++ b/src/library/scala/collection/generic/BitSetFactory.scala @@ -15,7 +15,7 @@ import scala.collection._ import mutable.Builder /** @define coll collection - * @define Coll Traversable + * @define Coll `Traversable` * @define factoryInfo * This object provides a set of operations to create `$Coll` values. * @author Martin Odersky diff --git a/src/library/scala/collection/generic/Clearable.scala b/src/library/scala/collection/generic/Clearable.scala new file mode 100644 index 000000000000..6c8d9558b028 --- /dev/null +++ b/src/library/scala/collection/generic/Clearable.scala @@ -0,0 +1,26 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package generic + +/** This trait forms part of collections that can be cleared + * with a clear() call. + * + * @author Paul Phillips + * @version 2.10 + * @since 2.10 + * @define coll clearable collection + * @define Coll `Clearable` + */ +trait Clearable { + /** Clears the $coll's contents. After this operation, the + * $coll is empty. + */ + def clear(): Unit +} diff --git a/src/library/scala/collection/generic/GenMapFactory.scala b/src/library/scala/collection/generic/GenMapFactory.scala index b3faf0497b9e..31fe4e100d6d 100644 --- a/src/library/scala/collection/generic/GenMapFactory.scala +++ b/src/library/scala/collection/generic/GenMapFactory.scala @@ -15,7 +15,7 @@ import language.higherKinds /** A template for companion objects of `Map` and subclasses thereof. * * @define coll map - * @define Coll Map + * @define Coll `Map` * @define factoryInfo * This object provides a set of operations needed to create `$Coll` values. * @author Martin Odersky diff --git a/src/library/scala/collection/generic/GenSetFactory.scala b/src/library/scala/collection/generic/GenSetFactory.scala index caae8afa1cf3..4f812b337cf6 100644 --- a/src/library/scala/collection/generic/GenSetFactory.scala +++ b/src/library/scala/collection/generic/GenSetFactory.scala @@ -17,7 +17,7 @@ import language.higherKinds /** A template for companion objects of `Set` and subclasses thereof. * * @define coll set - * @define Coll Set + * @define Coll `Set` * @define factoryInfo * This object provides a set of operations needed to create `$Coll` values. * @author Martin Odersky diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index f233a40d3598..94def7ab5d06 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -19,7 +19,7 @@ import language.higherKinds * @since 2.8 * * @define coll collection - * @define Coll Traversable + * @define Coll `Traversable` * @define factoryInfo * This object provides a set of operations to create `$Coll` values. * @author Martin Odersky diff --git a/src/library/scala/collection/generic/GenericCompanion.scala b/src/library/scala/collection/generic/GenericCompanion.scala index cf01cf5f08d5..badceac7132b 100644 --- a/src/library/scala/collection/generic/GenericCompanion.scala +++ b/src/library/scala/collection/generic/GenericCompanion.scala @@ -20,7 +20,7 @@ import language.higherKinds * @author Martin Odersky * @since 2.8 * @define coll collection - * @define Coll CC + * @define Coll `CC` */ abstract class GenericCompanion[+CC[X] <: GenTraversable[X]] { /** The underlying collection type with unknown element type */ diff --git a/src/library/scala/collection/generic/GenericParCompanion.scala b/src/library/scala/collection/generic/GenericParCompanion.scala index 93c166b7ba1b..484da5c6d96d 100644 --- a/src/library/scala/collection/generic/GenericParCompanion.scala +++ b/src/library/scala/collection/generic/GenericParCompanion.scala @@ -16,7 +16,7 @@ import language.higherKinds /** A template class for companion objects of parallel collection classes. * They should be mixed in together with `GenericCompanion` type. * - * @define Coll ParIterable + * @define Coll `ParIterable` * @tparam CC the type constructor representing the collection class * @since 2.8 */ diff --git a/src/library/scala/collection/generic/Growable.scala b/src/library/scala/collection/generic/Growable.scala index f0a70c2b88e0..d6a263af2f33 100644 --- a/src/library/scala/collection/generic/Growable.scala +++ b/src/library/scala/collection/generic/Growable.scala @@ -18,11 +18,11 @@ package generic * @version 2.8 * @since 2.8 * @define coll growable collection - * @define Coll Growable + * @define Coll `Growable` * @define add add * @define Add add */ -trait Growable[-A] { +trait Growable[-A] extends Clearable { /** ${Add}s a single element to this $coll. * @@ -50,5 +50,5 @@ trait Growable[-A] { /** Clears the $coll's contents. After this operation, the * $coll is empty. */ - def clear() + def clear(): Unit } diff --git a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala index 93aae0e3554f..f415a52b4d16 100644 --- a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala +++ b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala @@ -16,7 +16,7 @@ import language.higherKinds /** A template for companion objects of `SortedMap` and subclasses thereof. * * @since 2.8 - * @define Coll SortedMap + * @define Coll `SortedMap` * @define coll sorted map * @define factoryInfo * This object provides a set of operations needed to create sorted maps of type `$Coll`. diff --git a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala index 67fb72270c31..1317bb4796df 100644 --- a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala +++ b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala @@ -16,8 +16,8 @@ import language.higherKinds /** A template for companion objects of `SortedSet` and subclasses thereof. * * @since 2.8 - * @define Coll immutable.SortedSet - * @define coll immutable sorted + * @define Coll `immutable.SortedSet` + * @define coll immutable sorted set * @define factoryInfo * This object provides a set of operations needed to create sorted sets of type `$Coll`. * @author Martin Odersky diff --git a/src/library/scala/collection/generic/MutableSortedSetFactory.scala b/src/library/scala/collection/generic/MutableSortedSetFactory.scala index b0dd23ee1aac..0e90ed999cd2 100644 --- a/src/library/scala/collection/generic/MutableSortedSetFactory.scala +++ b/src/library/scala/collection/generic/MutableSortedSetFactory.scala @@ -13,8 +13,8 @@ import scala.collection.mutable.{ Builder, GrowingBuilder } import language.higherKinds /** - * @define Coll mutable.SortedSet - * @define coll mutable sorted + * @define Coll `mutable.SortedSet` + * @define coll mutable sorted set * * @author Lucien Pereira * diff --git a/src/library/scala/collection/generic/ParFactory.scala b/src/library/scala/collection/generic/ParFactory.scala index 0829ba661627..41dca8fbe938 100644 --- a/src/library/scala/collection/generic/ParFactory.scala +++ b/src/library/scala/collection/generic/ParFactory.scala @@ -17,7 +17,7 @@ import language.higherKinds * operations to create `$Coll` objects. * * @define coll parallel collection - * @define Coll ParIterable + * @define Coll `ParIterable` * @since 2.8 */ abstract class ParFactory[CC[X] <: ParIterable[X] with GenericParTemplate[X, CC]] diff --git a/src/library/scala/collection/generic/ParMapFactory.scala b/src/library/scala/collection/generic/ParMapFactory.scala index c05ab7343167..5aedf6792481 100644 --- a/src/library/scala/collection/generic/ParMapFactory.scala +++ b/src/library/scala/collection/generic/ParMapFactory.scala @@ -19,7 +19,7 @@ import language.higherKinds * to create `$Coll` objects. * * @define coll parallel map - * @define Coll ParMap + * @define Coll `ParMap` * @author Aleksandar Prokopec * @since 2.8 */ diff --git a/src/library/scala/collection/generic/Shrinkable.scala b/src/library/scala/collection/generic/Shrinkable.scala index 88c7ce3a3dc7..0c9dafefb111 100644 --- a/src/library/scala/collection/generic/Shrinkable.scala +++ b/src/library/scala/collection/generic/Shrinkable.scala @@ -17,7 +17,7 @@ package generic * @version 2.8 * @since 2.8 * @define coll shrinkable collection - * @define Coll Shrinkable + * @define Coll `Shrinkable` */ trait Shrinkable[-A] { diff --git a/src/library/scala/collection/immutable/BitSet.scala b/src/library/scala/collection/immutable/BitSet.scala index 870d5534dc76..1b676e2d2f57 100644 --- a/src/library/scala/collection/immutable/BitSet.scala +++ b/src/library/scala/collection/immutable/BitSet.scala @@ -20,7 +20,7 @@ import mutable.{ Builder, SetBuilder } * @see [[http://docs.scala-lang.org/overviews/collections/concrete-immutable-collection-classes.html#immutable_bitsets "Scala's Collection Library overview"]] * section on `Immutable BitSets` for more information. * - * @define Coll immutable.BitSet + * @define Coll `immutable.BitSet` * @define coll immutable bitset */ @SerialVersionUID(1611436763290191562L) @@ -63,7 +63,7 @@ abstract class BitSet extends scala.collection.AbstractSet[Int] } /** $factoryInfo - * @define Coll immutable.BitSet + * @define Coll `immutable.BitSet` * @define coll immutable bitset */ object BitSet extends BitSetFactory[BitSet] { diff --git a/src/library/scala/collection/immutable/GenSeq.scala.disabled b/src/library/scala/collection/immutable/GenSeq.scala.disabled index 5b59418b9f39..b8bc420ec38a 100644 --- a/src/library/scala/collection/immutable/GenSeq.scala.disabled +++ b/src/library/scala/collection/immutable/GenSeq.scala.disabled @@ -25,7 +25,7 @@ import mutable.Builder * * The class adds an `update` method to `collection.Seq`. * - * @define Coll mutable.Seq + * @define Coll `mutable.Seq` * @define coll mutable sequence */ trait GenSeq[+A] extends GenIterable[A] diff --git a/src/library/scala/collection/immutable/GenSet.scala.disabled b/src/library/scala/collection/immutable/GenSet.scala.disabled index dc921b524588..828219580e57 100644 --- a/src/library/scala/collection/immutable/GenSet.scala.disabled +++ b/src/library/scala/collection/immutable/GenSet.scala.disabled @@ -24,7 +24,7 @@ import mutable.Builder * * @since 1.0 * @author Matthias Zenger - * @define Coll mutable.Set + * @define Coll `mutable.Set` * @define coll mutable set */ trait GenSet[A] extends GenIterable[A] diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 6b11371bec9c..13a0febfeedb 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -27,7 +27,7 @@ import parallel.immutable.ParHashMap * @since 2.3 * @see [[http://docs.scala-lang.org/overviews/collections/concrete-immutable-collection-classes.html#hash_tries "Scala's Collection Library overview"]] * section on `Hash Tries` for more information. - * @define Coll immutable.HashMap + * @define Coll `immutable.HashMap` * @define coll immutable hash map * @define mayNotTerminateInf * @define willNotTerminateInf @@ -96,7 +96,7 @@ class HashMap[A, +B] extends AbstractMap[A, B] } /** $factoryInfo - * @define Coll immutable.HashMap + * @define Coll `immutable.HashMap` * @define coll immutable hash map * * @author Tiark Rompf diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala index 79d2fb71ccdc..b956a4d83815 100644 --- a/src/library/scala/collection/immutable/HashSet.scala +++ b/src/library/scala/collection/immutable/HashSet.scala @@ -26,7 +26,7 @@ import collection.parallel.immutable.ParHashSet * @author Tiark Rompf * @version 2.8 * @since 2.3 - * @define Coll immutable.HashSet + * @define Coll `immutable.HashSet` * @define coll immutable hash set */ @SerialVersionUID(2L) @@ -85,12 +85,12 @@ class HashSet[A] extends AbstractSet[A] } /** $factoryInfo - * @define Coll immutable.HashSet + * @define Coll `immutable.HashSet` * @define coll immutable hash set * * @author Tiark Rompf * @since 2.3 - * @define Coll immutable.HashSet + * @define Coll `immutable.HashSet` * @define coll immutable hash set * @define mayNotTerminateInf * @define willNotTerminateInf diff --git a/src/library/scala/collection/immutable/IndexedSeq.scala b/src/library/scala/collection/immutable/IndexedSeq.scala index e3939001d897..b37edc425490 100644 --- a/src/library/scala/collection/immutable/IndexedSeq.scala +++ b/src/library/scala/collection/immutable/IndexedSeq.scala @@ -29,7 +29,7 @@ trait IndexedSeq[+A] extends Seq[A] /** $factoryInfo * The current default implementation of a $Coll is a `Vector`. * @define coll indexed sequence - * @define Coll IndexedSeq + * @define Coll `IndexedSeq` */ object IndexedSeq extends SeqFactory[IndexedSeq] { class Impl[A](buf: ArrayBuffer[A]) extends AbstractSeq[A] with IndexedSeq[A] with Serializable { diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala index 3c9c0c2f24ca..039a57041c02 100644 --- a/src/library/scala/collection/immutable/IntMap.scala +++ b/src/library/scala/collection/immutable/IntMap.scala @@ -36,7 +36,7 @@ import IntMapUtils._ /** A companion object for integer maps. * - * @define Coll IntMap + * @define Coll `IntMap` * @define mapCanBuildFromInfo * The standard `CanBuildFrom` instance for `$Coll` objects. * The created value is an instance of class `MapCanBuildFrom`. @@ -150,7 +150,7 @@ import IntMap._ * @tparam T type of the values associated with integer keys. * * @since 2.7 - * @define Coll immutable.IntMap + * @define Coll `immutable.IntMap` * @define coll immutable integer map * @define mayNotTerminateInf * @define willNotTerminateInf diff --git a/src/library/scala/collection/immutable/Iterable.scala b/src/library/scala/collection/immutable/Iterable.scala index d5fca2bdffae..a1390ba18943 100644 --- a/src/library/scala/collection/immutable/Iterable.scala +++ b/src/library/scala/collection/immutable/Iterable.scala @@ -18,7 +18,7 @@ import parallel.immutable.ParIterable /** A base trait for iterable collections that are guaranteed immutable. * $iterableInfo * - * @define Coll immutable.Iterable + * @define Coll `immutable.Iterable` * @define coll immutable iterable collection */ trait Iterable[+A] extends Traversable[A] @@ -34,7 +34,7 @@ trait Iterable[+A] extends Traversable[A] } /** $factoryInfo - * @define Coll immutable.Iterable + * @define Coll `immutable.Iterable` * @define coll immutable iterable collection */ object Iterable extends TraversableFactory[Iterable] { diff --git a/src/library/scala/collection/immutable/LinearSeq.scala b/src/library/scala/collection/immutable/LinearSeq.scala index 536894c28788..2d6986740abe 100644 --- a/src/library/scala/collection/immutable/LinearSeq.scala +++ b/src/library/scala/collection/immutable/LinearSeq.scala @@ -29,7 +29,7 @@ trait LinearSeq[+A] extends Seq[A] /** $factoryInfo * The current default implementation of a $Coll is a `List`. * @define coll immutable linear sequence - * @define Coll immutable.LinearSeq + * @define Coll `immutable.LinearSeq` */ object LinearSeq extends SeqFactory[LinearSeq] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, LinearSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 1b75c1011374..b4c22c3b6c41 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -141,7 +141,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] /** Builds a new list by applying a function to all elements of this list. * Like `xs map f`, but returns `xs` unchanged if function - * `f` maps all elements to themselves (wrt eq). + * `f` maps all elements to themselves (as determined by `eq`). * * @param f the function to apply to each element. * @tparam B the element type of the returned collection. @@ -382,7 +382,7 @@ final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extend /** $factoryInfo * @define coll list - * @define Coll List + * @define Coll `List` */ object List extends SeqFactory[List] { diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala index 11b5d1e3113c..8a316f37ded6 100644 --- a/src/library/scala/collection/immutable/LongMap.scala +++ b/src/library/scala/collection/immutable/LongMap.scala @@ -36,7 +36,7 @@ import LongMapUtils._ /** A companion object for long maps. * - * @define Coll LongMap + * @define Coll `LongMap` * @define mapCanBuildFromInfo * The standard `CanBuildFrom` instance for `$Coll` objects. * The created value is an instance of class `MapCanBuildFrom`. @@ -147,7 +147,7 @@ import LongMap._; * @tparam T type of the values associated with the long keys. * * @since 2.7 - * @define Coll immutable.LongMap + * @define Coll `immutable.LongMap` * @define coll immutable long integer map * @define mayNotTerminateInf * @define willNotTerminateInf diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala index bbefd983fd76..e73da01ac49c 100644 --- a/src/library/scala/collection/immutable/Map.scala +++ b/src/library/scala/collection/immutable/Map.scala @@ -66,7 +66,7 @@ trait Map[A, +B] extends Iterable[(A, B)] } /** $factoryInfo - * @define Coll immutable.Map + * @define Coll `immutable.Map` * @define coll immutable map */ object Map extends ImmutableMapFactory[Map] { diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 0966fa035fde..4c82d99c03e9 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -34,7 +34,7 @@ import generic._ * * @author Paul Phillips * @version 2.8 - * @define Coll NumericRange + * @define Coll `NumericRange` * @define coll numeric range * @define mayNotTerminateInf * @define willNotTerminateInf diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala index 68c75ee5867c..94953ce38bec 100644 --- a/src/library/scala/collection/immutable/PagedSeq.scala +++ b/src/library/scala/collection/immutable/PagedSeq.scala @@ -119,7 +119,7 @@ import PagedSeq._ * * @author Martin Odersky * @since 2.7 - * @define Coll PagedSeq + * @define Coll `PagedSeq` * @define coll paged sequence * @define mayNotTerminateInf * @define willNotTerminateInf diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala index da04446281a6..e980dda84798 100644 --- a/src/library/scala/collection/immutable/Queue.scala +++ b/src/library/scala/collection/immutable/Queue.scala @@ -30,7 +30,7 @@ import annotation.tailrec * @see [[http://docs.scala-lang.org/overviews/collections/concrete-immutable-collection-classes.html#immutable_queues "Scala's Collection Library overview"]] * section on `Immutable Queues` for more information. * - * @define Coll immutable.Queue + * @define Coll `immutable.Queue` * @define coll immutable queue * @define mayNotTerminateInf * @define willNotTerminateInf @@ -131,7 +131,7 @@ class Queue[+A] protected(protected val in: List[A], protected val out: List[A]) } /** $factoryInfo - * @define Coll immutable.Queue + * @define Coll `immutable.Queue` * @define coll immutable queue */ object Queue extends SeqFactory[Queue] { diff --git a/src/library/scala/collection/immutable/Seq.scala b/src/library/scala/collection/immutable/Seq.scala index 882ca1261244..1104eb1b4f27 100644 --- a/src/library/scala/collection/immutable/Seq.scala +++ b/src/library/scala/collection/immutable/Seq.scala @@ -19,7 +19,7 @@ import parallel.immutable.ParSeq * that are guaranteed immutable. * * $seqInfo - * @define Coll immutable.Seq + * @define Coll `immutable.Seq` * @define coll immutable sequence */ trait Seq[+A] extends Iterable[A] @@ -36,7 +36,7 @@ trait Seq[+A] extends Iterable[A] } /** $factoryInfo - * @define Coll immutable.Seq + * @define Coll `immutable.Seq` * @define coll immutable sequence */ object Seq extends SeqFactory[Seq] { diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala index cd972d6c3052..f783f2d56202 100644 --- a/src/library/scala/collection/immutable/Set.scala +++ b/src/library/scala/collection/immutable/Set.scala @@ -21,7 +21,7 @@ import parallel.immutable.ParSet * @since 1.0 * @author Matthias Zenger * @author Martin Odersky - * @define Coll immutable.Set + * @define Coll `immutable.Set` * @define coll immutable set */ trait Set[A] extends Iterable[A] @@ -38,7 +38,7 @@ trait Set[A] extends Iterable[A] } /** $factoryInfo - * @define Coll immutable.Set + * @define Coll `immutable.Set` * @define coll immutable set */ object Set extends ImmutableSetFactory[Set] { diff --git a/src/library/scala/collection/immutable/SortedSet.scala b/src/library/scala/collection/immutable/SortedSet.scala index e1637ce78bf8..62fa4e0335dc 100644 --- a/src/library/scala/collection/immutable/SortedSet.scala +++ b/src/library/scala/collection/immutable/SortedSet.scala @@ -21,7 +21,7 @@ import mutable.Builder * @author Martin Odersky * @version 2.8 * @since 2.4 - * @define Coll immutable.SortedSet + * @define Coll `immutable.SortedSet` * @define coll immutable sorted set */ trait SortedSet[A] extends Set[A] with scala.collection.SortedSet[A] with SortedSetLike[A, SortedSet[A]] { @@ -30,7 +30,7 @@ trait SortedSet[A] extends Set[A] with scala.collection.SortedSet[A] with Sorted } /** $factoryInfo - * @define Coll immutable.SortedSet + * @define Coll `immutable.SortedSet` * @define coll immutable sorted set */ object SortedSet extends ImmutableSortedSetFactory[SortedSet] { diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala index 50fc2795c0c3..c63c1ce232df 100644 --- a/src/library/scala/collection/immutable/Stack.scala +++ b/src/library/scala/collection/immutable/Stack.scala @@ -13,7 +13,7 @@ import generic._ import mutable.{ ArrayBuffer, Builder } /** $factoryInfo - * @define Coll immutable.Stack + * @define Coll `immutable.Stack` * @define coll immutable stack */ object Stack extends SeqFactory[Stack] { @@ -37,7 +37,7 @@ object Stack extends SeqFactory[Stack] { * @see [[http://docs.scala-lang.org/overviews/collections/concrete-immutable-collection-classes.html#immutable_stacks "Scala's Collection Library overview"]] * section on `Immutable stacks` for more information. * - * @define Coll immutable.Stack + * @define Coll `immutable.Stack` * @define coll immutable stack * @define orderDependent * @define orderDependentFold diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 2df4ed70c76f..f3e7214c5fd7 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -177,7 +177,7 @@ import language.implicitConversions * section on `Streams` for more information. * @define naturalsEx def naturalsFrom(i: Int): Stream[Int] = i #:: naturalsFrom(i + 1) - * @define Coll Stream + * @define Coll `Stream` * @define coll stream * @define orderDependent * @define orderDependentFold @@ -805,9 +805,9 @@ self => these } - /** Builds a new stream from this stream in which any duplicates (wrt to ==) - * have been removed. Among duplicate elements, only the first one is - * retained in the resulting `Stream`. + /** Builds a new stream from this stream in which any duplicates (as + * determined by `==`) have been removed. Among duplicate elements, only the + * first one is retained in the resulting `Stream`. * * @return A new `Stream` representing the result of applying distinctness to * the original `Stream`. diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index 52032a1cde7a..d1605bf6378e 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -33,7 +33,7 @@ import StringLike._ * @tparam Repr The type of the actual collection inheriting `StringLike`. * * @since 2.8 - * @define Coll String + * @define Coll `String` * @define coll string * @define orderDependent * @define orderDependentFold diff --git a/src/library/scala/collection/immutable/StringOps.scala b/src/library/scala/collection/immutable/StringOps.scala index 97609b4c4d57..633821eceabd 100644 --- a/src/library/scala/collection/immutable/StringOps.scala +++ b/src/library/scala/collection/immutable/StringOps.scala @@ -25,7 +25,7 @@ import mutable.StringBuilder * @param repr the actual representation of this string operations object. * * @since 2.8 - * @define Coll StringOps + * @define Coll `StringOps` * @define coll string */ final class StringOps(override val repr: String) extends AnyVal with StringLike[String] { diff --git a/src/library/scala/collection/immutable/Traversable.scala b/src/library/scala/collection/immutable/Traversable.scala index 7830b38d693c..59d3b4e029c8 100644 --- a/src/library/scala/collection/immutable/Traversable.scala +++ b/src/library/scala/collection/immutable/Traversable.scala @@ -30,7 +30,7 @@ trait Traversable[+A] extends scala.collection.Traversable[A] /** $factoryInfo * The current default implementation of a $Coll is a `Vector`. * @define coll immutable traversable collection - * @define Coll immutable.Traversable + * @define Coll `immutable.Traversable` */ object Traversable extends TraversableFactory[Traversable] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Traversable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala index 1b3d72ceb76d..882e828c5b54 100644 --- a/src/library/scala/collection/immutable/TreeSet.scala +++ b/src/library/scala/collection/immutable/TreeSet.scala @@ -16,7 +16,7 @@ import immutable.{RedBlackTree => RB} import mutable.{ Builder, SetBuilder } /** $factoryInfo - * @define Coll immutable.TreeSet + * @define Coll `immutable.TreeSet` * @define coll immutable tree set */ object TreeSet extends ImmutableSortedSetFactory[TreeSet] { @@ -40,7 +40,7 @@ object TreeSet extends ImmutableSortedSetFactory[TreeSet] { * @see [[http://docs.scala-lang.org/overviews/collections/concrete-immutable-collection-classes.html#redblack_trees "Scala's Collection Library overview"]] * section on `Red-Black Trees` for more information. * - * @define Coll immutable.TreeSet + * @define Coll `immutable.TreeSet` * @define coll immutable tree set * @define orderDependent * @define orderDependentFold diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index 55c31feec2eb..1395a8f52dc8 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -40,7 +40,7 @@ object Vector extends SeqFactory[Vector] { * * @tparam A the element type * - * @define Coll Vector + * @define Coll `Vector` * @define coll vector * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `Vector[B]` because an implicit of type `CanBuildFrom[Vector, B, That]` diff --git a/src/library/scala/collection/immutable/WrappedString.scala b/src/library/scala/collection/immutable/WrappedString.scala index de8aeea7e1d5..aa7e5b3c4aaf 100644 --- a/src/library/scala/collection/immutable/WrappedString.scala +++ b/src/library/scala/collection/immutable/WrappedString.scala @@ -25,7 +25,7 @@ import mutable.{Builder, StringBuilder} * @param self a string contained within this wrapped string * * @since 2.8 - * @define Coll WrappedString + * @define Coll `WrappedString` * @define coll wrapped string */ class WrappedString(val self: String) extends AbstractSeq[Char] with IndexedSeq[Char] with StringLike[WrappedString] { diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala index bfdc08536c2e..3034fc2bced1 100644 --- a/src/library/scala/collection/mutable/ArrayBuffer.scala +++ b/src/library/scala/collection/mutable/ArrayBuffer.scala @@ -29,7 +29,7 @@ import parallel.mutable.ParArray * * @tparam A the type of this arraybuffer's elements. * - * @define Coll ArrayBuffer + * @define Coll `ArrayBuffer` * @define coll arraybuffer * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `ArrayBuffer[B]` because an implicit of type `CanBuildFrom[ArrayBuffer, B, ArrayBuffer[B]]` @@ -187,7 +187,7 @@ class ArrayBuffer[A](override protected val initialSize: Int) * * $factoryInfo * @define coll array buffer - * @define Coll ArrayBuffer + * @define Coll `ArrayBuffer` */ object ArrayBuffer extends SeqFactory[ArrayBuffer] { /** $genericCanBuildFromInfo */ diff --git a/src/library/scala/collection/mutable/ArrayLike.scala b/src/library/scala/collection/mutable/ArrayLike.scala index 23d36252d2cb..04601845c414 100644 --- a/src/library/scala/collection/mutable/ArrayLike.scala +++ b/src/library/scala/collection/mutable/ArrayLike.scala @@ -18,7 +18,7 @@ import generic._ * @tparam A type of the elements contained in the array like object. * @tparam Repr the type of the actual collection containing the elements. * - * @define Coll ArrayLike + * @define Coll `ArrayLike` * @version 2.8 * @since 2.8 */ diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala index 5f0e1e1071bf..57e81fdb9cb0 100644 --- a/src/library/scala/collection/mutable/ArrayOps.scala +++ b/src/library/scala/collection/mutable/ArrayOps.scala @@ -30,7 +30,7 @@ import parallel.mutable.ParArray * * @tparam T type of the elements contained in this array. * - * @define Coll ArrayOps + * @define Coll `ArrayOps` * @define orderDependent * @define orderDependentFold * @define mayNotTerminateInf diff --git a/src/library/scala/collection/mutable/ArraySeq.scala b/src/library/scala/collection/mutable/ArraySeq.scala index cb86c416fe83..d0eaee348bac 100644 --- a/src/library/scala/collection/mutable/ArraySeq.scala +++ b/src/library/scala/collection/mutable/ArraySeq.scala @@ -27,7 +27,7 @@ import parallel.mutable.ParArray * @tparam A type of the elements contained in this array sequence. * @param length the length of the underlying array. * - * @define Coll ArraySeq + * @define Coll `ArraySeq` * @define coll array sequence * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `ArraySeq[B]` because an implicit of type `CanBuildFrom[ArraySeq, B, ArraySeq[B]]` @@ -93,7 +93,7 @@ extends AbstractSeq[A] /** $factoryInfo * @define coll array sequence - * @define Coll ArraySeq + * @define Coll `ArraySeq` */ object ArraySeq extends SeqFactory[ArraySeq] { /** $genericCanBuildFromInfo */ diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala index b3a05348261b..04a318d0c30a 100644 --- a/src/library/scala/collection/mutable/ArrayStack.scala +++ b/src/library/scala/collection/mutable/ArrayStack.scala @@ -15,7 +15,7 @@ import generic._ * * $factoryInfo * @define coll array stack - * @define Coll ArrayStack + * @define Coll `ArrayStack` */ object ArrayStack extends SeqFactory[ArrayStack] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, ArrayStack[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] @@ -51,7 +51,7 @@ object ArrayStack extends SeqFactory[ArrayStack] { * * @tparam T type of the elements contained in this array stack. * - * @define Coll ArrayStack + * @define Coll `ArrayStack` * @define coll array stack * @define orderDependent * @define orderDependentFold diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala index 6b9673dae6e8..58b45aa2a29d 100644 --- a/src/library/scala/collection/mutable/BitSet.scala +++ b/src/library/scala/collection/mutable/BitSet.scala @@ -21,7 +21,7 @@ import BitSetLike.{LogWL, updateArray} * @see [[http://docs.scala-lang.org/overviews/collections/concrete-mutable-collection-classes.html#mutable_bitsets "Scala's Collection Library overview"]] * section on `Mutable Bitsets` for more information. * - * @define Coll BitSet + * @define Coll `BitSet` * @define coll bitset * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `BitSet[B]` because an implicit of type `CanBuildFrom[BitSet, B, BitSet]` @@ -114,7 +114,7 @@ class BitSet(protected var elems: Array[Long]) extends AbstractSet[Int] /** $factoryInfo * @define coll bitset - * @define Coll BitSet + * @define Coll `BitSet` */ object BitSet extends BitSetFactory[BitSet] { def empty: BitSet = new BitSet diff --git a/src/library/scala/collection/mutable/Buffer.scala b/src/library/scala/collection/mutable/Buffer.scala index 7326d5ec5b13..dd225cfab948 100644 --- a/src/library/scala/collection/mutable/Buffer.scala +++ b/src/library/scala/collection/mutable/Buffer.scala @@ -25,7 +25,7 @@ import generic._ * * @tparam A type of the elements contained in this buffer. * - * @define Coll Buffer + * @define Coll `Buffer` * @define coll buffer */ @cloneable @@ -37,7 +37,7 @@ trait Buffer[A] extends Seq[A] /** $factoryInfo * @define coll buffer - * @define Coll Buffer + * @define Coll `Buffer` */ object Buffer extends SeqFactory[Buffer] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Buffer[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala index 6a6bdd0077a4..aa1b20d2404b 100644 --- a/src/library/scala/collection/mutable/BufferProxy.scala +++ b/src/library/scala/collection/mutable/BufferProxy.scala @@ -25,7 +25,7 @@ import script._ * * @tparam A type of the elements the buffer proxy contains. * - * @define Coll BufferProxy + * @define Coll `BufferProxy` * @define coll buffer proxy */ trait BufferProxy[A] extends Buffer[A] with Proxy { diff --git a/src/library/scala/collection/mutable/ConcurrentMap.scala b/src/library/scala/collection/mutable/ConcurrentMap.scala index f2b44d67376d..ad6b60986265 100644 --- a/src/library/scala/collection/mutable/ConcurrentMap.scala +++ b/src/library/scala/collection/mutable/ConcurrentMap.scala @@ -20,7 +20,7 @@ package mutable * @tparam A the key type of the map * @tparam B the value type of the map * - * @define Coll ConcurrentMap + * @define Coll `ConcurrentMap` * @define coll concurrent map * @define concurrentmapinfo * This is a base trait for all Scala concurrent map implementations. It diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index 49378a4f4e8a..cba4e9725eed 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -26,7 +26,7 @@ import generic._ * * @tparam A the type of the elements contained in this double linked list. * - * @define Coll DoubleLinkedList + * @define Coll `DoubleLinkedList` * @define coll double linked list * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `DoubleLinkedList[B]` because an implicit of type `CanBuildFrom[DoubleLinkedList, B, DoubleLinkedList[B]]` @@ -67,7 +67,7 @@ class DoubleLinkedList[A]() extends AbstractSeq[A] /** $factoryInfo * @define coll double linked list - * @define Coll DoubleLinkedList + * @define Coll `DoubleLinkedList` */ object DoubleLinkedList extends SeqFactory[DoubleLinkedList] { /** $genericCanBuildFromInfo */ diff --git a/src/library/scala/collection/mutable/DoubleLinkedListLike.scala b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala index dfb70beeda05..ebccacf97655 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedListLike.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala @@ -52,7 +52,7 @@ import annotation.migration * @tparam A type of the elements contained in the double linked list * @tparam This the type of the actual linked list holding the elements * - * @define Coll DoubleLinkedList + * @define Coll `DoubleLinkedList` * @define coll double linked list */ trait DoubleLinkedListLike[A, This <: Seq[A] with DoubleLinkedListLike[A, This]] extends SeqLike[A, This] with LinkedListLike[A, This] { self => diff --git a/src/library/scala/collection/mutable/GenSeq.scala.disabled b/src/library/scala/collection/mutable/GenSeq.scala.disabled index 85e406518315..53ec5acc342c 100644 --- a/src/library/scala/collection/mutable/GenSeq.scala.disabled +++ b/src/library/scala/collection/mutable/GenSeq.scala.disabled @@ -24,7 +24,7 @@ import generic._ * * The class adds an `update` method to `collection.Seq`. * - * @define Coll mutable.Seq + * @define Coll `mutable.Seq` * @define coll mutable sequence */ trait GenSeq[A] extends GenIterable[A] diff --git a/src/library/scala/collection/mutable/GenSet.scala.disabled b/src/library/scala/collection/mutable/GenSet.scala.disabled index ac11e634e813..9080abaf3824 100644 --- a/src/library/scala/collection/mutable/GenSet.scala.disabled +++ b/src/library/scala/collection/mutable/GenSet.scala.disabled @@ -24,7 +24,7 @@ import generic._ * * @since 1.0 * @author Matthias Zenger - * @define Coll mutable.Set + * @define Coll `mutable.Set` * @define coll mutable set */ trait GenSet[A] extends GenIterable[A] diff --git a/src/library/scala/collection/mutable/GrowingBuilder.scala b/src/library/scala/collection/mutable/GrowingBuilder.scala index 0b7385194e2c..df63177b8723 100644 --- a/src/library/scala/collection/mutable/GrowingBuilder.scala +++ b/src/library/scala/collection/mutable/GrowingBuilder.scala @@ -18,7 +18,7 @@ import generic._ * @version 2.8 * @since 2.8 * - * @define Coll GrowingBuilder + * @define Coll `GrowingBuilder` * @define coll growing builder */ class GrowingBuilder[Elem, To <: Growable[Elem]](empty: To) extends Builder[Elem, To] { diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala index 65a10f4ba9d4..bf640cdb9000 100644 --- a/src/library/scala/collection/mutable/HashMap.scala +++ b/src/library/scala/collection/mutable/HashMap.scala @@ -21,7 +21,7 @@ import scala.collection.parallel.mutable.ParHashMap * @tparam A the type of the keys contained in this hash map. * @tparam B the type of the values assigned to keys in this hash map. * - * @define Coll mutable.HashMap + * @define Coll `mutable.HashMap` * @define coll mutable hash map * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `HashMap[A, B]` if the elements contained in the resulting collection are @@ -138,7 +138,7 @@ extends AbstractMap[A, B] } /** $factoryInfo - * @define Coll mutable.HashMap + * @define Coll `mutable.HashMap` * @define coll mutable hash map */ object HashMap extends MutableMapFactory[HashMap] { diff --git a/src/library/scala/collection/mutable/HashSet.scala b/src/library/scala/collection/mutable/HashSet.scala index 8ed6b925aaff..e040d1e421ed 100644 --- a/src/library/scala/collection/mutable/HashSet.scala +++ b/src/library/scala/collection/mutable/HashSet.scala @@ -25,7 +25,7 @@ import collection.parallel.mutable.ParHashSet * @see [[http://docs.scala-lang.org/overviews/collections/concrete-mutable-collection-classes.html#hash_tables "Scala's Collection Library overview"]] * section on `Hash Tables` for more information. * - * @define Coll mutable.HashSet + * @define Coll `mutable.HashSet` * @define coll mutable hash set * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `HashSet[B]` because an implicit of type `CanBuildFrom[HashSet, B, HashSet[B]]` @@ -98,7 +98,7 @@ extends AbstractSet[A] } /** $factoryInfo - * @define Coll mutable.HashSet + * @define Coll `mutable.HashSet` * @define coll mutable hash set */ object HashSet extends MutableSetFactory[HashSet] { diff --git a/src/library/scala/collection/mutable/IndexedSeq.scala b/src/library/scala/collection/mutable/IndexedSeq.scala index 0e2e06df84dc..686f90c9e87b 100644 --- a/src/library/scala/collection/mutable/IndexedSeq.scala +++ b/src/library/scala/collection/mutable/IndexedSeq.scala @@ -29,7 +29,7 @@ trait IndexedSeq[A] extends Seq[A] /** $factoryInfo * The current default implementation of a $Coll is an `ArrayBuffer`. * @define coll mutable indexed sequence - * @define Coll mutable.IndexedSeq + * @define Coll `mutable.IndexedSeq` */ object IndexedSeq extends SeqFactory[IndexedSeq] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/mutable/IndexedSeqLike.scala b/src/library/scala/collection/mutable/IndexedSeqLike.scala index 0c1df17ead43..4bd5ea1e8943 100644 --- a/src/library/scala/collection/mutable/IndexedSeqLike.scala +++ b/src/library/scala/collection/mutable/IndexedSeqLike.scala @@ -27,7 +27,7 @@ import generic._ * @tparam A the element type of the $coll * @tparam Repr the type of the actual $coll containing the elements. * - * @define Coll IndexedSeq + * @define Coll `IndexedSeq` * @define coll mutable indexed sequence * @define indexedSeqInfo * @author Martin Odersky diff --git a/src/library/scala/collection/mutable/Iterable.scala b/src/library/scala/collection/mutable/Iterable.scala index 54fe11f98c58..3b5ee63ea339 100644 --- a/src/library/scala/collection/mutable/Iterable.scala +++ b/src/library/scala/collection/mutable/Iterable.scala @@ -29,7 +29,7 @@ trait Iterable[A] extends Traversable[A] /** $factoryInfo * The current default implementation of a $Coll is an `ArrayBuffer`. * @define coll mutable iterable collection - * @define Coll mutable.Iterable + * @define Coll `mutable.Iterable` */ object Iterable extends TraversableFactory[Iterable] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Iterable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/mutable/LinearSeq.scala b/src/library/scala/collection/mutable/LinearSeq.scala index 522ebfd2771c..443b458342e5 100644 --- a/src/library/scala/collection/mutable/LinearSeq.scala +++ b/src/library/scala/collection/mutable/LinearSeq.scala @@ -17,7 +17,7 @@ import generic._ * that can be mutated. * $linearSeqInfo * - * @define Coll LinearSeq + * @define Coll `LinearSeq` * @define coll linear sequence * @see [[http://docs.scala-lang.org/overviews/collections/concrete-mutable-collection-classes.html#mutable_lists "Scala's Collection Library overview"]] * section on `Mutable Lists` for more information. @@ -33,7 +33,7 @@ trait LinearSeq[A] extends Seq[A] /** $factoryInfo * The current default implementation of a $Coll is a `MutableList`. * @define coll mutable linear sequence - * @define Coll mutable.LinearSeq + * @define Coll `mutable.LinearSeq` */ object LinearSeq extends SeqFactory[LinearSeq] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, LinearSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/mutable/LinkedHashMap.scala b/src/library/scala/collection/mutable/LinkedHashMap.scala index e4090637ecb4..cd174523b116 100644 --- a/src/library/scala/collection/mutable/LinkedHashMap.scala +++ b/src/library/scala/collection/mutable/LinkedHashMap.scala @@ -14,7 +14,7 @@ package mutable import generic._ /** $factoryInfo - * @define Coll LinkedHashMap + * @define Coll `LinkedHashMap` * @define coll linked hash map */ object LinkedHashMap extends MutableMapFactory[LinkedHashMap] { @@ -28,7 +28,7 @@ object LinkedHashMap extends MutableMapFactory[LinkedHashMap] { * @tparam A the type of the keys contained in this hash map. * @tparam B the type of the values assigned to keys in this hash map. * - * @define Coll LinkedHashMap + * @define Coll `LinkedHashMap` * @define coll linked hash map * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `LinkedHashMap[A, B]` if the elements contained in the resulting collection are diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala index d2815cf9de46..3f789f9fa2b8 100644 --- a/src/library/scala/collection/mutable/LinkedHashSet.scala +++ b/src/library/scala/collection/mutable/LinkedHashSet.scala @@ -24,7 +24,7 @@ import generic._ * * @tparam A the type of the elements contained in this set. * - * @define Coll LinkedHashSet + * @define Coll `LinkedHashSet` * @define coll linked hash set * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `LinkedHashSet[B]` because an implicit of type `CanBuildFrom[LinkedHashSet, B, LinkedHashSet[B]]` @@ -87,7 +87,7 @@ class LinkedHashSet[A] extends AbstractSet[A] } /** $factoryInfo - * @define Coll LinkedHashSet + * @define Coll `LinkedHashSet` * @define coll linked hash set */ object LinkedHashSet extends MutableSetFactory[LinkedHashSet] { diff --git a/src/library/scala/collection/mutable/LinkedList.scala b/src/library/scala/collection/mutable/LinkedList.scala index 85108276973b..335ddccf56ae 100644 --- a/src/library/scala/collection/mutable/LinkedList.scala +++ b/src/library/scala/collection/mutable/LinkedList.scala @@ -40,7 +40,7 @@ import generic._ * * @constructor Creates an "empty" list, defined as a single node with no data element and next pointing to itself. - * @define Coll LinkedList + * @define Coll `LinkedList` * @define coll linked list * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `LinkedList[B]` because an implicit of type `CanBuildFrom[LinkedList, B, LinkedList[B]]` @@ -109,7 +109,7 @@ class LinkedList[A]() extends AbstractSeq[A] } /** $factoryInfo - * @define Coll LinkedList + * @define Coll `LinkedList` * @define coll linked list */ object LinkedList extends SeqFactory[LinkedList] { diff --git a/src/library/scala/collection/mutable/LinkedListLike.scala b/src/library/scala/collection/mutable/LinkedListLike.scala index ebec31ca98d5..07a8501ca4ad 100644 --- a/src/library/scala/collection/mutable/LinkedListLike.scala +++ b/src/library/scala/collection/mutable/LinkedListLike.scala @@ -29,7 +29,7 @@ import annotation.tailrec * @tparam A type of the elements contained in the linked list * @tparam This the type of the actual linked list holding the elements * - * @define Coll LinkedList + * @define Coll `LinkedList` * @define coll linked list * * @define singleLinkedListExample diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 96e73522b6db..5c580f9c09cf 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -27,7 +27,7 @@ import java.io._ * * @tparam A the type of this list buffer's elements. * - * @define Coll ListBuffer + * @define Coll `ListBuffer` * @define coll list buffer * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `ListBuffer[B]` because an implicit of type `CanBuildFrom[ListBuffer, B, ListBuffer[B]]` @@ -425,7 +425,7 @@ final class ListBuffer[A] } /** $factoryInfo - * @define Coll ListBuffer + * @define Coll `ListBuffer` * @define coll list buffer */ object ListBuffer extends SeqFactory[ListBuffer] { diff --git a/src/library/scala/collection/mutable/ListMap.scala b/src/library/scala/collection/mutable/ListMap.scala index d8d60d1c9a29..61810c4ddfbc 100644 --- a/src/library/scala/collection/mutable/ListMap.scala +++ b/src/library/scala/collection/mutable/ListMap.scala @@ -18,7 +18,7 @@ import generic._ * @tparam A the type of the keys contained in this list map. * @tparam B the type of the values assigned to keys in this list map. * - * @define Coll mutable.ListMap + * @define Coll `mutable.ListMap` * @define coll mutable list map * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `ListMap[A, B]` if the elements contained in the resulting collection are @@ -60,7 +60,7 @@ extends AbstractMap[A, B] } /** $factoryInfo - * @define Coll mutable.ListMap + * @define Coll `mutable.ListMap` * @define coll mutable list map */ object ListMap extends MutableMapFactory[ListMap] { diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala index 0d40a1c70d9f..207b3f332411 100644 --- a/src/library/scala/collection/mutable/Map.scala +++ b/src/library/scala/collection/mutable/Map.scala @@ -63,7 +63,7 @@ trait Map[A, B] /** $factoryInfo * The current default implementation of a $Coll is a `HashMap`. * @define coll mutable map - * @define Coll mutable.Map + * @define Coll `mutable.Map` */ object Map extends MutableMapFactory[Map] { /** $canBuildFromInfo */ diff --git a/src/library/scala/collection/mutable/MultiMap.scala b/src/library/scala/collection/mutable/MultiMap.scala index 0f298c4a8af0..d21624759db9 100644 --- a/src/library/scala/collection/mutable/MultiMap.scala +++ b/src/library/scala/collection/mutable/MultiMap.scala @@ -19,7 +19,7 @@ package mutable * `B` objects. * * @define coll multimap - * @define Coll MultiMap + * @define Coll `MultiMap` * @author Matthias Zenger * @author Martin Odersky * @version 2.8 diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala index 87e5c061fa0f..2634deb81989 100644 --- a/src/library/scala/collection/mutable/OpenHashMap.scala +++ b/src/library/scala/collection/mutable/OpenHashMap.scala @@ -10,7 +10,7 @@ package scala.collection package mutable /** - * @define Coll OpenHashMap + * @define Coll `OpenHashMap` * @define coll open hash map * * @since 2.7 @@ -42,7 +42,7 @@ object OpenHashMap { * @author David MacIver * @since 2.7 * - * @define Coll OpenHashMap + * @define Coll `OpenHashMap` * @define coll open hash map * @define mayNotTerminateInf * @define willNotTerminateInf diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index 77b1ae21cb48..605d37aec631 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -23,7 +23,7 @@ import generic._ * @see [[http://docs.scala-lang.org/overviews/collections/concrete-mutable-collection-classes.html#mutable_queues "Scala's Collection Library overview"]] * section on `Queues` for more information. * - * @define Coll mutable.Queue + * @define Coll `mutable.Queue` * @define coll mutable queue * @define orderDependent * @define orderDependentFold diff --git a/src/library/scala/collection/mutable/Seq.scala b/src/library/scala/collection/mutable/Seq.scala index 89b930e36f77..ceed76cf88b2 100644 --- a/src/library/scala/collection/mutable/Seq.scala +++ b/src/library/scala/collection/mutable/Seq.scala @@ -21,7 +21,7 @@ import generic._ * * The class adds an `update` method to `collection.Seq`. * - * @define Coll mutable.Seq + * @define Coll `mutable.Seq` * @define coll mutable sequence */ trait Seq[A] extends Iterable[A] @@ -36,7 +36,7 @@ trait Seq[A] extends Iterable[A] /** $factoryInfo * The current default implementation of a $Coll is an `ArrayBuffer`. * @define coll mutable sequence - * @define Coll mutable.Seq + * @define Coll `mutable.Seq` */ object Seq extends SeqFactory[Seq] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Seq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala index 744768e8ddc1..33a99e94742a 100644 --- a/src/library/scala/collection/mutable/Set.scala +++ b/src/library/scala/collection/mutable/Set.scala @@ -19,7 +19,7 @@ import generic._ * * @since 1.0 * @author Matthias Zenger - * @define Coll mutable.Set + * @define Coll `mutable.Set` * @define coll mutable set */ trait Set[A] extends Iterable[A] @@ -34,7 +34,7 @@ trait Set[A] extends Iterable[A] /** $factoryInfo * The current default implementation of a $Coll is a `HashSet`. * @define coll mutable set - * @define Coll mutable.Set + * @define Coll `mutable.Set` */ object Set extends MutableSetFactory[Set] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Set[A]] = setCanBuildFrom[A] diff --git a/src/library/scala/collection/mutable/SortedSet.scala b/src/library/scala/collection/mutable/SortedSet.scala index f41a51d3ef99..78d12f3d641b 100644 --- a/src/library/scala/collection/mutable/SortedSet.scala +++ b/src/library/scala/collection/mutable/SortedSet.scala @@ -14,7 +14,7 @@ import generic._ /** * Base trait for mutable sorted set. * - * @define Coll mutable.SortedSet + * @define Coll `mutable.SortedSet` * @define coll mutable sorted set * * @author Lucien Pereira @@ -31,7 +31,7 @@ trait SortedSet[A] extends collection.SortedSet[A] with collection.SortedSetLike /** * A template for mutable sorted set companion objects. * - * @define Coll mutable.SortedSet + * @define Coll `mutable.SortedSet` * @define coll mutable sorted set * @define factoryInfo * This object provides a set of operations needed to create sorted sets of type mutable.SortedSet. diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala index b70df05c55ec..042eac517af4 100644 --- a/src/library/scala/collection/mutable/Stack.scala +++ b/src/library/scala/collection/mutable/Stack.scala @@ -20,7 +20,7 @@ import annotation.migration * * $factoryInfo * @define coll mutable stack - * @define Coll mutable.Stack + * @define Coll `mutable.Stack` */ object Stack extends SeqFactory[Stack] { class StackBuilder[A] extends Builder[A, Stack[A]] { @@ -46,7 +46,7 @@ object Stack extends SeqFactory[Stack] { * @since 1 * @see [[http://docs.scala-lang.org/overviews/collections/concrete-mutable-collection-classes.html#stacks "Scala's Collection Library overview"]] * section on `Stacks` for more information. - * @define Coll Stack + * @define Coll `Stack` * @define coll stack * @define orderDependent * @define orderDependentFold diff --git a/src/library/scala/collection/mutable/SynchronizedBuffer.scala b/src/library/scala/collection/mutable/SynchronizedBuffer.scala index 23552e9d5291..a14605d60ab0 100644 --- a/src/library/scala/collection/mutable/SynchronizedBuffer.scala +++ b/src/library/scala/collection/mutable/SynchronizedBuffer.scala @@ -21,7 +21,7 @@ import script._ * @author Matthias Zenger * @version 1.0, 08/07/2003 * @since 1 - * @define Coll SynchronizedBuffer + * @define Coll `SynchronizedBuffer` * @define coll synchronized buffer */ trait SynchronizedBuffer[A] extends Buffer[A] { diff --git a/src/library/scala/collection/mutable/SynchronizedMap.scala b/src/library/scala/collection/mutable/SynchronizedMap.scala index 6e3ae13ada88..037b8ec5f515 100644 --- a/src/library/scala/collection/mutable/SynchronizedMap.scala +++ b/src/library/scala/collection/mutable/SynchronizedMap.scala @@ -22,7 +22,7 @@ import annotation.migration * @author Matthias Zenger, Martin Odersky * @version 2.0, 31/12/2006 * @since 1 - * @define Coll SynchronizedMap + * @define Coll `SynchronizedMap` * @define coll synchronized map */ trait SynchronizedMap[A, B] extends Map[A, B] { diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala index 159b8312b2f6..bc325377981d 100644 --- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala @@ -20,7 +20,7 @@ package mutable * @author Matthias Zenger * @version 1.0, 03/05/2004 * @since 1 - * @define Coll SynchronizedPriorityQueue + * @define Coll `SynchronizedPriorityQueue` * @define coll synchronized priority queue */ class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQueue[A] { diff --git a/src/library/scala/collection/mutable/SynchronizedQueue.scala b/src/library/scala/collection/mutable/SynchronizedQueue.scala index 56f74a5b9b31..9e00c5d6fd51 100644 --- a/src/library/scala/collection/mutable/SynchronizedQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedQueue.scala @@ -21,7 +21,7 @@ package mutable * @author Matthias Zenger * @version 1.0, 03/05/2004 * @since 1 - * @define Coll SynchronizedQueue + * @define Coll `SynchronizedQueue` * @define coll synchronized queue */ class SynchronizedQueue[A] extends Queue[A] { diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala index c945a859f373..c28764ff68ef 100644 --- a/src/library/scala/collection/mutable/SynchronizedSet.scala +++ b/src/library/scala/collection/mutable/SynchronizedSet.scala @@ -20,7 +20,7 @@ import script._ * @author Matthias Zenger * @version 1.0, 08/07/2003 * @since 1 - * @define Coll SynchronizedSet + * @define Coll `SynchronizedSet` * @define coll synchronized set */ trait SynchronizedSet[A] extends Set[A] { diff --git a/src/library/scala/collection/mutable/SynchronizedStack.scala b/src/library/scala/collection/mutable/SynchronizedStack.scala index a09ae2190150..8363222295ce 100644 --- a/src/library/scala/collection/mutable/SynchronizedStack.scala +++ b/src/library/scala/collection/mutable/SynchronizedStack.scala @@ -21,7 +21,7 @@ package mutable * @author Matthias Zenger * @version 1.0, 03/05/2004 * @since 1 - * @define Coll SynchronizedStack + * @define Coll `SynchronizedStack` * @define coll synchronized stack */ class SynchronizedStack[A] extends Stack[A] { diff --git a/src/library/scala/collection/mutable/Traversable.scala b/src/library/scala/collection/mutable/Traversable.scala index 04b67c0badd9..28241fdec96e 100644 --- a/src/library/scala/collection/mutable/Traversable.scala +++ b/src/library/scala/collection/mutable/Traversable.scala @@ -29,7 +29,7 @@ trait Traversable[A] extends scala.collection.Traversable[A] /** $factoryInfo * The current default implementation of a $Coll is an `ArrayBuffer`. * @define coll mutable traversable collection - * @define Coll mutable.Traversable + * @define Coll `mutable.Traversable` */ object Traversable extends TraversableFactory[Traversable] { implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Traversable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]] diff --git a/src/library/scala/collection/mutable/TreeSet.scala b/src/library/scala/collection/mutable/TreeSet.scala index 02ee81119370..00675b9119b2 100644 --- a/src/library/scala/collection/mutable/TreeSet.scala +++ b/src/library/scala/collection/mutable/TreeSet.scala @@ -12,7 +12,7 @@ package mutable import generic._ /** - * @define Coll mutable.TreeSet + * @define Coll `mutable.TreeSet` * @define coll mutable tree set * @factoryInfo * Companion object of TreeSet providing factory related utilities. diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala index 889768d47110..cd76c7de4e19 100644 --- a/src/library/scala/collection/mutable/UnrolledBuffer.scala +++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala @@ -36,7 +36,7 @@ import annotation.tailrec * should still be avoided for such a purpose. * * @define coll unrolled buffer - * @define Coll UnrolledBuffer + * @define Coll `UnrolledBuffer` * @author Aleksandar Prokopec * */ diff --git a/src/library/scala/collection/mutable/WeakHashMap.scala b/src/library/scala/collection/mutable/WeakHashMap.scala index 4e09755acf5c..ec99197bb914 100644 --- a/src/library/scala/collection/mutable/WeakHashMap.scala +++ b/src/library/scala/collection/mutable/WeakHashMap.scala @@ -23,7 +23,7 @@ import convert.Wrappers._ * @see [[http://docs.scala-lang.org/overviews/collections/concrete-mutable-collection-classes.html#weak_hash_maps "Scala's Collection Library overview"]] * section on `Weak Hash Maps` for more information. * - * @define Coll WeakHashMap + * @define Coll `WeakHashMap` * @define coll weak hash map * @define thatinfo the class of the returned collection. In the standard library configuration, * `That` is always `WeakHashMap[A, B]` if the elements contained in the resulting collection are @@ -43,7 +43,7 @@ class WeakHashMap[A, B] extends JMapWrapper[A, B](new java.util.WeakHashMap) } /** $factoryInfo - * @define Coll WeakHashMap + * @define Coll `WeakHashMap` * @define coll weak hash map */ object WeakHashMap extends MutableMapFactory[WeakHashMap] { diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala index 9d170b28325a..86317819a155 100644 --- a/src/library/scala/collection/mutable/WrappedArray.scala +++ b/src/library/scala/collection/mutable/WrappedArray.scala @@ -24,7 +24,7 @@ import scala.collection.parallel.mutable.ParArray * @author Martin Odersky, Stephane Micheloud * @version 1.0 * @since 2.8 - * @define Coll WrappedArray + * @define Coll `WrappedArray` * @define coll wrapped array * @define orderDependent * @define orderDependentFold diff --git a/src/library/scala/collection/parallel/ParIterable.scala b/src/library/scala/collection/parallel/ParIterable.scala index 0b5faf15ee47..0bd6abaf7808 100644 --- a/src/library/scala/collection/parallel/ParIterable.scala +++ b/src/library/scala/collection/parallel/ParIterable.scala @@ -24,7 +24,7 @@ import scala.collection.parallel.mutable.ParArray * @author Aleksandar Prokopec * @since 2.9 * - * @define Coll ParIterable + * @define Coll `ParIterable` * @define coll parallel iterable */ trait ParIterable[+T] diff --git a/src/library/scala/collection/parallel/immutable/ParHashMap.scala b/src/library/scala/collection/parallel/immutable/ParHashMap.scala index e630a9dbed24..ad882390c83c 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashMap.scala @@ -39,7 +39,7 @@ import collection.parallel.Task * @see [[http://docs.scala-lang.org/overviews/parallel-collections/concrete-parallel-collections.html#parallel_hash_tries Scala's Parallel Collections Library overview]] * section on Parallel Hash Tries for more information. * - * @define Coll immutable.ParHashMap + * @define Coll `immutable.ParHashMap` * @define coll immutable parallel hash map */ @SerialVersionUID(1L) @@ -140,7 +140,7 @@ self => /** $factoryInfo - * @define Coll immutable.ParHashMap + * @define Coll `immutable.ParHashMap` * @define coll immutable parallel hash map */ object ParHashMap extends ParMapFactory[ParHashMap] { diff --git a/src/library/scala/collection/parallel/immutable/ParHashSet.scala b/src/library/scala/collection/parallel/immutable/ParHashSet.scala index 084637c5dcff..d1899601d705 100644 --- a/src/library/scala/collection/parallel/immutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParHashSet.scala @@ -38,7 +38,7 @@ import collection.parallel.Task * @see [[http://docs.scala-lang.org/overviews/parallel-collections/concrete-parallel-collections.html#parallel_hash_tries Scala's Parallel Collections Library overview]] * section on Parallel Hash Tries for more information. * - * @define Coll immutable.ParHashSet + * @define Coll `immutable.ParHashSet` * @define coll immutable parallel hash set */ @SerialVersionUID(1L) @@ -118,7 +118,7 @@ self => /** $factoryInfo - * @define Coll immutable.ParHashSet + * @define Coll `immutable.ParHashSet` * @define coll immutable parallel hash set */ object ParHashSet extends ParSetFactory[ParHashSet] { diff --git a/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled b/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled index fb411ec0acc5..04bc8b8d296c 100644 --- a/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled +++ b/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled @@ -29,7 +29,7 @@ import scala.collection.parallel.ParIterableIterator * @author Aleksandar Prokopec * @since 2.9 * - * @define Coll immutable.ParRange + * @define Coll `immutable.ParRange` * @define coll immutable parallel range */ @SerialVersionUID(1L) diff --git a/src/library/scala/collection/parallel/immutable/ParRange.scala b/src/library/scala/collection/parallel/immutable/ParRange.scala index 277fd5fdd350..9553704caac6 100644 --- a/src/library/scala/collection/parallel/immutable/ParRange.scala +++ b/src/library/scala/collection/parallel/immutable/ParRange.scala @@ -28,7 +28,7 @@ import scala.collection.Iterator * @see [[http://docs.scala-lang.org/overviews/parallel-collections/concrete-parallel-collections.html#parallel_range Scala's Parallel Collections Library overview]] * section on `ParRange` for more information. * - * @define Coll immutable.ParRange + * @define Coll `immutable.ParRange` * @define coll immutable parallel range */ @SerialVersionUID(1L) diff --git a/src/library/scala/collection/parallel/immutable/ParSeq.scala b/src/library/scala/collection/parallel/immutable/ParSeq.scala index bf3d3a5aa881..dde6533c8233 100644 --- a/src/library/scala/collection/parallel/immutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/immutable/ParSeq.scala @@ -24,7 +24,7 @@ import scala.collection.GenSeq /** An immutable variant of `ParSeq`. * - * @define Coll mutable.ParSeq + * @define Coll `mutable.ParSeq` * @define coll mutable parallel sequence */ trait ParSeq[+T] @@ -40,7 +40,7 @@ extends collection/*.immutable*/.GenSeq[T] /** $factoryInfo - * @define Coll mutable.ParSeq + * @define Coll `mutable.ParSeq` * @define coll mutable parallel sequence */ object ParSeq extends ParFactory[ParSeq] { diff --git a/src/library/scala/collection/parallel/immutable/ParSet.scala b/src/library/scala/collection/parallel/immutable/ParSet.scala index d64858ed10d6..40429280ac82 100644 --- a/src/library/scala/collection/parallel/immutable/ParSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParSet.scala @@ -16,7 +16,7 @@ import scala.collection.parallel.Combiner /** An immutable variant of `ParSet`. * - * @define Coll mutable.ParSet + * @define Coll `mutable.ParSet` * @define coll mutable parallel set */ trait ParSet[T] @@ -38,7 +38,7 @@ self => } /** $factoryInfo - * @define Coll mutable.ParSet + * @define Coll `mutable.ParSet` * @define coll mutable parallel set */ object ParSet extends ParSetFactory[ParSet] { diff --git a/src/library/scala/collection/parallel/immutable/ParVector.scala b/src/library/scala/collection/parallel/immutable/ParVector.scala index 8baa84b77c69..1ece663a1d96 100644 --- a/src/library/scala/collection/parallel/immutable/ParVector.scala +++ b/src/library/scala/collection/parallel/immutable/ParVector.scala @@ -37,7 +37,7 @@ import immutable.VectorIterator * @see [[http://docs.scala-lang.org/overviews/parallel-collections/concrete-parallel-collections.html#parallel_vector Scala's Parallel Collections Library overview]] * section on `ParVector` for more information. * - * @define Coll immutable.ParVector + * @define Coll `immutable.ParVector` * @define coll immutable parallel vector */ class ParVector[+T](private[this] val vector: Vector[T]) @@ -86,7 +86,7 @@ extends ParSeq[T] /** $factoryInfo - * @define Coll immutable.ParVector + * @define Coll `immutable.ParVector` * @define coll immutable parallel vector */ object ParVector extends ParFactory[ParVector] { diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index 92ba701f7c55..29d84408dbb9 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -49,7 +49,7 @@ import scala.collection.GenTraversableOnce * @see [[http://docs.scala-lang.org/overviews/parallel-collections/concrete-parallel-collections.html#parallel_array Scala's Parallel Collections Library overview]] * section on `ParArray` for more information. * - * @define Coll ParArray + * @define Coll `ParArray` * @define coll parallel array * */ @@ -685,7 +685,7 @@ self => /** $factoryInfo - * @define Coll mutable.ParArray + * @define Coll `mutable.ParArray` * @define coll parallel array */ object ParArray extends ParFactory[ParArray] { diff --git a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala index 35c748916c8d..d0c7f6050ee0 100644 --- a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala @@ -15,7 +15,7 @@ import collection.parallel.IterableSplitter * * @tparam T type of the elements in the $coll. * @define coll table - * @define Coll flat hash table + * @define Coll `ParFlatHashTable` * * @author Aleksandar Prokopec */ diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index 23b23d55a18c..05b3f89fa143 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -28,7 +28,7 @@ import collection.parallel.Task * * @tparam T type of the elements in the parallel hash map * - * @define Coll ParHashMap + * @define Coll `ParHashMap` * @define coll parallel hash map * * @author Aleksandar Prokopec @@ -141,7 +141,7 @@ self => /** $factoryInfo - * @define Coll mutable.ParHashMap + * @define Coll `mutable.ParHashMap` * @define coll parallel hash map */ object ParHashMap extends ParMapFactory[ParHashMap] { diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index 4e9a38c13f9b..783f8dce77c9 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -25,7 +25,7 @@ import collection.parallel.Task * * @tparam T type of the elements in the $coll. * - * @define Coll ParHashSet + * @define Coll `ParHashSet` * @define coll parallel hash set * * @author Aleksandar Prokopec @@ -104,7 +104,7 @@ extends ParSet[T] /** $factoryInfo - * @define Coll mutable.ParHashSet + * @define Coll `mutable.ParHashSet` * @define coll parallel hash set */ object ParHashSet extends ParSetFactory[ParHashSet] { diff --git a/src/library/scala/collection/parallel/mutable/ParSeq.scala b/src/library/scala/collection/parallel/mutable/ParSeq.scala index a48ba48d5627..f46b36949488 100644 --- a/src/library/scala/collection/parallel/mutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/mutable/ParSeq.scala @@ -26,7 +26,7 @@ import scala.collection.GenSeq /** A mutable variant of `ParSeq`. * - * @define Coll mutable.ParSeq + * @define Coll `mutable.ParSeq` * @define coll mutable parallel sequence */ trait ParSeq[T] extends collection/*.mutable*/.GenSeq[T] // was: collection.mutable.Seq[T] @@ -47,7 +47,7 @@ self => /** $factoryInfo - * @define Coll mutable.ParSeq + * @define Coll `mutable.ParSeq` * @define coll mutable parallel sequence */ object ParSeq extends ParFactory[ParSeq] { diff --git a/src/library/scala/collection/parallel/mutable/ParSet.scala b/src/library/scala/collection/parallel/mutable/ParSet.scala index 1d295fd5fe53..6da4c8a7bccc 100644 --- a/src/library/scala/collection/parallel/mutable/ParSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParSet.scala @@ -21,7 +21,7 @@ import scala.collection.GenSet /** A mutable variant of `ParSet`. * - * @define Coll mutable.ParSet + * @define Coll `mutable.ParSet` * @define coll mutable parallel set * * @author Aleksandar Prokopec @@ -41,7 +41,7 @@ self => /** $factoryInfo - * @define Coll mutable.ParSet + * @define Coll `mutable.ParSet` * @define coll mutable parallel set */ object ParSet extends ParSetFactory[ParSet] { diff --git a/src/library/scala/concurrent/package.scala b/src/library/scala/concurrent/package.scala index 169826034b90..e8921ef5315b 100644 --- a/src/library/scala/concurrent/package.scala +++ b/src/library/scala/concurrent/package.scala @@ -26,7 +26,7 @@ package concurrent { object Await { private[concurrent] implicit val canAwaitEvidence = new CanAwait {} - def ready[T <: Awaitable[_]](awaitable: T, atMost: Duration): T = { + def ready[T](awaitable: Awaitable[T], atMost: Duration): awaitable.type = { blocking(awaitable, atMost) awaitable } diff --git a/src/library/scala/reflect/api/RequiredFile.scala b/src/library/scala/reflect/api/RequiredFile.scala new file mode 100644 index 000000000000..4a545959406b --- /dev/null +++ b/src/library/scala/reflect/api/RequiredFile.scala @@ -0,0 +1,7 @@ +package scala.reflect +package api + +trait RequiredFile { + def path: String + def canonicalPath: String +} diff --git a/src/library/scala/reflect/api/Trees.scala b/src/library/scala/reflect/api/Trees.scala index f1e9cc13ca0d..b82972c9bcf4 100644 --- a/src/library/scala/reflect/api/Trees.scala +++ b/src/library/scala/reflect/api/Trees.scala @@ -110,13 +110,12 @@ trait Trees { self: Universe => def withoutAttachment(att: Any): this.type = { detach(att); this } def attachment[T: ClassTag]: T = attachmentOpt[T] getOrElse { throw new Error("no attachment of type %s".format(classTag[T].erasure)) } def attachmentOpt[T: ClassTag]: Option[T] = + firstAttachment { case attachment if attachment.getClass == classTag[T].erasure => attachment.asInstanceOf[T] } + + def firstAttachment[T](p: PartialFunction[Any, T]): Option[T] = rawatt match { - case NontrivialAttachment(pos, payload) => - val index = payload.indexWhere(p => p.getClass == classTag[T].erasure) - if (index != -1) Some(payload(index).asInstanceOf[T]) - else None - case _ => - None + case NontrivialAttachment(pos, payload) => payload.collectFirst(p) + case _ => None } private[this] var rawtpe: Type = _ diff --git a/src/library/scala/reflect/api/Types.scala b/src/library/scala/reflect/api/Types.scala index e06bb37cba49..5c7563c2c532 100755 --- a/src/library/scala/reflect/api/Types.scala +++ b/src/library/scala/reflect/api/Types.scala @@ -464,10 +464,10 @@ trait Types { self: Universe => def unapply(tpe: AnnotatedType): Option[(List[AnnotationInfo], Type, Symbol)] } - /** The least upper bound wrt <:< of a list of types */ + /** The least upper bound of a list of types, as determined by `<:<`. */ def lub(xs: List[Type]): Type - /** The greatest lower bound wrt <:< of a list of types */ + /** The greatest lower bound of a list of types, as determined by `<:<`. */ def glb(ts: List[Type]): Type // Creators --------------------------------------------------------------- @@ -515,15 +515,17 @@ trait Types { self: Universe => /** A creator for existential types. This generates: * - * tpe1 where { tparams } + * {{{ + * tpe1 where { tparams } + * }}} * - * where `tpe1` is the result of extrapolating `tpe` wrt to `tparams`. + * where `tpe1` is the result of extrapolating `tpe` with regard to `tparams`. * Extrapolating means that type variables in `tparams` occurring * in covariant positions are replaced by upper bounds, (minus any * SingletonClass markers), type variables in `tparams` occurring in * contravariant positions are replaced by upper bounds, provided the - * resulting type is legal wrt to stability, and does not contain any type - * variable in `tparams`. + * resulting type is legal with regard to stability, and does not contain + * any type variable in `tparams`. * * The abstraction drops all type parameters that are not directly or * indirectly referenced by type `tpe1`. If there are no remaining type diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index a83619cf012f..3655a0a019ab 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -145,6 +145,7 @@ import java.util.regex.{ Pattern, Matcher } */ @SerialVersionUID(-2094783597747625537L) class Regex(regex: String, groupNames: String*) extends Serializable { + outer => import Regex._ @@ -179,15 +180,14 @@ class Regex(regex: String, groupNames: String*) extends Serializable { * @return The matches */ def unapplySeq(target: Any): Option[List[String]] = target match { - case s: java.lang.CharSequence => - val m = pattern.matcher(s) - if (m.matches) Some((1 to m.groupCount).toList map m.group) + case s: CharSequence => + val m = pattern matcher s + if (runMatcher(m)) Some((1 to m.groupCount).toList map m.group) else None - case Match(s) => - unapplySeq(s) - case _ => - None + case m: Match => unapplySeq(m.matched) + case _ => None } + protected def runMatcher(m: Matcher) = m.matches() /** Return all matches of this regexp in given character sequence as a [[scala.util.matching.Regex.MatchIterator]], * which is a special [[scala.collection.Iterator]] that returns the @@ -373,10 +373,35 @@ class Regex(regex: String, groupNames: String*) extends Serializable { def split(toSplit: java.lang.CharSequence): Array[String] = pattern.split(toSplit) + /** Create a new Regex with the same pattern, but no requirement that + * the entire String matches in extractor patterns. For instance, the strings + * shown below lead to successful matches, where they would not otherwise. + * + * {{{ + * val dateP1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r.unanchored + * + * val dateP1(year, month, day) = "Date 2011-07-15" + * + * val copyright: String = "Date of this document: 2011-07-15" match { + * case dateP1(year, month, day) => "Copyright "+year + * case _ => "No copyright" + * } + * }}} + * + * @return The new unanchored regex + */ + def unanchored: UnanchoredRegex = new Regex(regex, groupNames: _*) with UnanchoredRegex { override def anchored = outer } + def anchored: Regex = this + /** The string defining the regular expression */ override def toString = regex } +trait UnanchoredRegex extends Regex { + override protected def runMatcher(m: Matcher) = m.find() + override def unanchored = this +} + /** This object defines inner classes that describe * regex matches and helper objects. The class hierarchy * is as follows: diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala index b1c3c8ba404e..66ebde592bd5 100644 --- a/test/files/jvm/annotations.scala +++ b/test/files/jvm/annotations.scala @@ -193,7 +193,9 @@ object Test6 { val c = new C("bob") c.setText("dylan") println(c.getText()) - if (new D(true).isProp()) { + val d = new D(true) + d.setProp(false) + if (!d.isProp()) { println(new D(false).getM()) } } diff --git a/test/files/neg/gadts1.check b/test/files/neg/gadts1.check index 0441f604c9f7..44d2b114d6e6 100644 --- a/test/files/neg/gadts1.check +++ b/test/files/neg/gadts1.check @@ -11,7 +11,4 @@ gadts1.scala:20: error: type mismatch; required: a case Cell[a](x: Int) => c.x = 5 ^ -gadts1.scala:20: error: Could not typecheck extractor call: case class with arguments List((x @ (_: Int))) - case Cell[a](x: Int) => c.x = 5 - ^ -four errors found +three errors found diff --git a/test/files/neg/override.check b/test/files/neg/override.check index 0336fb2b11b7..fc152cb3b1ee 100644 --- a/test/files/neg/override.check +++ b/test/files/neg/override.check @@ -1,5 +1,5 @@ override.scala:9: error: overriding type T in trait A with bounds >: Int <: Int; type T in trait B with bounds >: String <: String has incompatible type lazy val x : A with B = x - ^ + ^ one error found diff --git a/test/files/neg/patmat-type-check.check b/test/files/neg/patmat-type-check.check index ab4451f08930..e045841ce174 100644 --- a/test/files/neg/patmat-type-check.check +++ b/test/files/neg/patmat-type-check.check @@ -3,31 +3,19 @@ patmat-type-check.scala:22: error: scrutinee is incompatible with pattern type; required: String def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail ^ -patmat-type-check.scala:22: error: value _1 is not a member of object Seq - def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail - ^ patmat-type-check.scala:23: error: scrutinee is incompatible with pattern type; found : Seq[A] required: Array[Char] def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail ^ -patmat-type-check.scala:23: error: value _1 is not a member of object Seq - def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail - ^ patmat-type-check.scala:27: error: scrutinee is incompatible with pattern type; found : Seq[A] required: Test.Bop2 def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail ^ -patmat-type-check.scala:27: error: value _1 is not a member of object Seq - def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail - ^ patmat-type-check.scala:30: error: scrutinee is incompatible with pattern type; found : Seq[A] required: Test.Bop3[Char] def f4[T](x: Bop3[Char]) = x match { case Seq('b', 'o', 'b') => true } // fail ^ -patmat-type-check.scala:30: error: value _1 is not a member of object Seq - def f4[T](x: Bop3[Char]) = x match { case Seq('b', 'o', 'b') => true } // fail - ^ -8 errors found +four errors found diff --git a/test/files/neg/t0418.check b/test/files/neg/t0418.check index 50931a1bca73..4e9ad2f9aeee 100644 --- a/test/files/neg/t0418.check +++ b/test/files/neg/t0418.check @@ -4,7 +4,4 @@ t0418.scala:2: error: not found: value Foo12340771 t0418.scala:2: error: not found: value x null match { case Foo12340771.Bar(x) => x } ^ -t0418.scala:2: error: Could not typecheck extractor call: case class with arguments List((x @ _)) - null match { case Foo12340771.Bar(x) => x } - ^ -three errors found +two errors found diff --git a/test/files/neg/t112706A.check b/test/files/neg/t112706A.check index fb18b31be1c9..30d0c3ec91dd 100644 --- a/test/files/neg/t112706A.check +++ b/test/files/neg/t112706A.check @@ -3,7 +3,4 @@ t112706A.scala:5: error: constructor cannot be instantiated to expected type; required: String case Tuple2(node,_) => ^ -t112706A.scala:5: error: Could not typecheck extractor call: case class Tuple2 with arguments List((node @ _), _) - case Tuple2(node,_) => - ^ -two errors found +one error found diff --git a/test/files/neg/t3392.check b/test/files/neg/t3392.check index 3a39098c4e52..842d63eec98e 100644 --- a/test/files/neg/t3392.check +++ b/test/files/neg/t3392.check @@ -1,7 +1,4 @@ t3392.scala:9: error: not found: value x case x@A(x/*<-- refers to the pattern that includes this comment*/.Ex(42)) => ^ -t3392.scala:9: error: Could not typecheck extractor call: case class with arguments List(42) - case x@A(x/*<-- refers to the pattern that includes this comment*/.Ex(42)) => - ^ -two errors found +one error found diff --git a/test/files/neg/t418.check b/test/files/neg/t418.check index c06088ba9dd5..1489547823b3 100644 --- a/test/files/neg/t418.check +++ b/test/files/neg/t418.check @@ -4,7 +4,4 @@ t418.scala:2: error: not found: value Foo12340771 t418.scala:2: error: not found: value x null match { case Foo12340771.Bar(x) => x } ^ -t418.scala:2: error: Could not typecheck extractor call: case class with arguments List((x @ _)) - null match { case Foo12340771.Bar(x) => x } - ^ -three errors found +two errors found diff --git a/test/files/neg/t4515.check b/test/files/neg/t4515.check index 856d252a0fad..a60d16295ff2 100644 --- a/test/files/neg/t4515.check +++ b/test/files/neg/t4515.check @@ -1,6 +1,6 @@ t4515.scala:37: error: type mismatch; - found : _0(in method apply) where type _0(in method apply) - required: (some other)_0(in method apply) + found : _0(in value $anonfun) where type _0(in value $anonfun) + required: (some other)_0(in value $anonfun) handler.onEvent(target, ctx.getEvent, node, ctx) ^ one error found diff --git a/test/files/neg/t5589neg.check b/test/files/neg/t5589neg.check index fb6858a39796..b3ff16d7e4a9 100644 --- a/test/files/neg/t5589neg.check +++ b/test/files/neg/t5589neg.check @@ -22,9 +22,6 @@ t5589neg.scala:4: error: constructor cannot be instantiated to expected type; t5589neg.scala:4: error: not found: value y2 def f7(x: Either[Int, (String, Int)]) = for (y1 @ Tuple1(y2) <- x.right) yield ((y1, y2)) ^ -t5589neg.scala:4: error: Could not typecheck extractor call: case class Tuple1 with arguments List((y2 @ _)) - def f7(x: Either[Int, (String, Int)]) = for (y1 @ Tuple1(y2) <- x.right) yield ((y1, y2)) - ^ t5589neg.scala:5: error: constructor cannot be instantiated to expected type; found : (T1, T2, T3) required: (String, Int) @@ -37,4 +34,4 @@ t5589neg.scala:5: error: not found: value y2 def f8(x: Either[Int, (String, Int)]) = for ((y1, y2, y3) <- x.right) yield ((y1, y2)) ^ two warnings found -8 errors found +7 errors found diff --git a/test/files/pos/t5198.scala b/test/files/pos/t5198.scala new file mode 100644 index 000000000000..f403f77f7da4 --- /dev/null +++ b/test/files/pos/t5198.scala @@ -0,0 +1,15 @@ +package gaga + + + + + +trait Sys[Self <: Sys[Self]] { + type Tx +} + + +sealed trait AssocEntry[S <: Sys[S], @specialized(Int) A] { + def value: A + def value(implicit tx: S#Tx): A +} diff --git a/test/files/pos/t5542.flags b/test/files/pos/t5542.flags new file mode 100644 index 000000000000..464cc20ea684 --- /dev/null +++ b/test/files/pos/t5542.flags @@ -0,0 +1 @@ +-Xfatal-warnings -unchecked \ No newline at end of file diff --git a/test/files/pos/t5542.scala b/test/files/pos/t5542.scala new file mode 100644 index 000000000000..80b8cef03046 --- /dev/null +++ b/test/files/pos/t5542.scala @@ -0,0 +1,3 @@ +class Test { + Option(3) match { case Some(n) => n; case None => 0 } +} \ No newline at end of file diff --git a/test/files/pos/t5703/Base.java b/test/files/pos/t5703/Base.java new file mode 100644 index 000000000000..fa75cc3bddde --- /dev/null +++ b/test/files/pos/t5703/Base.java @@ -0,0 +1,3 @@ +public abstract class Base { + public abstract void func(Params[] params); +} \ No newline at end of file diff --git a/test/files/pos/t5703/Impl.scala b/test/files/pos/t5703/Impl.scala new file mode 100644 index 000000000000..ee22d8fb4bb0 --- /dev/null +++ b/test/files/pos/t5703/Impl.scala @@ -0,0 +1,3 @@ +class Implementation extends Base[Object] { + def func(params: Array[Object]): Unit = {} +} \ No newline at end of file diff --git a/test/files/pos/t5720-ownerous.scala b/test/files/pos/t5720-ownerous.scala new file mode 100644 index 000000000000..3a1249961243 --- /dev/null +++ b/test/files/pos/t5720-ownerous.scala @@ -0,0 +1,56 @@ + +/* + * The block under qual$1 must be owned by it. + * In the sample bug, the first default arg generates x$4, + * the second default arg generates qual$1, hence the maximal + * minimization. + * + def model: C.this.M = { + val qual$1: C.this.M = scala.Option.apply[C.this.M]({ + val x$1: lang.this.String("foo") = "foo"; + val x$2: String = C.this.M.apply$default$2("foo"); + C.this.M.apply("foo")(x$2) +}).getOrElse[C.this.M]({ + val x$3: lang.this.String("bar") = "bar"; + val x$4: String = C.this.M.apply$default$2("bar"); + C.this.M.apply("bar")(x$4) + }); + val x$5: lang.this.String("baz") = "baz"; + val x$6: String = qual$1.copy$default$2("baz"); + qual$1.copy("baz")(x$6) + } + */ +class C { + case class M(currentUser: String = "anon")(val message: String = "empty") + val m = M("foo")() + + // reported + //def model = Option(M("foo")()).getOrElse(M("bar")()).copy(currentUser = "")() + + // the bug + def model = Option(m).getOrElse(M("bar")()).copy("baz")() + + // style points for this version + def modish = ((null: Option[M]) getOrElse new M()()).copy()() + + // various simplifications are too simple + case class N(currentUser: String = "anon") + val n = N("fun") + def nudel = Option(n).getOrElse(N()).copy() +} + +object Test { + def main(args: Array[String]) { + val c = new C + println(c.model.currentUser) + println(c.model.message) + } +} +/* +symbol value x$4$1 does not exist in badcopy.C.model +at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:45) +at scala.tools.nsc.Global.abort(Global.scala:202) +at scala.tools.nsc.backend.icode.GenICode$ICodePhase.liftedTree2$1(GenICode.scala:998) +at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:992) +*/ + diff --git a/test/files/pos/t5727.scala b/test/files/pos/t5727.scala new file mode 100644 index 000000000000..e091d827b48e --- /dev/null +++ b/test/files/pos/t5727.scala @@ -0,0 +1,31 @@ + +/* + * We like operators, bar none. + */ +object Test { + + trait SomeInfo + case object NoInfo extends SomeInfo + + sealed abstract class Res[+T] + case object NotRes extends Res[Nothing] + + + abstract class Base[+T] { + def apply(f: String): Res[T] + // 'i' crashes the compiler, similarly if we use currying + //def |[U >: T](a: => Base[U], i: SomeInfo = NoInfo): Base[U] = null + def bar[U >: T](a: => Base[U], i: SomeInfo = NoInfo): Base[U] = null + } + + implicit def fromStringToBase(a: String): Base[String] = new Base[String] { def apply(in: String) = NotRes } + + // bug + //def Sample: Base[Any] = ( rep("foo" | "bar") | "sth") + def Sample: Base[Any] = ( rep("foo" bar "bar") bar "sth") + + def rep[T](p: => Base[T]): Base[T] = null // whatever + + def main(args: Array[String]) { + } +} diff --git a/test/files/pos/t5729.scala b/test/files/pos/t5729.scala new file mode 100644 index 000000000000..9fd9c9ffbb5b --- /dev/null +++ b/test/files/pos/t5729.scala @@ -0,0 +1,6 @@ +trait T[X] +object Test { + def join(in: Seq[T[_]]): Int = ??? + def join[S](in: Seq[T[S]]): String = ??? + join(null: Seq[T[_]]) +} \ No newline at end of file diff --git a/test/files/presentation/patmat.flags b/test/files/presentation/patmat.flags index 468b48c9e357..dc13682c5ea2 100644 --- a/test/files/presentation/patmat.flags +++ b/test/files/presentation/patmat.flags @@ -1,3 +1,2 @@ # This test will fail in the new pattern matcher because # it generates trees whose positions are not transparent --Xoldpatmat diff --git a/test/files/run/existentials3-old.check b/test/files/run/existentials3-old.check index e166e53ba896..72abfac63714 100644 --- a/test/files/run/existentials3-old.check +++ b/test/files/run/existentials3-old.check @@ -1,22 +1,22 @@ -_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object -_ <: Object with Test$ToS with scala.Product with scala.Serializable -Object with Test$ToS -Object with Test$ToS -Object with Test$ToS -scala.Function0[Object with Test$ToS] -scala.Function0[Object with Test$ToS] -_ <: Object with _ <: Object with Object with Test$ToS -_ <: Object with _ <: Object with _ <: Object with Test$ToS -scala.collection.immutable.List[Object with scala.collection.Seq[Int]] -scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]] -_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object -_ <: Object with Test$ToS with scala.Product with scala.Serializable -Object with Test$ToS -Object with Test$ToS -Object with Test$ToS -scala.Function0[Object with Test$ToS] -scala.Function0[Object with Test$ToS] -_ <: Object with _ <: Object with Object with Test$ToS -_ <: Object with _ <: Object with _ <: Object with Test$ToS -scala.collection.immutable.List[Object with scala.collection.Seq[Int]] -scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]] +_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object +_ <: Object with Test$ToS with scala.Product with scala.Serializable +Object with Test$ToS +Object with Test$ToS +Object with Test$ToS +scala.Function0[Object with Test$ToS] +scala.Function0[Object with Test$ToS] +_ <: Object with _ <: Object with Test$ToS +_ <: Object with _ <: Object with _ <: Object with Test$ToS +scala.collection.immutable.List[Object with scala.collection.Seq[Int]] +scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]] +_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object +_ <: Object with Test$ToS with scala.Product with scala.Serializable +Object with Test$ToS +Object with Test$ToS +Object with Test$ToS +scala.Function0[Object with Test$ToS] +scala.Function0[Object with Test$ToS] +_ <: Object with _ <: Object with Test$ToS +_ <: Object with _ <: Object with _ <: Object with Test$ToS +scala.collection.immutable.List[Object with scala.collection.Seq[Int]] +scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]] diff --git a/test/files/run/inner-parse.check b/test/files/run/inner-parse.check index 87ea9ddeb503..e4a30714bd6e 100644 --- a/test/files/run/inner-parse.check +++ b/test/files/run/inner-parse.check @@ -5,6 +5,7 @@ class Test$$anonfun$main$1 extends scala.runtime.AbstractFunction1$mcVL$sp descriptor ()V descriptor apply (Lscala/Tuple2;)V descriptor apply (Ljava/lang/Object;)Ljava/lang/Object; + descriptor apply (Ljava/lang/Object;)V descriptor cwd$1 Ljava/lang/String; descriptor serialVersionUID J descriptor (Ljava/lang/String;)V diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index d16e2c517852..bdf76ddce1ef 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -4,27 +4,28 @@ namer 2 resolve names, attach symbols to named trees packageobjects 3 load package objects typer 4 the meat and potatoes: type the trees - superaccessors 5 add super accessors in traits and nested classes - extmethods 6 add extension methods for inline classes - pickler 7 serialize symbol tables - refchecks 8 reference/override checking, translate nested objects - uncurry 9 uncurry, translate function values to anonymous classes - tailcalls 10 replace tail calls by jumps - specialize 11 @specialized-driven class and method specialization - explicitouter 12 this refs to outer pointers, translate patterns - erasure 13 erase types, add interfaces for traits - posterasure 14 clean up erased inline classes - lazyvals 15 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 16 move nested functions to top level - constructors 17 move field definitions into constructors - flatten 18 eliminate inner classes - mixin 19 mixin composition - cleanup 20 platform-specific cleanups, generate reflective calls - icode 21 generate portable intermediate code - inliner 22 optimization: do inlining -inlineExceptionHandlers 23 optimization: inline exception handlers - closelim 24 optimization: eliminate uncalled closures - dce 25 optimization: eliminate dead code - jvm 26 generate JVM bytecode - terminal 27 The last phase in the compiler chain + patmat 5 translate match expressions + superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code + inliner 23 optimization: do inlining +inlineExceptionHandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + dce 26 optimization: eliminate dead code + jvm 27 generate JVM bytecode + terminal 28 The last phase in the compiler chain diff --git a/test/files/run/reify_fors.flags b/test/files/run/reify_fors.flags index ba80cad69bcf..e69de29bb2d1 100644 --- a/test/files/run/reify_fors.flags +++ b/test/files/run/reify_fors.flags @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/reify_maps.flags b/test/files/run/reify_maps.flags index ba80cad69bcf..e69de29bb2d1 100644 --- a/test/files/run/reify_maps.flags +++ b/test/files/run/reify_maps.flags @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/repl-suppressed-warnings.scala b/test/files/run/repl-suppressed-warnings.scala index 9afbbaf1a5b9..1a51afe34fb6 100644 --- a/test/files/run/repl-suppressed-warnings.scala +++ b/test/files/run/repl-suppressed-warnings.scala @@ -1,7 +1,7 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-Xoldpatmat" + override def extraSettings = "" def code = """ // "Is this thing on?" Not working on first couple diff --git a/test/files/run/si5045.check b/test/files/run/si5045.check new file mode 100644 index 000000000000..7e9c1961b7fa --- /dev/null +++ b/test/files/run/si5045.check @@ -0,0 +1,6 @@ + extract an exact match 2011-07-15 2011-07-15 + extract from middle of string 2011-07-15 2011-07-15 + extract from middle of string (P2) 2011-07-15 2011-07-15 + extract from middle of string (P3) 2011-07-15 2011-07-15 + copyright example has date Copyright 2011 Copyright 2011 + copyright example missing date No copyright No copyright diff --git a/test/files/run/si5045.scala b/test/files/run/si5045.scala new file mode 100644 index 000000000000..e198b101f3cc --- /dev/null +++ b/test/files/run/si5045.scala @@ -0,0 +1,46 @@ +object Test extends App { + + import scala.util.matching.{ Regex, UnanchoredRegex } + + val dateP1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r.unanchored + val dateP2 = """(\d\d\d\d)-(\d\d)-(\d\d)""" r ("year", "month", "day") unanchored + val dateP3 = new Regex("""(\d\d\d\d)-(\d\d)-(\d\d)""", "year", "month", "day") with UnanchoredRegex + + val yearStr = "2011" + val dateStr = List(yearStr,"07","15").mkString("-") + + def test(msg: String)(strs: Seq[String]): Unit = println("%40s %s".format(msg, strs mkString " ")) + + test("extract an exact match") { + val dateP1(y,m,d) = dateStr + Seq(List(y,m,d).mkString("-"), dateStr) + } + + test("extract from middle of string") { + val dateP1(y,m,d) = "Tested on "+dateStr+"." + Seq(List(y,m,d).mkString("-"), dateStr) + } + + test("extract from middle of string (P2)") { + val dateP2(y,m,d) = "Tested on "+dateStr+"." + Seq(List(y,m,d).mkString("-"), dateStr) + } + + test("extract from middle of string (P3)") { + val dateP2(y,m,d) = "Tested on "+dateStr+"." + Seq(List(y,m,d).mkString("-"), dateStr) + } + + def copyright(in: String): String = in match { + case dateP1(year, month, day) => "Copyright "+year + case _ => "No copyright" + } + + test("copyright example has date") { + Seq(copyright("Date of this document: "+dateStr), "Copyright "+yearStr) + } + + test("copyright example missing date") { + Seq(copyright("Date of this document: unknown"), "No copyright") + } +} diff --git a/test/files/run/t4536.check b/test/files/run/t4536.check new file mode 100644 index 000000000000..0c5a72ada74a --- /dev/null +++ b/test/files/run/t4536.check @@ -0,0 +1,8 @@ +cls: bar +obj: foo +obj: bar +cls: bar +obj: bar +trait: pili +trait: mili +trait: foo \ No newline at end of file diff --git a/test/files/run/t4536.scala b/test/files/run/t4536.scala new file mode 100644 index 000000000000..acd91deb7fb9 --- /dev/null +++ b/test/files/run/t4536.scala @@ -0,0 +1,46 @@ + + + + + + +object dynamicObject extends Dynamic { + def applyDynamic(m: String)() = println("obj: " + m); + this.foo() +} + + +class dynamicClass extends Dynamic { + def applyDynamic(m: String)() = println("cls: " + m); + this.bar() + dynamicObject.bar() +} + + +abstract class dynamicAbstractClass extends Dynamic { + def applyDynamic(m: String)(args: Any*): Unit + this.pili(1, new dynamicClass, "hello"); +} + + +trait dynamicTrait extends Dynamic { + def applyDynamic(m: String)(args: Any*) = println("trait: " + m); + def two = 2 + this.mili(1,2,3) + two +} + + +object dynamicMixin extends dynamicAbstractClass with dynamicTrait { + this.foo(None) +} + + +object Test { + + def main(args: Array[String]) { + val cls = new dynamicClass + dynamicMixin + } + +} diff --git a/test/files/run/t5272_1.flags b/test/files/run/t5272_1.flags index cb8324a345b7..e69de29bb2d1 100644 --- a/test/files/run/t5272_1.flags +++ b/test/files/run/t5272_1.flags @@ -1 +0,0 @@ --Xoldpatmat \ No newline at end of file diff --git a/test/files/run/t5272_2.flags b/test/files/run/t5272_2.flags index cb8324a345b7..e69de29bb2d1 100644 --- a/test/files/run/t5272_2.flags +++ b/test/files/run/t5272_2.flags @@ -1 +0,0 @@ --Xoldpatmat \ No newline at end of file diff --git a/test/files/run/t5273_1.flags b/test/files/run/t5273_1.flags index ba80cad69bcf..e69de29bb2d1 100644 --- a/test/files/run/t5273_1.flags +++ b/test/files/run/t5273_1.flags @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/t5273_2a.flags b/test/files/run/t5273_2a.flags index ba80cad69bcf..e69de29bb2d1 100644 --- a/test/files/run/t5273_2a.flags +++ b/test/files/run/t5273_2a.flags @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/t5273_2b.flags b/test/files/run/t5273_2b.flags index ba80cad69bcf..e69de29bb2d1 100644 --- a/test/files/run/t5273_2b.flags +++ b/test/files/run/t5273_2b.flags @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/t5543.check b/test/files/run/t5543.check new file mode 100644 index 000000000000..517038f4c73f --- /dev/null +++ b/test/files/run/t5543.check @@ -0,0 +1,3 @@ +Test, 7, 119 +m, 3, 19 +Test, 5, 85 diff --git a/test/files/run/t5543.scala b/test/files/run/t5543.scala new file mode 100644 index 000000000000..651bc7f2b24f --- /dev/null +++ b/test/files/run/t5543.scala @@ -0,0 +1,26 @@ + +object Test extends Function0[Int] { + // this and v resolve to Test.this, Test.v not A.this, A.v + class A(x: Function0[Int] = this)(val a: Int = v, val b: Int = v * x()) extends Function0[Int] { + val v = 3 + override def toString = x.toString +", "+ a +", "+ b + // ordinary instance scope + def m(i: Int = v, y: Function0[Int] = this) = "m, "+ i +", "+ y() + def apply() = 19 + } + object A { + val v = 5 + // should happily coexist with default getters, in a happier world + def init(x: Function0[Int] = Test.this)(a: Int = v, b: Int = v * x()) = x.toString +", "+ a +", "+ b + override def toString = "A" + } + val v = 7 + def apply() = 17 + override def toString = "Test" + def main(args: Array[String]) { + val sut = new A()() + println(sut.toString) + println(sut.m()) + println(A.init()()) + } +} diff --git a/test/files/run/t5688.check b/test/files/run/t5688.check new file mode 100644 index 000000000000..2c84f9e2ef7a --- /dev/null +++ b/test/files/run/t5688.check @@ -0,0 +1 @@ +Vector(ta, tb, tab) diff --git a/test/files/run/t5688.scala b/test/files/run/t5688.scala new file mode 100644 index 000000000000..f99bfb47d332 --- /dev/null +++ b/test/files/run/t5688.scala @@ -0,0 +1,23 @@ +object Test extends App { + trait T + + trait TA + trait TB + + class A extends T with TA + class B extends T with TB + class AB extends T with TA with TB + // Matching on _: TA with TB + + val li: Vector[T] = Vector(new A, new B, new AB) + + val matched = (for (l <- li) yield { + l match { + case _: TA with TB => "tab" + case _: TA => "ta" + case _: TB => "tb" + } + }) + + println(matched) +} \ No newline at end of file diff --git a/test/files/run/virtpatmat_staging.flags b/test/files/run/virtpatmat_staging.flags index 3f5a3100e469..48fd867160ba 100644 --- a/test/files/run/virtpatmat_staging.flags +++ b/test/files/run/virtpatmat_staging.flags @@ -1 +1 @@ - -Xexperimental +-Xexperimental diff --git a/test/pending/neg/t5618.check b/test/pending/neg/t5618.check new file mode 100644 index 000000000000..118e812ae403 --- /dev/null +++ b/test/pending/neg/t5618.check @@ -0,0 +1,7 @@ +t5618.scala:12: error: could not find implicit value for parameter class1: Class1 + val class2 = new Class2 + ^ +t5618.scala:18: error: could not find implicit value for parameter class1: Class1 + val class2 = new Class2 + ^ +two errors found \ No newline at end of file diff --git a/test/pending/neg/t5618.scala b/test/pending/neg/t5618.scala new file mode 100644 index 000000000000..66e06787f1d2 --- /dev/null +++ b/test/pending/neg/t5618.scala @@ -0,0 +1,27 @@ + + + + +case class Class1 + + +case class Class2(implicit class1: Class1) + + +object Test1 { + val class2 = new Class2 + implicit val class1 = new Class1 +} + + +object Test2 { + val class2 = new Class2 + implicit val class1: Class1 = new Class1 +} + + +object Test3 { + implicit val class1 = new Class1 + val class2 = new Class2 +} + diff --git a/test/pending/pos/t4683.scala b/test/pending/pos/t4683.scala new file mode 100644 index 000000000000..7af70241592a --- /dev/null +++ b/test/pending/pos/t4683.scala @@ -0,0 +1,11 @@ + + + + +class DelayedInitTest { + def a = () + class B extends DelayedInit { + a + def delayedInit(body: => Unit) = () + } +} diff --git a/test/pending/pos/t5240.scala b/test/pending/pos/t5240.scala new file mode 100644 index 000000000000..2db689c27d4c --- /dev/null +++ b/test/pending/pos/t5240.scala @@ -0,0 +1,11 @@ + + + + + + +package object foo { + + var labels: Array[_ <: String] = null + +} diff --git a/test/pending/pos/t5559.scala b/test/pending/pos/t5559.scala new file mode 100644 index 000000000000..586e52cd4fbb --- /dev/null +++ b/test/pending/pos/t5559.scala @@ -0,0 +1,23 @@ + + + + +object Test { + + class Inv[T] + + def foo[S](interface: Inv[_ >: S], implementation: Inv[S]) {} + + def bar[R, T <: R](interface: Inv[R], impl: Inv[T]) { + //foo[T](interface, impl) + foo(interface, impl) // Compilation Error + // Inv[R] <: Inv[_ >: S] + // Inv[T] <: Inv[S] + // ---------------------- + // R >: S + // T == S + } + +} + + diff --git a/test/pending/pos/t5606.scala b/test/pending/pos/t5606.scala new file mode 100644 index 000000000000..2545271e32d8 --- /dev/null +++ b/test/pending/pos/t5606.scala @@ -0,0 +1,9 @@ + + + + + + + + +case class CaseTest[_](someData:String) diff --git a/test/pending/run/t5018.scala b/test/pending/run/t5018.scala new file mode 100644 index 000000000000..30c0d5ac94e5 --- /dev/null +++ b/test/pending/run/t5018.scala @@ -0,0 +1,34 @@ + + + +import java.io._ +import collection._ + + + +object Test { + + def serializeDeserialize[T <: AnyRef](obj: T) = { + val buffer = new ByteArrayOutputStream + val out = new ObjectOutputStream(buffer) + out.writeObject(obj) + val in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray)) + in.readObject.asInstanceOf[T] + } + + def main(args: Array[String]) { + val values = mutable.Map(1 -> 1).values + assert(serializeDeserialize(values) == values) + + val keyset = mutable.Map(1 -> 1).keySet + assert(serializeDeserialize(keyset) == keyset) + + val imkeyset = immutable.Map(1 -> 1).keySet + assert(serializeDeserialize(imkeyset) == imkeyset) + + val defaultmap = immutable.Map(1 -> 1).withDefaultValue(1) + assert(serializeDeserialize(defaultmap) == defaultmap) + } + +} + diff --git a/test/pending/run/t5514.scala b/test/pending/run/t5514.scala new file mode 100644 index 000000000000..eacad21cd813 --- /dev/null +++ b/test/pending/run/t5514.scala @@ -0,0 +1,35 @@ + + + +import scala.io.Source +import scala.util.parsing.combinator.Parsers +import scala.util.parsing.input.Reader +import scala.util.parsing.input.Position + + + +object DemoApp extends App { + val parsers = new DemoParsers + val reader = new DemoReader(10) + val result = parsers.startsWith("s").*(reader) + Console println result +} + + +class DemoReader(n: Int) extends Reader[String] { + def atEnd = n == 0 + def first = "s" + n + def rest = new DemoReader(n - 1) + def pos = new Position { + def line = 0 + def column = 0 + def lineContents = first + } + println("reader: " + n) +} + + +class DemoParsers extends Parsers { + type Elem = String + def startsWith(prefix: String) = acceptIf(_ startsWith prefix)("Error: " + _) +} diff --git a/test/pending/run/t5676.flags b/test/pending/run/t5676.flags new file mode 100644 index 000000000000..e1b37447c953 --- /dev/null +++ b/test/pending/run/t5676.flags @@ -0,0 +1 @@ +-Xexperimental \ No newline at end of file diff --git a/test/pending/run/t5676.scala b/test/pending/run/t5676.scala new file mode 100644 index 000000000000..3ff498eaa268 --- /dev/null +++ b/test/pending/run/t5676.scala @@ -0,0 +1,25 @@ + + + + +class Bar[T] + + +class Foo[T] { + object A extends Bar[T] +} + + +class Baz[S] extends Foo[S] { + override object A extends Bar[S] +} + + +object Test { + + def main(a: Array[String]) { + val b = new Baz[Any] + println(b) + } + +} diff --git a/test/pending/run/t5698/client.scala b/test/pending/run/t5698/client.scala new file mode 100644 index 000000000000..de672c1809fe --- /dev/null +++ b/test/pending/run/t5698/client.scala @@ -0,0 +1,9 @@ +package client + + + +object Client extends App { + val peer = actors.remote.Node("localhost", 23456) + val a = actors.remote.RemoteActor.select(peer, 'test) + a ! server.TestMsg +} diff --git a/test/pending/run/t5698/server.scala b/test/pending/run/t5698/server.scala new file mode 100644 index 000000000000..e8f3cea22580 --- /dev/null +++ b/test/pending/run/t5698/server.scala @@ -0,0 +1,22 @@ +package server + + + +object Server extends App { + + class ServerActor extends actors.Actor { + def act() { + actors.remote.RemoteActor.alive(23456) + actors.remote.RemoteActor.register('test, actors.Actor.self) + loop { + react { + case TestMsg => println("Yay!") + } + } + } + } + + val a = new ServerActor + a.start() + +} diff --git a/test/pending/run/t5698/testmsg.scala b/test/pending/run/t5698/testmsg.scala new file mode 100644 index 000000000000..004ff0b8c723 --- /dev/null +++ b/test/pending/run/t5698/testmsg.scala @@ -0,0 +1,5 @@ +package server + + + +case object TestMsg diff --git a/test/scaladoc/resources/package-object-res.scala b/test/scaladoc/resources/package-object-res.scala new file mode 100644 index 000000000000..17d5c0a49919 --- /dev/null +++ b/test/scaladoc/resources/package-object-res.scala @@ -0,0 +1,14 @@ +/** This package have A and B. + */ +package test { + trait A { def hi = "hello" } + trait B { def bye = "bye!" } +} + +/** This package object extends A and B. + */ +package object test extends A with B { + override def hi = "good morning!" + override def bye = "good bye!" + protected def thank = "thank you!" +} diff --git a/test/scaladoc/run/package-object.check b/test/scaladoc/run/package-object.check new file mode 100644 index 000000000000..4297847e73ec --- /dev/null +++ b/test/scaladoc/run/package-object.check @@ -0,0 +1,2 @@ +List((test.B,B), (test.A,A), (scala.AnyRef,AnyRef), (scala.Any,Any)) +Done. diff --git a/test/scaladoc/run/package-object.scala b/test/scaladoc/run/package-object.scala new file mode 100644 index 000000000000..fd36a8df7b0e --- /dev/null +++ b/test/scaladoc/run/package-object.scala @@ -0,0 +1,15 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest +import language._ + +object Test extends ScaladocModelTest { + override def resourceFile = "package-object-res.scala" + override def scaladocSettings = "" + def testModel(root: Package) = { + import access._ + + val p = root._package("test") + println(p.linearization) + } +} + diff --git a/test/scaladoc/run/usecase-var-expansion.check b/test/scaladoc/run/usecase-var-expansion.check new file mode 100644 index 000000000000..3faa4735c088 --- /dev/null +++ b/test/scaladoc/run/usecase-var-expansion.check @@ -0,0 +1,4 @@ +newSource:8: error: Incorrect variable expansion for $Coll in use case. Does the variable expand to wiki syntax when documenting class Test2? + * @usecase def foo: $Coll[T] + ^ +Done. diff --git a/test/scaladoc/run/usecase-var-expansion.scala b/test/scaladoc/run/usecase-var-expansion.scala new file mode 100644 index 000000000000..e86ea4a835f6 --- /dev/null +++ b/test/scaladoc/run/usecase-var-expansion.scala @@ -0,0 +1,26 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest +import language._ + +object Test extends ScaladocModelTest { + + override def code = """ + /** + * @define Coll `Test` + */ + class Test[T] { + /** + * member $Coll + * @usecase def foo: $Coll[T] + * usecase $Coll + */ + def foo(implicit err: String): Test[T] = sys.error(err) + } + + /** @define Coll {{{some `really` < !! >> invalid $$$ thing}}} */ + class Test2[T] extends Test[Int] + """ + + def scaladocSettings = "" + def testModel(root: Package) = () +}