summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.xml4
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Aliases.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala9
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala36
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/page/Template.scala6
-rw-r--r--src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala8
-rw-r--r--src/compiler/scala/tools/nsc/transform/LazyVals.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala19
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala12
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala13
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
-rw-r--r--src/library/scala/Function.scala4
-rw-r--r--src/library/scala/LowPriorityImplicits.scala21
-rw-r--r--src/library/scala/PartialFunction.scala135
-rw-r--r--src/library/scala/collection/CustomParallelizable.scala2
-rw-r--r--src/library/scala/collection/JavaConversions.scala3
-rw-r--r--src/library/scala/collection/convert/WrapAsScala.scala22
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala78
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala14
-rw-r--r--src/library/scala/collection/immutable/Stream.scala42
-rw-r--r--src/library/scala/collection/mutable/ArrayLike.scala2
-rw-r--r--src/library/scala/collection/mutable/ArrayOps.scala28
-rw-r--r--src/library/scala/collection/mutable/DoubleLinkedList.scala7
-rw-r--r--src/library/scala/collection/mutable/IndexedSeqLike.scala2
-rwxr-xr-xsrc/library/scala/collection/mutable/IndexedSeqOptimized.scala2
-rw-r--r--src/library/scala/math/BigDecimal.scala2
-rw-r--r--src/library/scala/math/BigInt.scala4
-rw-r--r--src/library/scala/math/ScalaNumericConversions.scala12
-rw-r--r--src/library/scala/reflect/ClassTag.scala9
-rw-r--r--src/library/scala/reflect/base/Symbols.scala16
-rw-r--r--src/library/scala/reflect/base/TypeTags.scala2
-rw-r--r--src/library/scala/runtime/AbstractPartialFunction.scala40
-rw-r--r--src/library/scala/runtime/RichBoolean.scala4
-rw-r--r--src/library/scala/runtime/RichByte.scala5
-rw-r--r--src/library/scala/runtime/RichChar.scala5
-rw-r--r--src/library/scala/runtime/RichDouble.scala6
-rw-r--r--src/library/scala/runtime/RichFloat.scala6
-rw-r--r--src/library/scala/runtime/RichInt.scala4
-rw-r--r--src/library/scala/runtime/RichLong.scala5
-rw-r--r--src/library/scala/runtime/RichShort.scala5
-rw-r--r--src/library/scala/runtime/ScalaNumberProxy.scala19
-rw-r--r--src/library/scala/runtime/StringAdd.scala5
-rw-r--r--src/library/scala/runtime/StringFormat.scala4
-rw-r--r--src/library/scala/runtime/Tuple2Zipped.scala45
-rw-r--r--src/library/scala/runtime/Tuple3Zipped.scala58
-rw-r--r--src/library/scala/util/control/Exception.scala2
-rw-r--r--src/reflect/scala/reflect/api/FlagSets.scala2
-rw-r--r--src/reflect/scala/reflect/api/Mirrors.scala2
-rw-r--r--src/reflect/scala/reflect/api/Symbols.scala6
-rw-r--r--src/reflect/scala/reflect/api/Types.scala7
-rw-r--r--src/reflect/scala/reflect/internal/Importers.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala1
-rw-r--r--src/reflect/scala/reflect/macros/Aliases.scala2
-rw-r--r--src/reflect/scala/reflect/runtime/JavaMirrors.scala2
-rw-r--r--test/files/jvm/future-spec/TryTests.scala14
-rw-r--r--test/files/jvm/manifests-new.scala2
-rw-r--r--test/files/neg/implicit-shadow.check11
-rw-r--r--test/files/neg/implicit-shadow.flags1
-rw-r--r--test/files/neg/implicit-shadow.scala13
-rw-r--r--test/files/neg/javaConversions-2.10-ambiguity.check6
-rw-r--r--test/files/neg/javaConversions-2.10-ambiguity.scala10
-rw-r--r--test/files/neg/t6227.check4
-rw-r--r--test/files/neg/t6227.scala6
-rw-r--r--test/files/neg/t6264.check6
-rw-r--r--test/files/neg/t6264.flags1
-rw-r--r--test/files/neg/t6264.scala6
-rw-r--r--test/files/neg/t6283.check4
-rw-r--r--test/files/neg/t6283.scala1
-rw-r--r--test/files/neg/t900.check4
-rw-r--r--test/files/neg/unit2anyref.check2
-rw-r--r--test/files/pos/javaConversions-2.10-regression.scala17
-rw-r--r--test/files/pos/t5667.scala2
-rw-r--r--test/files/run/classtags_core.check60
-rw-r--r--test/files/run/existentials3-new.check16
-rw-r--r--test/files/run/existentials3-new.scala2
-rw-r--r--test/files/run/inline-ex-handlers.check27
-rw-r--r--test/files/run/macro-expand-implicit-argument.check1
-rw-r--r--test/files/run/macro-expand-implicit-argument.flags1
-rw-r--r--test/files/run/macro-expand-implicit-argument/Macros_1.scala59
-rw-r--r--test/files/run/macro-expand-implicit-argument/Test_2.scala4
-rw-r--r--test/files/run/partialfun.check6
-rw-r--r--test/files/run/partialfun.scala86
-rw-r--r--test/files/run/reflection-sorted-decls.check4
-rw-r--r--test/files/run/reflection-sorted-decls.scala2
-rw-r--r--test/files/run/reflection-sorted-members.check30
-rw-r--r--test/files/run/reflection-sorted-members.scala2
-rw-r--r--test/files/run/richWrapperEquals.scala4
-rw-r--r--test/files/run/stream-stack-overflow-filter-map.scala44
-rw-r--r--test/files/run/t1987b.check1
-rw-r--r--test/files/run/t1987b/PullIteratees.scala17
-rw-r--r--test/files/run/t1987b/a.scala6
-rw-r--r--test/files/run/t1987b/cce_test.scala15
-rw-r--r--test/files/run/t1987b/pkg1.scala4
-rw-r--r--test/files/run/t1987b/pkg2.scala3
-rw-r--r--test/files/run/t5356.check8
-rw-r--r--test/files/run/t5356.scala6
-rw-r--r--test/files/run/t6261.scala130
-rw-r--r--test/files/run/t6272.check10
-rw-r--r--test/files/run/t6272.scala62
-rw-r--r--test/files/run/t6292.scala18
-rw-r--r--test/files/run/try-catch-unify.check1
-rw-r--r--test/files/run/try-catch-unify.scala1
104 files changed, 1091 insertions, 423 deletions
diff --git a/build.xml b/build.xml
index 647697bed5..99b68ced84 100644
--- a/build.xml
+++ b/build.xml
@@ -281,6 +281,8 @@ INITIALISATION
<!-- Resolve maven dependencies -->
<target name="init.maven.jars" depends="init.maven.tasks">
+ <!-- This target has an issue where if the user directory does not exist, we BOMB. ugh. -->
+ <mkdir dir="${user.home}/.m2/repository"/>
<artifact:dependencies pathId="dependency.classpath" filesetId="dependency.fileset">
<!--<dependency groupId="com.typesafe" artifactId="config" version="0.4.0"/>-->
</artifact:dependencies>
@@ -2178,7 +2180,7 @@ DOCUMENTATION
docfooter="epfl"
docsourceurl="${scaladoc.url}€{FILE_PATH}.scala#L1"
docUncompilable="${src.dir}/library-aux"
- skipPackages="scala.reflect.macros"
+ skipPackages="scala.reflect.macros.internal"
sourcepath="${src.dir}"
classpathref="pack.classpath"
addparams="${scalac.args.all}"
diff --git a/src/compiler/scala/reflect/macros/runtime/Aliases.scala b/src/compiler/scala/reflect/macros/runtime/Aliases.scala
index 8b742755cd..5e15b61dbd 100644
--- a/src/compiler/scala/reflect/macros/runtime/Aliases.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Aliases.scala
@@ -21,6 +21,8 @@ trait Aliases {
override type TypeTag[T] = universe.TypeTag[T]
override val AbsTypeTag = universe.AbsTypeTag
override val TypeTag = universe.TypeTag
+ override def absTypeTag[T](implicit attag: AbsTypeTag[T]) = attag
override def typeTag[T](implicit ttag: TypeTag[T]) = ttag
+ override def absTypeOf[T](implicit attag: AbsTypeTag[T]): Type = attag.tpe
override def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 17bea7f796..e79c92e162 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1366,7 +1366,8 @@ self =>
}
parseDo
case FOR =>
- def parseFor = atPos(in.skipToken()) {
+ val start = in.skipToken()
+ def parseFor = atPos(start) {
val enums =
if (in.token == LBRACE) inBracesOrNil(enumerators())
else inParensOrNil(enumerators())
@@ -1378,7 +1379,11 @@ self =>
makeFor(enums, expr())
}
}
- parseFor
+ def adjustStart(tree: Tree) =
+ if (tree.pos.isRange && start < tree.pos.start)
+ tree setPos tree.pos.withStart(start)
+ else tree
+ adjustStart(parseFor)
case RETURN =>
def parseReturn =
atPos(in.skipToken()) {
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
index 8bbf11650c..486a43614b 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
@@ -42,10 +42,14 @@ trait BasicBlocks {
private final class SuccessorList() {
private var successors: List[BasicBlock] = Nil
+ /** This method is very hot! Handle with care. */
private def updateConserve() {
- var lb: ListBuffer[BasicBlock] = null
- var matches = 0
- var remaining = successors
+ var lb: ListBuffer[BasicBlock] = null
+ var matches = 0
+ var remaining = successors
+ val direct = directSuccessors
+ var scratchHandlers: List[ExceptionHandler] = method.exh
+ var scratchBlocks: List[BasicBlock] = direct
def addBlock(bb: BasicBlock) {
if (matches < 0)
@@ -60,25 +64,27 @@ trait BasicBlocks {
}
}
- // exceptionSuccessors
- method.exh foreach { handler =>
- if (handler covers outer)
- addBlock(handler.startBlock)
+ while (scratchBlocks ne Nil) {
+ addBlock(scratchBlocks.head)
+ scratchBlocks = scratchBlocks.tail
}
- // directSuccessors
- val direct = directSuccessors
- direct foreach addBlock
-
/** Return a list of successors for 'b' that come from exception handlers
* covering b's (non-exceptional) successors. These exception handlers
* might not cover 'b' itself. This situation corresponds to an
* exception being thrown as the first thing of one of b's successors.
*/
- method.exh foreach { handler =>
- direct foreach { block =>
- if (handler covers block)
+ while (scratchHandlers ne Nil) {
+ val handler = scratchHandlers.head
+ if (handler covers outer)
+ addBlock(handler.startBlock)
+
+ scratchBlocks = direct
+ while (scratchBlocks ne Nil) {
+ if (handler covers scratchBlocks.head)
addBlock(handler.startBlock)
+ scratchBlocks = scratchBlocks.tail
}
+ scratchHandlers = scratchHandlers.tail
}
// Blocks did not align: create a new list.
if (matches < 0)
@@ -101,7 +107,7 @@ trait BasicBlocks {
}
/** Flags of this basic block. */
- private var flags: Int = 0
+ private[this] var flags: Int = 0
/** Does this block have the given flag? */
def hasFlag(flag: Int): Boolean = (flags & flag) != 0
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 1f68781777..24a26b2ad3 100644
--- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
@@ -49,7 +49,11 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp
if(top === self) {{
var url = '{ val p = templateToPath(tpl); "../" * (p.size - 1) + "index.html" }';
var hash = '{ val p = templateToPath(tpl); (p.tail.reverse ::: List(p.head.replace(".html", ""))).mkString(".") }';
- window.location.href = url + '#' + hash;
+ var anchor = window.location.hash;
+ var anchor_opt = '';
+ if (anchor.length { scala.xml.Unparsed(">=") /* unless we use Unparsed, it gets escaped and crashes the script */ } 1)
+ anchor_opt = '@' + anchor.substring(1);
+ window.location.href = url + '#' + hash + anchor_opt;
}}
</script>
</xml:group>
diff --git a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
index efc393c812..2aed99657e 100644
--- a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
+++ b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
@@ -113,9 +113,11 @@ trait ScratchPadMaker { self: Global =>
val topLevel = objectName.isEmpty
if (topLevel) objectName = tree.symbol.fullName
body foreach traverseStat
- applyPendingPatches(skipped)
- if (topLevel)
- patches += Patch(skipped, epilogue)
+ if (skipped != 0) { // don't issue prologue and epilogue if there are no instrumented statements
+ applyPendingPatches(skipped)
+ if (topLevel)
+ patches += Patch(skipped, epilogue)
+ }
case _ =>
}
diff --git a/src/compiler/scala/tools/nsc/transform/LazyVals.scala b/src/compiler/scala/tools/nsc/transform/LazyVals.scala
index 4c555f4740..c0cc560a17 100644
--- a/src/compiler/scala/tools/nsc/transform/LazyVals.scala
+++ b/src/compiler/scala/tools/nsc/transform/LazyVals.scala
@@ -111,7 +111,7 @@ abstract class LazyVals extends Transform with TypingTransformers with ast.TreeD
var added = false
val stats =
for (stat <- body1) yield stat match {
- case Block(_, _) | Apply(_, _) | If(_, _, _) if !added =>
+ case Block(_, _) | Apply(_, _) | If(_, _, _) | Try(_, _, _) if !added =>
// Avoid adding bitmaps when they are fully overshadowed by those
// that are added inside loops
if (LocalLazyValFinder.find(stat)) {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 226e17f605..6a91922b4c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -593,7 +593,7 @@ trait Implicits {
typed1(itree, EXPRmode, wildPt)
if (context.hasErrors)
- return fail("typed implicit %s has errors".format(info.sym.fullLocationString))
+ return fail(context.errBuffer.head.errMsg)
if (Statistics.canEnable) Statistics.incCounter(typedImplicits)
@@ -615,7 +615,7 @@ trait Implicits {
}
if (context.hasErrors)
- fail("hasMatchingSymbol reported threw error(s)")
+ fail("hasMatchingSymbol reported error: " + context.errBuffer.head.errMsg)
else if (isLocal && !hasMatchingSymbol(itree1))
fail("candidate implicit %s is shadowed by %s".format(
info.sym.fullLocationString, itree1.symbol.fullLocationString))
@@ -639,7 +639,7 @@ trait Implicits {
// #2421: check that we correctly instantiated type parameters outside of the implicit tree:
checkBounds(itree2, NoPrefix, NoSymbol, undetParams, targs, "inferred ")
if (context.hasErrors)
- return fail("type parameters weren't correctly instantiated outside of the implicit tree")
+ return fail("type parameters weren't correctly instantiated outside of the implicit tree: " + context.errBuffer.head.errMsg)
// filter out failures from type inference, don't want to remove them from undetParams!
// we must be conservative in leaving type params in undetparams
@@ -675,7 +675,7 @@ trait Implicits {
}
if (context.hasErrors)
- fail("typing TypeApply reported errors for the implicit tree")
+ fail("typing TypeApply reported errors for the implicit tree: " + context.errBuffer.head.errMsg)
else {
val result = new SearchResult(itree2, subst)
if (Statistics.canEnable) Statistics.incCounter(foundImplicits)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 239d53cf37..fadf9b8acc 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1393,14 +1393,17 @@ trait Infer {
else =:=
)
(arg hasAnnotation UncheckedClass) || {
- val TypeRef(_, sym, args) = arg.withoutAnnotations
-
- ( isLocalBinding(sym)
- || arg.typeSymbol.isTypeParameterOrSkolem
- || (sym.name == tpnme.WILDCARD) // avoid spurious warnings on HK types
- || check(arg, param.tpeHK, conforms)
- || warn("non-variable type argument " + arg)
- )
+ arg.withoutAnnotations match {
+ case TypeRef(_, sym, args) =>
+ ( isLocalBinding(sym)
+ || arg.typeSymbol.isTypeParameterOrSkolem
+ || (sym.name == tpnme.WILDCARD) // avoid spurious warnings on HK types
+ || check(arg, param.tpeHK, conforms)
+ || warn("non-variable type argument " + arg)
+ )
+ case _ =>
+ warn("non-variable type argument " + arg)
+ }
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index dbafd01ebc..01e773e528 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -588,7 +588,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
val nullaryArgsEmptyParams = exprArgs.isEmpty && macroDef.paramss == ListOfNil
if (argcDoesntMatch && !nullaryArgsEmptyParams) { typer.TyperErrorGen.MacroPartialApplicationError(expandee) }
- var argss: List[List[Any]] = exprArgs.toList
+ val argss: List[List[Any]] = exprArgs.toList
macroTraceVerbose("context: ")(context)
macroTraceVerbose("argss: ")(argss)
@@ -597,9 +597,6 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
if (fastTrack(macroDef) validate context) argss
else typer.TyperErrorGen.MacroPartialApplicationError(expandee)
} else {
- val binding = loadMacroImplBinding(macroDef)
- macroTraceVerbose("binding: ")(binding)
-
// if paramss have typetag context bounds, add an arglist to argss if necessary and instantiate the corresponding evidences
// consider the following example:
//
@@ -616,6 +613,8 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
// then T and U need to be inferred from the lexical scope of the call using `asSeenFrom`
// whereas V won't be resolved by asSeenFrom and need to be loaded directly from `expandee` which needs to contain a TypeApply node
// also, macro implementation reference may contain a regular type as a type argument, then we pass it verbatim
+ val binding = loadMacroImplBinding(macroDef)
+ macroTraceVerbose("binding: ")(binding)
val tags = binding.signature filter (_ != -1) map (paramPos => {
val targ = binding.targs(paramPos).tpe.typeSymbol
val tpe = if (targ.isTypeParameterOrSkolem) {
@@ -633,14 +632,13 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
targ.tpe
if (tpe.isConcrete) context.TypeTag(tpe) else context.AbsTypeTag(tpe)
})
- val hasImplicitParams = macroDef.paramss.flatten.lastOption exists (_.isImplicit)
- argss = if (hasImplicitParams) argss.dropRight(1) :+ (tags ++ argss.last) else argss :+ tags
+ macroTraceVerbose("tags: ")(tags)
// transforms argss taking into account varargness of paramss
// note that typetag context bounds are only declared on macroImpls
// so this optional arglist might not match macroDef's paramlist
// nb! varargs can apply to any parameter section, not necessarily to the last one
- mapWithIndex(argss)((as, i) => {
+ mapWithIndex(argss :+ tags)((as, i) => {
val mapsToParamss = macroDef.paramss.indices contains i
if (mapsToParamss) {
val ps = macroDef.paramss(i)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index fd27c3c070..18b3fe5f4c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -192,6 +192,10 @@ trait Namers extends MethodSynthesis {
if (!allowsOverload(sym)) {
val prev = scope.lookupEntry(sym.name)
if ((prev ne null) && prev.owner == scope && conflict(sym, prev.sym)) {
+ if (sym.isSynthetic || prev.sym.isSynthetic) {
+ handleSyntheticNameConflict(sym, prev.sym)
+ handleSyntheticNameConflict(prev.sym, sym)
+ }
DoubleDefError(sym, prev.sym)
sym setInfo ErrorType
scope unlink prev.sym // let them co-exist...
@@ -202,6 +206,14 @@ trait Namers extends MethodSynthesis {
scope enter sym
}
+ /** Logic to handle name conflicts of synthetically generated symbols
+ * We handle right now: t6227
+ */
+ def handleSyntheticNameConflict(sym1: Symbol, sym2: Symbol) = {
+ if (sym1.isImplicit && sym1.isMethod && sym2.isModule && sym2.companionClass.isCaseClass)
+ validate(sym2.companionClass)
+ }
+
def enterSym(tree: Tree): Context = {
def dispatch() = {
var returnContext = this.context
@@ -1390,6 +1402,7 @@ trait Namers extends MethodSynthesis {
fail(ImplicitAtToplevel)
}
if (sym.isClass) {
+ checkNoConflict(IMPLICIT, CASE)
if (sym.isAnyOverride && !sym.hasFlag(TRAIT))
fail(OverrideClass)
} else {
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 91435e2214..71d352345b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1618,6 +1618,8 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
if ((clazz isSubClass AnyValClass) && !isPrimitiveValueClass(clazz)) {
if (clazz.isTrait)
unit.error(clazz.pos, "Only classes (not traits) are allowed to extend AnyVal")
+ else if ((clazz != AnyValClass) && clazz.hasFlag(ABSTRACT))
+ unit.error(clazz.pos, "`abstract' modifier cannot be used with value classes")
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 1770f2419a..f80810e082 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4726,8 +4726,13 @@ trait Typers extends Modes with Adaptations with Tags {
if (isInPackageObject(defEntry.sym, pre.typeSymbol)) {
defSym = pre.member(defEntry.sym.name)
if (defSym ne defEntry.sym) {
- log("!!! Overloaded package object member resolved incorrectly.\n Discarded: " +
- defEntry.sym.defString + "\n Using: " + defSym.defString)
+ qual = gen.mkAttributedQualifier(pre)
+ log(s"""
+ | !!! Overloaded package object member resolved incorrectly.
+ | prefix: $pre
+ | Discarded: ${defEntry.sym.defString}
+ | Using: ${defSym.defString}
+ """.stripMargin)
}
}
else
diff --git a/src/library/scala/Function.scala b/src/library/scala/Function.scala
index 270581a3aa..d470f4c966 100644
--- a/src/library/scala/Function.scala
+++ b/src/library/scala/Function.scala
@@ -28,11 +28,11 @@ object Function {
/** Turns a function `A => Option[B]` into a `PartialFunction[A, B]`.
*
- * TODO: check if the paragraph below is still correct
* '''Important note''': this transformation implies the original function
- * will be called 2 or more times on each logical invocation, because the
+ * may be called 2 or more times on each logical invocation, because the
* only way to supply an implementation of `isDefinedAt` is to call the
* function and examine the return value.
+ * See also [[scala.PartialFunction]], method `applyOrElse`.
*
* @param f a function `T => Option[R]`
* @return a partial function defined for those inputs where
diff --git a/src/library/scala/LowPriorityImplicits.scala b/src/library/scala/LowPriorityImplicits.scala
index 491cd417a3..8c49d2f67b 100644
--- a/src/library/scala/LowPriorityImplicits.scala
+++ b/src/library/scala/LowPriorityImplicits.scala
@@ -27,15 +27,20 @@ class LowPriorityImplicits {
* any potential conflicts. Conflicts do exist because the wrappers
* need to implement ScalaNumber in order to have a symmetric equals
* method, but that implies implementing java.lang.Number as well.
+ *
+ * Note - these are inlined because they are value classes, but
+ * the call to xxxWrapper is not eliminated even though it does nothing.
+ * Even inlined, every call site does a no-op retrieval of Predef's MODULE$
+ * because maybe loading Predef has side effects!
*/
- implicit def byteWrapper(x: Byte) = new runtime.RichByte(x)
- implicit def shortWrapper(x: Short) = new runtime.RichShort(x)
- implicit def intWrapper(x: Int) = new runtime.RichInt(x)
- implicit def charWrapper(c: Char) = new runtime.RichChar(c)
- implicit def longWrapper(x: Long) = new runtime.RichLong(x)
- implicit def floatWrapper(x: Float) = new runtime.RichFloat(x)
- implicit def doubleWrapper(x: Double) = new runtime.RichDouble(x)
- implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
+ @inline implicit def byteWrapper(x: Byte) = new runtime.RichByte(x)
+ @inline implicit def shortWrapper(x: Short) = new runtime.RichShort(x)
+ @inline implicit def intWrapper(x: Int) = new runtime.RichInt(x)
+ @inline implicit def charWrapper(c: Char) = new runtime.RichChar(c)
+ @inline implicit def longWrapper(x: Long) = new runtime.RichLong(x)
+ @inline implicit def floatWrapper(x: Float) = new runtime.RichFloat(x)
+ @inline implicit def doubleWrapper(x: Double) = new runtime.RichDouble(x)
+ @inline implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
// These eight implicits exist solely to exclude Null from the domain of
// the boxed types, so that e.g. "var x: Int = null" is a compile time
diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala
index 7154b8da34..d0a339bdd5 100644
--- a/src/library/scala/PartialFunction.scala
+++ b/src/library/scala/PartialFunction.scala
@@ -67,7 +67,7 @@ trait PartialFunction[-A, +B] extends (A => B) { self =>
* of this partial function and `that`. The resulting partial function
* takes `x` to `this(x)` where `this` is defined, and to `that(x)` where it is not.
*/
- def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]) : PartialFunction[A1, B1] =
+ def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]): PartialFunction[A1, B1] =
new OrElse[A1, B1] (this, that)
//TODO: why not overload it with orElse(that: F1): F1?
@@ -78,10 +78,8 @@ trait PartialFunction[-A, +B] extends (A => B) { self =>
* @return a partial function with the same domain as this partial function, which maps
* arguments `x` to `k(this(x))`.
*/
- override def andThen[C](k: B => C) : PartialFunction[A, C] = new PartialFunction[A, C] {
- def isDefinedAt(x: A): Boolean = self isDefinedAt x
- def apply(x: A): C = k(self(x))
- }
+ override def andThen[C](k: B => C): PartialFunction[A, C] =
+ new AndThen[A, B, C] (this, k)
/** Turns this partial function into an plain function returning an `Option` result.
* @see Function.unlift
@@ -90,28 +88,54 @@ trait PartialFunction[-A, +B] extends (A => B) { self =>
*/
def lift: A => Option[B] = new Lifted(this)
- /**
- * TODO: comment
+ /** Applies this partial function to the given argument when it is contained in the function domain.
+ * Applies fallback function where this partial function is not defined.
+ *
+ * Note that expression `pf.applyOrElse(x, default)` is equivalent to
+ * {{{ if(pf isDefinedAt x) pf(x) else default(x) }}}
+ * except that `applyOrElse` method can be implemented more efficiently.
+ * For all partial function literals compiler generates `applyOrElse` implementation which
+ * avoids double evaluation of pattern matchers and guards.
+ * This makes `applyOrElse` the basis for the efficient implementation for many operations and scenarios, such as:
+ *
+ * - combining partial functions into `orElse`/`andThen` chains does not lead to
+ * excessive `apply`/`isDefinedAt` evaluation
+ * - `lift` and `unlift` do not evaluate source functions twice on each invocation
+ * - `runWith` allows efficient imperative-style combining of partial functions
+ * with conditionally applied actions
+ *
+ * For non-literal partial function classes with nontrivial `isDefinedAt` method
+ * it is recommended to override `applyOrElse` with custom implementation that avoids
+ * double `isDefinedAt` evaluation. This may result in better performance
+ * and more predictable behavior w.r.t. side effects.
+ *
+ * @param x the function argument
+ * @param default the fallback function
+ * @return the result of this function or fallback function application.
* @since 2.10
*/
def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 =
if (isDefinedAt(x)) apply(x) else default(x)
- /**
- * TODO: comment
- * @since 2.10
- */
- def run[U](x: A)(action: B => U): Boolean =
- applyOrElse(x, fallbackToken) match {
- case FallbackToken => false
- case z => action(z); true
- }
-
- /**
- * TODO: comment
+ /** Composes this partial function with an action function which
+ * gets applied to results of this partial function.
+ * The action function is invoked only for its side effects; its result is ignored.
+ *
+ * Note that expression `pf.runWith(action)(x)` is equivalent to
+ * {{{ if(pf isDefinedAt x) { action(pf(x)); true } else false }}}
+ * except that `runWith` is implemented via `applyOrElse` and thus potentially more efficient.
+ * Using `runWith` avoids double evaluation of pattern matchers and guards for partial function literals.
+ * @see `applyOrElse`.
+ *
+ * @param action the action function
+ * @return a function which maps arguments `x` to `isDefinedAt(x)`. The resulting function
+ * runs `action(this(x))` where `this` is defined.
* @since 2.10
*/
- def runWith[U](action: B => U): A => Boolean = { x => run(x)(action) }
+ def runWith[U](action: B => U): A => Boolean = { x =>
+ val z = applyOrElse(x, checkFallback[B])
+ if (!fallbackOccurred(z)) { action(z); true } else false
+ }
}
/** A few handy operations which leverage the extra bit of information
@@ -137,11 +161,10 @@ object PartialFunction {
def apply(x: A): B = f1.applyOrElse(x, f2)
- override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 =
- f1.applyOrElse(x, fallbackToken) match {
- case FallbackToken => f2.applyOrElse(x, default)
- case z => z
- }
+ override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = {
+ val z = f1.applyOrElse(x, checkFallback[B])
+ if (!fallbackOccurred(z)) z else f2.applyOrElse(x, default)
+ }
override def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]) =
new OrElse[A1, B1] (f1, f2 orElse that)
@@ -150,23 +173,61 @@ object PartialFunction {
new OrElse[A, C] (f1 andThen k, f2 andThen k)
}
- private[scala] lazy val FallbackToken: PartialFunction[Any, PartialFunction[Any, Nothing]] = { case _ => FallbackToken.asInstanceOf[PartialFunction[Any, Nothing]] }
- private[scala] final def fallbackToken[B] = FallbackToken.asInstanceOf[PartialFunction[Any, B]]
- //TODO: check generated code for PF literal here
+ /** Composite function produced by `PartialFunction#andThen` method
+ */
+ private final class AndThen[-A, B, +C] (pf: PartialFunction[A, B], k: B => C) extends PartialFunction[A, C] {
+ def isDefinedAt(x: A) = pf.isDefinedAt(x)
+
+ def apply(x: A): C = k(pf(x))
+
+ override def applyOrElse[A1 <: A, C1 >: C](x: A1, default: A1 => C1): C1 = {
+ val z = pf.applyOrElse(x, checkFallback[B])
+ if (!fallbackOccurred(z)) k(z) else default(x)
+ }
+ }
+
+ /** To implement patterns like {{{ if(pf isDefinedAt x) f1(pf(x)) else f2(x) }}} efficiently
+ * the following trick is used:
+ *
+ * To avoid double evaluation of pattern matchers & guards `applyOrElse` method is used here
+ * instead of `isDefinedAt`/`apply` pair.
+ *
+ * After call to `applyOrElse` we need both the function result it returned and
+ * the fact if the function's argument was contained in its domain. The only degree of freedom we have here
+ * to achieve this goal is tweaking with the continuation argument (`default`) of `applyOrElse` method.
+ * The obvious way is to throw an exception from `default` function and to catch it after
+ * calling `applyOrElse` but I consider this somewhat inefficient.
+ *
+ * I know only one way how you can do this task efficiently: `default` function should return unique marker object
+ * which never may be returned by any other (regular/partial) function. This way after calling `applyOrElse` you need
+ * just one reference comparison to distinguish if `pf isDefined x` or not.
+ *
+ * This correctly interacts with specialization as return type of `applyOrElse`
+ * (which is parameterized upper bound) can never be specialized.
+ *
+ * Here `fallback_pf` is used as both unique marker object and special fallback function that returns it.
+ */
+ private[this] final val fallback_pf: PartialFunction[Any, Any] = { case _ => fallback_pf }
+ @inline private final def checkFallback[B] = fallback_pf.asInstanceOf[PartialFunction[Any, B]]
+ @inline private final def fallbackOccurred[B](x: B) = (fallback_pf eq x.asInstanceOf[AnyRef])
- private[scala] final class Lifted[-A, +B] (val pf: PartialFunction[A, B])
+ private final class Lifted[-A, +B] (val pf: PartialFunction[A, B])
extends runtime.AbstractFunction1[A, Option[B]] {
- def apply(x: A): Option[B] = pf.applyOrElse(x, fallbackToken) match {
- case FallbackToken => None
- case z => Some(z)
+ def apply(x: A): Option[B] = {
+ val z = pf.applyOrElse(x, checkFallback[B])
+ if (!fallbackOccurred(z)) Some(z) else None
}
}
private final class Unlifted[A, B] (f: A => Option[B]) extends runtime.AbstractPartialFunction[A, B] {
def isDefinedAt(x: A): Boolean = f(x).isDefined
- override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 =
- f(x) getOrElse default(x) //TODO: check generated code and inline getOrElse if needed
+
+ override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = {
+ val z = f(x)
+ if (!z.isEmpty) z.get else default(x)
+ }
+
override def lift = f
}
@@ -178,7 +239,6 @@ object PartialFunction {
/** Converts ordinary function to partial one
* @since 2.10
*/
- //TODO: check generated code for PF literal here
def apply[A, B](f: A => B): PartialFunction[A, B] = { case x => f(x) }
private[this] final val constFalse: Any => Boolean = { _ => false}
@@ -189,12 +249,11 @@ object PartialFunction {
override def orElse[A1, B1](that: PartialFunction[A1, B1]) = that
override def andThen[C](k: Nothing => C) = this
override val lift = (x: Any) => None
- override def run[U](x: Any)(action: Nothing => U) = false
override def runWith[U](action: Nothing => U) = constFalse
}
- /**
- * TODO: comment
+ /** The partial function with empty domain.
+ * Any attempt to invoke empty partial function leads to throwing [[scala.MatchError]] exception.
* @since 2.10
*/
def empty[A, B] : PartialFunction[A, B] = empty_pf
diff --git a/src/library/scala/collection/CustomParallelizable.scala b/src/library/scala/collection/CustomParallelizable.scala
index dc634c67d3..a56cb5da59 100644
--- a/src/library/scala/collection/CustomParallelizable.scala
+++ b/src/library/scala/collection/CustomParallelizable.scala
@@ -10,7 +10,7 @@ package scala.collection
import parallel.Combiner
-trait CustomParallelizable[+A, +ParRepr <: Parallel] extends Parallelizable[A, ParRepr] {
+trait CustomParallelizable[+A, +ParRepr <: Parallel] extends Any with Parallelizable[A, ParRepr] {
override def par: ParRepr
override protected[this] def parCombiner: Combiner[A, ParRepr] = throw new UnsupportedOperationException("")
}
diff --git a/src/library/scala/collection/JavaConversions.scala b/src/library/scala/collection/JavaConversions.scala
index a978a9a783..8e4fdf537d 100644
--- a/src/library/scala/collection/JavaConversions.scala
+++ b/src/library/scala/collection/JavaConversions.scala
@@ -22,7 +22,8 @@ import convert._
* scala.collection.mutable.Buffer <=> java.util.List
* scala.collection.mutable.Set <=> java.util.Set
* scala.collection.mutable.Map <=> java.util.{ Map, Dictionary }
- * scala.collection.mutable.ConcurrentMap <=> java.util.concurrent.ConcurrentMap
+ * scala.collection.mutable.ConcurrentMap (deprecated since 2.10) <=> java.util.concurrent.ConcurrentMap
+ * scala.collection.concurrent.Map <=> java.util.concurrent.ConcurrentMap
*}}}
* In all cases, converting from a source type to a target type and back
* again will return the original source object, eg.
diff --git a/src/library/scala/collection/convert/WrapAsScala.scala b/src/library/scala/collection/convert/WrapAsScala.scala
index 49f4d7cd99..c2994a0986 100644
--- a/src/library/scala/collection/convert/WrapAsScala.scala
+++ b/src/library/scala/collection/convert/WrapAsScala.scala
@@ -13,7 +13,27 @@ import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
import Wrappers._
import language.implicitConversions
-trait WrapAsScala {
+trait LowPriorityWrapAsScala {
+ this: WrapAsScala =>
+ /**
+ * Implicitly converts a Java ConcurrentMap to a Scala mutable ConcurrentMap.
+ * The returned Scala ConcurrentMap is backed by the provided Java
+ * ConcurrentMap and any side-effects of using it via the Scala interface will
+ * be visible via the Java interface and vice versa.
+ *
+ * If the Java ConcurrentMap was previously obtained from an implicit or
+ * explicit call of `asConcurrentMap(scala.collection.mutable.ConcurrentMap)`
+ * then the original Scala ConcurrentMap will be returned.
+ *
+ * @param m The ConcurrentMap to be converted.
+ * @return A Scala mutable ConcurrentMap view of the argument.
+ */
+ @deprecated("Use `mapAsScalaConcurrentMap` instead, and use `concurrent.Map` instead of `ConcurrentMap`.", "2.10.0")
+ implicit def mapAsScalaDeprecatedConcurrentMap[A, B](m: juc.ConcurrentMap[A, B]): mutable.ConcurrentMap[A, B] =
+ asScalaConcurrentMap(m)
+}
+
+trait WrapAsScala extends LowPriorityWrapAsScala {
/**
* Implicitly converts a Java `Iterator` to a Scala `Iterator`.
*
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index 0b297aeb45..b41327ed95 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -146,6 +146,29 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
private object EmptyHashMap extends HashMap[Any, Nothing] { }
+ // utility method to create a HashTrieMap from two leaf HashMaps (HashMap1 or HashMapCollision1) with non-colliding hash code)
+ private def makeHashTrieMap[A, B](hash0:Int, elem0:HashMap[A, B], hash1:Int, elem1:HashMap[A, B], level:Int, size:Int) : HashTrieMap[A, B] = {
+ val index0 = (hash0 >>> level) & 0x1f
+ val index1 = (hash1 >>> level) & 0x1f
+ if(index0 != index1) {
+ val bitmap = (1 << index0) | (1 << index1)
+ val elems = new Array[HashMap[A,B]](2)
+ if(index0 < index1) {
+ elems(0) = elem0
+ elems(1) = elem1
+ } else {
+ elems(0) = elem1
+ elems(1) = elem0
+ }
+ new HashTrieMap[A, B](bitmap, elems, size)
+ } else {
+ val elems = new Array[HashMap[A,B]](1)
+ val bitmap = (1 << index0)
+ elems(0) = makeHashTrieMap(hash0, elem0, hash1, elem1, level + 5, size)
+ new HashTrieMap[A, B](bitmap, elems, size)
+ }
+ }
+
// TODO: add HashMap2, HashMap3, ...
class HashMap1[A,+B](private[collection] val key: A, private[collection] val hash: Int, private[collection] val value: (B @uV), private[collection] var kv: (A,B @uV)) extends HashMap[A,B] {
@@ -183,30 +206,10 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
new HashMap1(nkv._1, hash, nkv._2, nkv)
}
} else {
- var thatindex = (hash >>> level) & 0x1f
- var thisindex = (this.hash >>> level) & 0x1f
if (hash != this.hash) {
// they have different hashes, but may collide at this level - find a level at which they don't
- var lvl = level
- var top: HashTrieMap[A, B1] = null
- var prev: HashTrieMap[A, B1] = null
- while (thisindex == thatindex) {
- val newlevel = new HashTrieMap[A, B1](1 << thisindex, new Array[HashMap[A, B1]](1), 2)
- if (prev ne null) prev.elems(0) = newlevel else top = newlevel
- prev = newlevel
- lvl += 5
- thatindex = (hash >>> lvl) & 0x1f
- thisindex = (this.hash >>> lvl) & 0x1f
- }
- val bottelems = new Array[HashMap[A,B1]](2)
- val ind = if (thisindex < thatindex) 1 else 0
- bottelems(1 - ind) = this
- bottelems(ind) = new HashMap1[A, B1](key, hash, value, kv)
- val bottom = new HashTrieMap[A,B1]((1 << thisindex) | (1 << thatindex), bottelems, 2)
- if (prev ne null) {
- prev.elems(0) = bottom
- top
- } else bottom
+ val that = new HashMap1[A, B1](key, hash, value, kv)
+ makeHashTrieMap[A,B1](this.hash, this, hash, that, level, 2)
} else {
// 32-bit hash collision (rare, but not impossible)
new HashMapCollision1(hash, ListMap.empty.updated(this.key,this.value).updated(key,value))
@@ -221,12 +224,13 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
// this method may be called multiple times in a multithreaded environment, but that's ok
private[HashMap] def ensurePair: (A,B) = if (kv ne null) kv else { kv = (key, value); kv }
protected override def merge0[B1 >: B](that: HashMap[A, B1], level: Int, merger: Merger[A, B1]): HashMap[A, B1] = {
- that.updated0(key, hash, level, value, kv, if (merger ne null) merger.invert else null)
+ that.updated0(key, hash, level, value, kv, merger.invert)
}
}
private[collection] class HashMapCollision1[A, +B](private[collection] val hash: Int, val kvs: ListMap[A, B @uV])
extends HashMap[A, B @uV] {
+ // assert(kvs.size > 1)
override def size = kvs.size
@@ -238,20 +242,20 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
if ((merger eq null) || !kvs.contains(key)) new HashMapCollision1(hash, kvs.updated(key, value))
else new HashMapCollision1(hash, kvs + merger((key, kvs(key)), kv))
} else {
- var m: HashMap[A,B1] = new HashTrieMap[A,B1](0,new Array[HashMap[A,B1]](0),0)
- // might be able to save some ops here, but it doesn't seem to be worth it
- for ((k,v) <- kvs)
- m = m.updated0(k, this.hash, level, v, null, merger)
- m.updated0(key, hash, level, value, kv, merger)
+ val that = new HashMap1(key, hash, value, kv)
+ makeHashTrieMap(this.hash, this, hash, that, level, size + 1)
}
override def removed0(key: A, hash: Int, level: Int): HashMap[A, B] =
if (hash == this.hash) {
val kvs1 = kvs - key
- if (!kvs1.isEmpty)
- new HashMapCollision1(hash, kvs1)
- else
+ if (kvs1.isEmpty)
HashMap.empty[A,B]
+ else if(kvs1.tail.isEmpty) {
+ val kv = kvs1.head
+ new HashMap1[A,B](kv._1,hash,kv._2,kv)
+ } else
+ new HashMapCollision1(hash, kvs1)
} else this
override def iterator: Iterator[(A,B)] = kvs.iterator
@@ -275,6 +279,9 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
private[collection] val size0: Int
) extends HashMap[A, B @uV] {
+ // assert(Integer.bitCount(bitmap) == elems.length)
+ // assert(elems.length > 1 || (elems.length == 1 && elems(0).isInstanceOf[HashTrieMap[_,_]]))
+
/*
def this (level: Int, m1: HashMap1[A,B], m2: HashMap1[A,B]) = {
this(((m1.hash >>> level) & 0x1f) | ((m2.hash >>> level) & 0x1f), {
@@ -347,9 +354,14 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
Array.copy(elems, 0, elemsNew, 0, offset)
Array.copy(elems, offset + 1, elemsNew, offset, elems.length - offset - 1)
val sizeNew = size - sub.size
- new HashTrieMap(bitmapNew, elemsNew, sizeNew)
+ if (elemsNew.length == 1 && !elemsNew(0).isInstanceOf[HashTrieMap[_,_]])
+ elemsNew(0)
+ else
+ new HashTrieMap(bitmapNew, elemsNew, sizeNew)
} else
HashMap.empty[A,B]
+ } else if(elems.length == 1 && !subNew.isInstanceOf[HashTrieMap[_,_]]) {
+ subNew
} else {
val elemsNew = new Array[HashMap[A,B]](elems.length)
Array.copy(elems, 0, elemsNew, 0, elems.length)
@@ -480,7 +492,7 @@ time { mNew.iterator.foreach( p => ()) }
}
new HashTrieMap[A, B1](this.bitmap | that.bitmap, merged, totalelems)
- case hm: HashMapCollision1[_, _] => that.merge0(this, level, if (merger ne null) merger.invert else null)
+ case hm: HashMapCollision1[_, _] => that.merge0(this, level, merger.invert)
case hm: HashMap[_, _] => this
case _ => sys.error("section supposed to be unreachable.")
}
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 091443f909..c21032603f 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -121,12 +121,12 @@ extends AbstractMap[A, B]
def hasNext = !self.isEmpty
def next(): (A,B) =
if (!hasNext) throw new NoSuchElementException("next on empty iterator")
- else { val res = (self.key, self.value); self = self.next; res }
+ else { val res = (self.key, self.value); self = self.tail; res }
}.toList.reverseIterator
protected def key: A = throw new NoSuchElementException("empty map")
protected def value: B = throw new NoSuchElementException("empty map")
- protected def next: ListMap[A, B] = throw new NoSuchElementException("empty map")
+ override def tail: ListMap[A, B] = throw new NoSuchElementException("empty map")
/** This class represents an entry in the `ListMap`.
*/
@@ -140,7 +140,7 @@ extends AbstractMap[A, B]
override def size: Int = size0(this, 0)
// to allow tail recursion and prevent stack overflows
- @tailrec private def size0(cur: ListMap[A, B1], acc: Int): Int = if (cur.isEmpty) acc else size0(cur.next, acc + 1)
+ @tailrec private def size0(cur: ListMap[A, B1], acc: Int): Int = if (cur.isEmpty) acc else size0(cur.tail, acc + 1)
/** Is this an empty map?
*
@@ -157,7 +157,7 @@ extends AbstractMap[A, B]
*/
override def apply(k: A): B1 = apply0(this, k)
- @tailrec private def apply0(cur: ListMap[A, B1], k: A): B1 = if (k == cur.key) cur.value else apply0(cur.next, k)
+ @tailrec private def apply0(cur: ListMap[A, B1], k: A): B1 = if (k == cur.key) cur.value else apply0(cur.tail, k)
/** Checks if this map maps `key` to a value and return the
* value if it exists.
@@ -169,7 +169,7 @@ extends AbstractMap[A, B]
@tailrec private def get0(cur: ListMap[A, B1], k: A): Option[B1] =
if (k == cur.key) Some(cur.value)
- else if (cur.next.nonEmpty) get0(cur.next, k) else None
+ else if (cur.tail.nonEmpty) get0(cur.tail, k) else None
/** This method allows one to create a new map with an additional mapping
* from `key` to `value`. If the map contains already a mapping for `key`,
@@ -198,7 +198,7 @@ extends AbstractMap[A, B]
var lst: List[(A, B1)] = Nil
while (cur.nonEmpty) {
if (k != cur.key) lst ::= ((cur.key, cur.value))
- cur = cur.next
+ cur = cur.tail
}
var acc = ListMap[A, B1]()
while (lst != Nil) {
@@ -211,6 +211,6 @@ extends AbstractMap[A, B]
}
- override protected def next: ListMap[A, B1] = ListMap.this
+ override def tail: ListMap[A, B1] = ListMap.this
}
}
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 1bf1e20694..97707d4f7c 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -479,22 +479,40 @@ self =>
final class StreamWithFilter(p: A => Boolean) extends WithFilter(p) {
override def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Stream[A], B, That]): That = {
- def tailMap = asStream[B](tail withFilter p map f)
- if (isStreamBuilder(bf)) asThat(
- if (isEmpty) Stream.Empty
- else if (p(head)) cons(f(head), tailMap)
- else tailMap
- )
+ def tailMap(coll: Stream[A]): Stream[B] = {
+ var head: A = null.asInstanceOf[A]
+ var tail: Stream[A] = coll
+ while (true) {
+ if (tail.isEmpty)
+ return Stream.Empty
+ head = tail.head
+ tail = tail.tail
+ if (p(head))
+ return cons(f(head), tailMap(tail))
+ }
+ throw new RuntimeException()
+ }
+
+ if (isStreamBuilder(bf)) asThat(tailMap(Stream.this))
else super.map(f)(bf)
}
override def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Stream[A], B, That]): That = {
- def tailFlatMap = asStream[B](tail withFilter p flatMap f)
- if (isStreamBuilder(bf)) asThat(
- if (isEmpty) Stream.Empty
- else if (p(head)) f(head).toStream append tailFlatMap
- else tailFlatMap
- )
+ def tailFlatMap(coll: Stream[A]): Stream[B] = {
+ var head: A = null.asInstanceOf[A]
+ var tail: Stream[A] = coll
+ while (true) {
+ if (tail.isEmpty)
+ return Stream.Empty
+ head = tail.head
+ tail = tail.tail
+ if (p(head))
+ return f(head).toStream append tailFlatMap(tail)
+ }
+ throw new RuntimeException()
+ }
+
+ if (isStreamBuilder(bf)) asThat(tailFlatMap(Stream.this))
else super.flatMap(f)(bf)
}
diff --git a/src/library/scala/collection/mutable/ArrayLike.scala b/src/library/scala/collection/mutable/ArrayLike.scala
index 04601845c4..172993c5c3 100644
--- a/src/library/scala/collection/mutable/ArrayLike.scala
+++ b/src/library/scala/collection/mutable/ArrayLike.scala
@@ -22,7 +22,7 @@ import generic._
* @version 2.8
* @since 2.8
*/
-trait ArrayLike[A, +Repr] extends IndexedSeqOptimized[A, Repr] { self =>
+trait ArrayLike[A, +Repr] extends Any with IndexedSeqOptimized[A, Repr] { self =>
/** Creates a possible nested `IndexedSeq` which consists of all the elements
* of this array. If the elements are arrays themselves, the `deep` transformation
diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala
index 21c2aaaec7..b3cd6a95c5 100644
--- a/src/library/scala/collection/mutable/ArrayOps.scala
+++ b/src/library/scala/collection/mutable/ArrayOps.scala
@@ -6,18 +6,14 @@
** |/ **
\* */
-
-
package scala.collection
package mutable
-import compat.Platform.arraycopy
+import compat.Platform.arraycopy
import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime._
-
import parallel.mutable.ParArray
-
/** This class serves as a wrapper for `Array`s with all the operations found in
* indexed sequences. Where needed, instances of arrays are implicitly converted
* into this class.
@@ -36,7 +32,7 @@ import parallel.mutable.ParArray
* @define mayNotTerminateInf
* @define willNotTerminateInf
*/
-abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParallelizable[T, ParArray[T]] {
+trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParallelizable[T, ParArray[T]] {
private def elementClass: Class[_] =
arrayElementClass(repr.getClass)
@@ -105,7 +101,7 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza
object ArrayOps {
/** A class of `ArrayOps` for arrays containing reference types. */
- class ofRef[T <: AnyRef](override val repr: Array[T]) extends ArrayOps[T] with ArrayLike[T, Array[T]] {
+ final class ofRef[T <: AnyRef](override val repr: Array[T]) extends AnyVal with ArrayOps[T] with ArrayLike[T, Array[T]] {
override protected[this] def thisCollection: WrappedArray[T] = new WrappedArray.ofRef[T](repr)
override protected[this] def toCollection(repr: Array[T]): WrappedArray[T] = new WrappedArray.ofRef[T](repr)
@@ -117,7 +113,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays containing `byte`s. */
- class ofByte(override val repr: Array[Byte]) extends ArrayOps[Byte] with ArrayLike[Byte, Array[Byte]] {
+final class ofByte(override val repr: Array[Byte]) extends AnyVal with ArrayOps[Byte] with ArrayLike[Byte, Array[Byte]] {
override protected[this] def thisCollection: WrappedArray[Byte] = new WrappedArray.ofByte(repr)
override protected[this] def toCollection(repr: Array[Byte]): WrappedArray[Byte] = new WrappedArray.ofByte(repr)
@@ -129,7 +125,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays containing `short`s. */
- class ofShort(override val repr: Array[Short]) extends ArrayOps[Short] with ArrayLike[Short, Array[Short]] {
+final class ofShort(override val repr: Array[Short]) extends AnyVal with ArrayOps[Short] with ArrayLike[Short, Array[Short]] {
override protected[this] def thisCollection: WrappedArray[Short] = new WrappedArray.ofShort(repr)
override protected[this] def toCollection(repr: Array[Short]): WrappedArray[Short] = new WrappedArray.ofShort(repr)
@@ -141,7 +137,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays containing `char`s. */
- class ofChar(override val repr: Array[Char]) extends ArrayOps[Char] with ArrayLike[Char, Array[Char]] {
+final class ofChar(override val repr: Array[Char]) extends AnyVal with ArrayOps[Char] with ArrayLike[Char, Array[Char]] {
override protected[this] def thisCollection: WrappedArray[Char] = new WrappedArray.ofChar(repr)
override protected[this] def toCollection(repr: Array[Char]): WrappedArray[Char] = new WrappedArray.ofChar(repr)
@@ -153,7 +149,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays containing `int`s. */
- class ofInt(override val repr: Array[Int]) extends ArrayOps[Int] with ArrayLike[Int, Array[Int]] {
+final class ofInt(override val repr: Array[Int]) extends AnyVal with ArrayOps[Int] with ArrayLike[Int, Array[Int]] {
override protected[this] def thisCollection: WrappedArray[Int] = new WrappedArray.ofInt(repr)
override protected[this] def toCollection(repr: Array[Int]): WrappedArray[Int] = new WrappedArray.ofInt(repr)
@@ -165,7 +161,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays containing `long`s. */
- class ofLong(override val repr: Array[Long]) extends ArrayOps[Long] with ArrayLike[Long, Array[Long]] {
+final class ofLong(override val repr: Array[Long]) extends AnyVal with ArrayOps[Long] with ArrayLike[Long, Array[Long]] {
override protected[this] def thisCollection: WrappedArray[Long] = new WrappedArray.ofLong(repr)
override protected[this] def toCollection(repr: Array[Long]): WrappedArray[Long] = new WrappedArray.ofLong(repr)
@@ -177,7 +173,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays containing `float`s. */
- class ofFloat(override val repr: Array[Float]) extends ArrayOps[Float] with ArrayLike[Float, Array[Float]] {
+final class ofFloat(override val repr: Array[Float]) extends AnyVal with ArrayOps[Float] with ArrayLike[Float, Array[Float]] {
override protected[this] def thisCollection: WrappedArray[Float] = new WrappedArray.ofFloat(repr)
override protected[this] def toCollection(repr: Array[Float]): WrappedArray[Float] = new WrappedArray.ofFloat(repr)
@@ -189,7 +185,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays containing `double`s. */
- class ofDouble(override val repr: Array[Double]) extends ArrayOps[Double] with ArrayLike[Double, Array[Double]] {
+final class ofDouble(override val repr: Array[Double]) extends AnyVal with ArrayOps[Double] with ArrayLike[Double, Array[Double]] {
override protected[this] def thisCollection: WrappedArray[Double] = new WrappedArray.ofDouble(repr)
override protected[this] def toCollection(repr: Array[Double]): WrappedArray[Double] = new WrappedArray.ofDouble(repr)
@@ -201,7 +197,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays containing `boolean`s. */
- class ofBoolean(override val repr: Array[Boolean]) extends ArrayOps[Boolean] with ArrayLike[Boolean, Array[Boolean]] {
+final class ofBoolean(override val repr: Array[Boolean]) extends AnyVal with ArrayOps[Boolean] with ArrayLike[Boolean, Array[Boolean]] {
override protected[this] def thisCollection: WrappedArray[Boolean] = new WrappedArray.ofBoolean(repr)
override protected[this] def toCollection(repr: Array[Boolean]): WrappedArray[Boolean] = new WrappedArray.ofBoolean(repr)
@@ -213,7 +209,7 @@ object ArrayOps {
}
/** A class of `ArrayOps` for arrays of `Unit` types. */
- class ofUnit(override val repr: Array[Unit]) extends ArrayOps[Unit] with ArrayLike[Unit, Array[Unit]] {
+final class ofUnit(override val repr: Array[Unit]) extends AnyVal with ArrayOps[Unit] with ArrayLike[Unit, Array[Unit]] {
override protected[this] def thisCollection: WrappedArray[Unit] = new WrappedArray.ofUnit(repr)
override protected[this] def toCollection(repr: Array[Unit]): WrappedArray[Unit] = new WrappedArray.ofUnit(repr)
diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala
index cba4e9725e..b7c5f07502 100644
--- a/src/library/scala/collection/mutable/DoubleLinkedList.scala
+++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala
@@ -63,6 +63,13 @@ class DoubleLinkedList[A]() extends AbstractSeq[A]
}
override def companion: GenericCompanion[DoubleLinkedList] = DoubleLinkedList
+
+ // Accurately clone this collection. See SI-6296
+ override def clone(): DoubleLinkedList[A] = {
+ val builder = newBuilder
+ builder ++= this
+ builder.result
+ }
}
/** $factoryInfo
diff --git a/src/library/scala/collection/mutable/IndexedSeqLike.scala b/src/library/scala/collection/mutable/IndexedSeqLike.scala
index 5d4b4de7b2..b3fe95ef27 100644
--- a/src/library/scala/collection/mutable/IndexedSeqLike.scala
+++ b/src/library/scala/collection/mutable/IndexedSeqLike.scala
@@ -36,7 +36,7 @@ import generic._
* @define willNotTerminateInf
* @define mayNotTerminateInf
*/
-trait IndexedSeqLike[A, +Repr] extends scala.collection.IndexedSeqLike[A, Repr] { self =>
+trait IndexedSeqLike[A, +Repr] extends Any with scala.collection.IndexedSeqLike[A, Repr] { self =>
override protected[this] def thisCollection: IndexedSeq[A] = this.asInstanceOf[IndexedSeq[A]]
override protected[this] def toCollection(repr: Repr): IndexedSeq[A] = repr.asInstanceOf[IndexedSeq[A]]
diff --git a/src/library/scala/collection/mutable/IndexedSeqOptimized.scala b/src/library/scala/collection/mutable/IndexedSeqOptimized.scala
index 819d06476a..506d2d6736 100755
--- a/src/library/scala/collection/mutable/IndexedSeqOptimized.scala
+++ b/src/library/scala/collection/mutable/IndexedSeqOptimized.scala
@@ -17,4 +17,4 @@ import generic._
*
* @since 2.8
*/
-trait IndexedSeqOptimized[A, +Repr] extends IndexedSeqLike[A, Repr] with scala.collection.IndexedSeqOptimized[A, Repr]
+trait IndexedSeqOptimized[A, +Repr] extends Any with IndexedSeqLike[A, Repr] with scala.collection.IndexedSeqOptimized[A, Repr]
diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala
index 74daa510ca..8669b2e2e8 100644
--- a/src/library/scala/math/BigDecimal.scala
+++ b/src/library/scala/math/BigDecimal.scala
@@ -211,7 +211,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable {
catch { case _: ArithmeticException => false }
}
- protected[math] def isWhole = (this remainder 1) == BigDecimal(0)
+ def isWhole() = (this remainder 1) == BigDecimal(0)
def underlying = bigDecimal
/** Compares this BigDecimal with the specified BigDecimal for equality.
diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala
index 4471e417d9..09e8ae2026 100644
--- a/src/library/scala/math/BigInt.scala
+++ b/src/library/scala/math/BigInt.scala
@@ -162,7 +162,7 @@ class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericCo
}
/** Some implementations of java.math.BigInteger allow huge values with bit length greater than Int.MaxValue .
* The BigInteger.bitLength method returns truncated bit length in this case .
- * This method tests if result of bitLength is valid.
+ * This method tests if result of bitLength is valid.
* This method will become unnecessary if BigInt constructors reject huge BigIntegers.
*/
private def bitLengthOverflow = {
@@ -170,7 +170,7 @@ class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericCo
(shifted.signum != 0) && !(shifted equals BigInt.minusOne)
}
- protected[math] def isWhole = true
+ def isWhole() = true
def underlying = bigInteger
/** Compares this BigInt with the specified BigInt for equality.
diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala
index 2b7ef7405c..edf243e5df 100644
--- a/src/library/scala/math/ScalaNumericConversions.scala
+++ b/src/library/scala/math/ScalaNumericConversions.scala
@@ -13,7 +13,17 @@ import java.{ lang => jl }
/** Conversions which present a consistent conversion interface
* across all the numeric types.
*/
-trait ScalaNumericConversions extends ScalaNumber {
+trait ScalaNumericConversions extends Any {
+ def isWhole(): Boolean
+ def underlying(): Any
+
+ def byteValue(): Byte = intValue().toByte
+ def shortValue(): Short = intValue().toShort
+ def intValue(): Int
+ def longValue(): Long
+ def floatValue(): Float
+ def doubleValue(): Double
+
/** Returns the value of this as a [[scala.Char]]. This may involve
* rounding or truncation.
*/
diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala
index 7b6df6e31c..5255c44f10 100644
--- a/src/library/scala/reflect/ClassTag.scala
+++ b/src/library/scala/reflect/ClassTag.scala
@@ -64,6 +64,7 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial
}
object ClassTag {
+ private val NothingTYPE = classOf[scala.runtime.Nothing$]
private val NullTYPE = classOf[scala.runtime.Null$]
private val ObjectTYPE = classOf[java.lang.Object]
@@ -80,13 +81,7 @@ object ClassTag {
val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Object }
val AnyVal : ClassTag[scala.AnyVal] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyVal]]
val AnyRef : ClassTag[scala.AnyRef] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyRef]]
- val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{
- def runtimeClass = throw new Exception("Nothing is a bottom type, therefore its erasure does not return a value")
- private def readResolve() = ClassTag.Nothing
- override def equals(x: Any) = x.isInstanceOf[ClassTag[_]] && (x.asInstanceOf[AnyRef] eq ClassTag.Nothing)
- override def hashCode = System.identityHashCode(this)
- override def toString = "ClassTag[Nothing]"
- }
+ val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def runtimeClass = NothingTYPE; private def readResolve() = ClassTag.Nothing }
val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def runtimeClass = NullTYPE; private def readResolve() = ClassTag.Null }
def apply[T](runtimeClass1: jClass[_]): ClassTag[T] =
diff --git a/src/library/scala/reflect/base/Symbols.scala b/src/library/scala/reflect/base/Symbols.scala
index 294fa19d62..3830264425 100644
--- a/src/library/scala/reflect/base/Symbols.scala
+++ b/src/library/scala/reflect/base/Symbols.scala
@@ -107,8 +107,8 @@ trait Symbols { self: Universe =>
/** Does this symbol represent the definition of a type?
* Note that every symbol is either a term or a type.
- * So for every symbol `sym`, either `sym.isTerm` is true
- * or `sym.isType` is true.
+ * So for every symbol `sym` (except for `NoSymbol`),
+ * either `sym.isTerm` is true or `sym.isType` is true.
*/
def isType: Boolean = false
@@ -118,9 +118,9 @@ trait Symbols { self: Universe =>
def asType: TypeSymbol = throw new ScalaReflectionException(s"$this is not a type")
/** Does this symbol represent the definition of a term?
- * Note that every symbol is either a term or a term.
- * So for every symbol `sym`, either `sym.isTerm` is true
- * or `sym.isTerm` is true.
+ * Note that every symbol is either a term or a type.
+ * So for every symbol `sym` (except for `NoSymbol`),
+ * either `sym.isTerm` is true or `sym.isTerm` is true.
*/
def isTerm: Boolean = false
@@ -234,10 +234,10 @@ trait Symbols { self: Universe =>
* `PolyType(ClassInfoType(...))` that describes type parameters, value
* parameters, parent types, and members of `C`.
*/
- def toType: Type
+ def toType: Type
- override def isType = true
- override def asType = this
+ final override def isType = true
+ final override def asType = this
}
/** The base API that all term symbols support */
diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala
index c9d1ccf5bc..b7e0c37a4b 100644
--- a/src/library/scala/reflect/base/TypeTags.scala
+++ b/src/library/scala/reflect/base/TypeTags.scala
@@ -250,9 +250,11 @@ trait TypeTags { self: Universe =>
}
// incantations
+ def absTypeTag[T](implicit attag: AbsTypeTag[T]) = attag
def typeTag[T](implicit ttag: TypeTag[T]) = ttag
// big thanks to Viktor Klang for this brilliant idea!
+ def absTypeOf[T](implicit attag: AbsTypeTag[T]): Type = attag.tpe
def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe
}
diff --git a/src/library/scala/runtime/AbstractPartialFunction.scala b/src/library/scala/runtime/AbstractPartialFunction.scala
index f499350ce9..c1f245590b 100644
--- a/src/library/scala/runtime/AbstractPartialFunction.scala
+++ b/src/library/scala/runtime/AbstractPartialFunction.scala
@@ -8,7 +8,8 @@
package scala.runtime
-/** `AbstractPartialFunction` reformulates all operations of its supertrait `PartialFunction` in terms of `isDefinedAt` and `applyOrElse`.
+/** `AbstractPartialFunction` reformulates all operations of its supertrait `PartialFunction`
+ * in terms of `isDefinedAt` and `applyOrElse`.
*
* This allows more efficient implementations in many cases:
* - optimized `orElse` method supports chained `orElse` in linear time,
@@ -16,12 +17,7 @@ package scala.runtime
* - optimized `lift` method helps to avoid double evaluation of pattern matchers & guards
* of partial function literals.
*
- * This trait is used as a basis for implementation of all partial function literals
- * with non-exhaustive matchers.
- *
- * Use of `AbstractPartialFunction` instead of `PartialFunction` as a base trait for
- * user-defined partial functions may result in better performance
- * and more predictable behavior w.r.t. side effects.
+ * This trait is used as a basis for implementation of all partial function literals.
*
* @author Pavel Pavlov
* @since 2.10
@@ -35,34 +31,4 @@ abstract class AbstractPartialFunction[@specialized(scala.Int, scala.Long, scala
// probably okay to make final since classes compiled before have overridden against the old version of AbstractPartialFunction
// let's not make it final so as not to confuse anyone
/*final*/ def apply(x: T1): R = applyOrElse(x, PartialFunction.empty)
-
- @annotation.unspecialized override final def andThen[C](k: R => C) : PartialFunction[T1, C] =
- new AbstractPartialFunction[T1, C] {
- def isDefinedAt(x: T1): Boolean = self.isDefinedAt(x)
- override def applyOrElse[A1 <: T1, C1 >: C](x: A1, default: A1 => C1): C1 =
- self.applyOrElse(x, PartialFunction.fallbackToken) match {
- case PartialFunction.FallbackToken => default(x)
- case z => k(z)
- }
- }
-
- // TODO: remove
- protected def missingCase(x: T1): R = throw new MatchError(x)
-}
-
-
-/** `AbstractTotalFunction` is a partial function whose `isDefinedAt` method always returns `true`.
- *
- * This class is used as base class for partial function literals with
- * certainly exhaustive pattern matchers.
- *
- * @author Pavel Pavlov
- * @since 2.10
- */
-abstract class AbstractTotalFunction[@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) +R] extends Function1[T1, R] with PartialFunction[T1, R] {
- final def isDefinedAt(x: T1): Boolean = true
- @annotation.unspecialized override final def applyOrElse[A1 <: T1, B1 >: R](x: A1, default: A1 => B1): B1 = apply(x)
- @annotation.unspecialized override final def orElse[A1 <: T1, B1 >: R](that: PartialFunction[A1, B1]): PartialFunction[A1, B1] = this
- //TODO: check generated code for PF literal here
- @annotation.unspecialized override final def andThen[C](k: R => C): PartialFunction[T1, C] = { case x => k(apply(x)) }
}
diff --git a/src/library/scala/runtime/RichBoolean.scala b/src/library/scala/runtime/RichBoolean.scala
index a14160a71e..92cc6ccf98 100644
--- a/src/library/scala/runtime/RichBoolean.scala
+++ b/src/library/scala/runtime/RichBoolean.scala
@@ -8,6 +8,6 @@
package scala.runtime
-final class RichBoolean(val self: Boolean) extends OrderedProxy[Boolean] {
- protected val ord = math.Ordering[Boolean]
+final class RichBoolean(val self: Boolean) extends AnyVal with OrderedProxy[Boolean] {
+ protected def ord = scala.math.Ordering.Boolean
}
diff --git a/src/library/scala/runtime/RichByte.scala b/src/library/scala/runtime/RichByte.scala
index c42a2dd183..9d88ed3689 100644
--- a/src/library/scala/runtime/RichByte.scala
+++ b/src/library/scala/runtime/RichByte.scala
@@ -8,4 +8,7 @@
package scala.runtime
-final class RichByte(val self: Byte) extends ScalaWholeNumberProxy[Byte] { }
+final class RichByte(val self: Byte) extends AnyVal with ScalaWholeNumberProxy[Byte] {
+ protected def num = scala.math.Numeric.ByteIsIntegral
+ protected def ord = scala.math.Ordering.Byte
+}
diff --git a/src/library/scala/runtime/RichChar.scala b/src/library/scala/runtime/RichChar.scala
index ba939d6633..918fe70f5c 100644
--- a/src/library/scala/runtime/RichChar.scala
+++ b/src/library/scala/runtime/RichChar.scala
@@ -10,7 +10,10 @@ package scala.runtime
import java.lang.Character
-final class RichChar(val self: Char) extends IntegralProxy[Char] {
+final class RichChar(val self: Char) extends AnyVal with IntegralProxy[Char] {
+ protected def num = scala.math.Numeric.CharIsIntegral
+ protected def ord = scala.math.Ordering.Char
+
def asDigit: Int = Character.digit(self, Character.MAX_RADIX)
def isControl: Boolean = Character.isISOControl(self)
diff --git a/src/library/scala/runtime/RichDouble.scala b/src/library/scala/runtime/RichDouble.scala
index 396323d1e8..19396a3d48 100644
--- a/src/library/scala/runtime/RichDouble.scala
+++ b/src/library/scala/runtime/RichDouble.scala
@@ -8,8 +8,10 @@
package scala.runtime
-final class RichDouble(val self: Double) extends FractionalProxy[Double] {
- protected val integralNum = Numeric.DoubleAsIfIntegral
+final class RichDouble(val self: Double) extends AnyVal with FractionalProxy[Double] {
+ protected def num = scala.math.Numeric.DoubleIsFractional
+ protected def ord = scala.math.Ordering.Double
+ protected def integralNum = scala.math.Numeric.DoubleAsIfIntegral
def round: Long = math.round(self)
def ceil: Double = math.ceil(self)
diff --git a/src/library/scala/runtime/RichFloat.scala b/src/library/scala/runtime/RichFloat.scala
index 4fc9e8864a..9fbb3c19bb 100644
--- a/src/library/scala/runtime/RichFloat.scala
+++ b/src/library/scala/runtime/RichFloat.scala
@@ -8,8 +8,10 @@
package scala.runtime
-final class RichFloat(val self: Float) extends FractionalProxy[Float] {
- protected val integralNum = Numeric.FloatAsIfIntegral
+final class RichFloat(val self: Float) extends AnyVal with FractionalProxy[Float] {
+ protected def num = scala.math.Numeric.FloatIsFractional
+ protected def ord = scala.math.Ordering.Float
+ protected def integralNum = scala.math.Numeric.FloatAsIfIntegral
def round: Int = math.round(self)
def ceil: Float = math.ceil(self).toFloat
diff --git a/src/library/scala/runtime/RichInt.scala b/src/library/scala/runtime/RichInt.scala
index d03968212f..619574264a 100644
--- a/src/library/scala/runtime/RichInt.scala
+++ b/src/library/scala/runtime/RichInt.scala
@@ -12,7 +12,9 @@ import scala.collection.immutable.Range
// Note that this does not implement IntegralProxy[Int] so that it can return
// the Int-specific Range class from until/to.
-final class RichInt(val self: Int) extends ScalaNumberProxy[Int] with RangedProxy[Int] {
+final class RichInt(val self: Int) extends AnyVal with ScalaNumberProxy[Int] with RangedProxy[Int] {
+ protected def num = scala.math.Numeric.IntIsIntegral
+ protected def ord = scala.math.Ordering.Int
type ResultWithoutStep = Range
/**
diff --git a/src/library/scala/runtime/RichLong.scala b/src/library/scala/runtime/RichLong.scala
index 5784934ffd..7c052851a9 100644
--- a/src/library/scala/runtime/RichLong.scala
+++ b/src/library/scala/runtime/RichLong.scala
@@ -8,7 +8,10 @@
package scala.runtime
-final class RichLong(val self: Long) extends IntegralProxy[Long] {
+final class RichLong(val self: Long) extends AnyVal with IntegralProxy[Long] {
+ protected def num = scala.math.Numeric.LongIsIntegral
+ protected def ord = scala.math.Ordering.Long
+
def toBinaryString: String = java.lang.Long.toBinaryString(self)
def toHexString: String = java.lang.Long.toHexString(self)
def toOctalString: String = java.lang.Long.toOctalString(self)
diff --git a/src/library/scala/runtime/RichShort.scala b/src/library/scala/runtime/RichShort.scala
index a174438c06..4dfa237b38 100644
--- a/src/library/scala/runtime/RichShort.scala
+++ b/src/library/scala/runtime/RichShort.scala
@@ -8,4 +8,7 @@
package scala.runtime
-final class RichShort(val self: Short) extends ScalaWholeNumberProxy[Short] { }
+final class RichShort(val self: Short) extends AnyVal with ScalaWholeNumberProxy[Short] {
+ protected def num = scala.math.Numeric.ShortIsIntegral
+ protected def ord = scala.math.Ordering.Short
+}
diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala
index d9b9a7843f..64df4611e3 100644
--- a/src/library/scala/runtime/ScalaNumberProxy.scala
+++ b/src/library/scala/runtime/ScalaNumberProxy.scala
@@ -20,9 +20,8 @@ import Proxy.Typed
* @version 2.9
* @since 2.9
*/
-abstract class ScalaNumberProxy[T: Numeric] extends ScalaNumericConversions with Typed[T] with OrderedProxy[T] {
- private val num = implicitly[Numeric[T]]
- protected val ord: Ordering[T] = num
+trait ScalaNumberProxy[T] extends Any with ScalaNumericConversions with Typed[T] with OrderedProxy[T] {
+ protected implicit def num: Numeric[T]
def underlying() = self.asInstanceOf[AnyRef]
def doubleValue() = num.toDouble(self)
@@ -35,11 +34,11 @@ abstract class ScalaNumberProxy[T: Numeric] extends ScalaNumericConversions with
def abs = num.abs(self)
def signum = num.signum(self)
}
-abstract class ScalaWholeNumberProxy[T: Numeric] extends ScalaNumberProxy[T] {
+trait ScalaWholeNumberProxy[T] extends Any with ScalaNumberProxy[T] {
def isWhole() = true
}
-abstract class IntegralProxy[T : Integral] extends ScalaWholeNumberProxy[T] with RangedProxy[T] {
- private lazy val num = implicitly[Integral[T]]
+trait IntegralProxy[T] extends Any with ScalaWholeNumberProxy[T] with RangedProxy[T] {
+ protected implicit def num: Integral[T]
type ResultWithoutStep = NumericRange[T]
def until(end: T): NumericRange.Exclusive[T] = NumericRange(self, end, num.one)
@@ -47,17 +46,17 @@ abstract class IntegralProxy[T : Integral] extends ScalaWholeNumberProxy[T] with
def to(end: T): NumericRange.Inclusive[T] = NumericRange.inclusive(self, end, num.one)
def to(end: T, step: T): NumericRange.Inclusive[T] = NumericRange.inclusive(self, end, step)
}
-abstract class FractionalProxy[T : Fractional] extends ScalaNumberProxy[T] with RangedProxy[T] {
- def isWhole() = false
+trait FractionalProxy[T] extends Any with ScalaNumberProxy[T] with RangedProxy[T] {
+ protected implicit def num: Fractional[T]
+ protected implicit def integralNum: Integral[T]
/** In order to supply predictable ranges, we require an Integral[T] which provides
* us with discrete operations on the (otherwise fractional) T. See Numeric.DoubleAsIfIntegral
* for an example.
*/
- protected implicit def integralNum: Integral[T]
- private lazy val num = implicitly[Fractional[T]]
type ResultWithoutStep = Range.Partial[T, NumericRange[T]]
+ def isWhole() = false
def until(end: T): ResultWithoutStep = new Range.Partial(NumericRange(self, end, _))
def until(end: T, step: T): NumericRange.Exclusive[T] = NumericRange(self, end, step)
def to(end: T): ResultWithoutStep = new Range.Partial(NumericRange.inclusive(self, end, _))
diff --git a/src/library/scala/runtime/StringAdd.scala b/src/library/scala/runtime/StringAdd.scala
index a7e78ea9a3..4693b0bf44 100644
--- a/src/library/scala/runtime/StringAdd.scala
+++ b/src/library/scala/runtime/StringAdd.scala
@@ -9,14 +9,11 @@
package scala.runtime
/** A wrapper class that adds string concatenation `+` to any value */
-final class StringAdd(val self: Any) {
-
+final class StringAdd(val self: Any) extends AnyVal {
// Note: The implicit conversion from Any to StringAdd is one of two
// implicit conversions from Any to AnyRef in Predef. It is important to have at least
// two such conversions, so that silent conversions from value types to AnyRef
// are avoided. If StringFormat should become a value class, another
// implicit conversion from Any to AnyRef has to be introduced in Predef
-
def +(other: String) = String.valueOf(self) + other
-
}
diff --git a/src/library/scala/runtime/StringFormat.scala b/src/library/scala/runtime/StringFormat.scala
index c120cbb14d..1f5feec9e1 100644
--- a/src/library/scala/runtime/StringFormat.scala
+++ b/src/library/scala/runtime/StringFormat.scala
@@ -10,8 +10,7 @@ package scala.runtime
/** A wrapper class that adds a `formatted` operation to any value
*/
-final class StringFormat(val self: Any) {
-
+final class StringFormat(val self: Any) extends AnyVal {
// Note: The implicit conversion from Any to StringFormat is one of two
// implicit conversions from Any to AnyRef in Predef. It is important to have at least
// two such conversions, so that silent conversions from value types to AnyRef
@@ -23,5 +22,4 @@ final class StringFormat(val self: Any) {
* (@see java.lang.String.format).
*/
@inline def formatted(fmtstr: String): String = fmtstr format self
-
}
diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala
index dce7eef08d..182fd77133 100644
--- a/src/library/scala/runtime/Tuple2Zipped.scala
+++ b/src/library/scala/runtime/Tuple2Zipped.scala
@@ -16,7 +16,7 @@ import language.{ higherKinds, implicitConversions }
* by the requirement to resolve type constructors, for implicit search (which only
* needs to find an implicit conversion to Traversable for our purposes.)
*/
-trait ZippedTraversable2[+El1, +El2] {
+trait ZippedTraversable2[+El1, +El2] extends Any {
def foreach[U](f: (El1, El2) => U): Unit
}
object ZippedTraversable2 {
@@ -27,16 +27,15 @@ object ZippedTraversable2 {
}
}
-class Tuple2Zipped[El1, Repr1, El2, Repr2](
- coll1: TraversableLike[El1, Repr1],
- coll2: IterableLike[El2, Repr2]
-) extends ZippedTraversable2[El1, El2] {
+final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1, Repr1], IterableLike[El2, Repr2])) extends AnyVal with ZippedTraversable2[El1, El2] {
+ // This would be better as "private def coll1 = colls._1" but
+ // SI-6215 precludes private methods in value classes.
def map[B, To](f: (El1, El2) => B)(implicit cbf: CBF[Repr1, B, To]): To = {
- val b = cbf(coll1.repr)
- b.sizeHint(coll1)
- val elems2 = coll2.iterator
+ val b = cbf(colls._1.repr)
+ b.sizeHint(colls._1)
+ val elems2 = colls._2.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext)
b += f(el1, elems2.next)
else
@@ -47,10 +46,10 @@ class Tuple2Zipped[El1, Repr1, El2, Repr2](
}
def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = {
- val b = cbf(coll1.repr)
- val elems2 = coll2.iterator
+ val b = cbf(colls._1.repr)
+ val elems2 = colls._2.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext)
b ++= f(el1, elems2.next)
else
@@ -61,11 +60,11 @@ class Tuple2Zipped[El1, Repr1, El2, Repr2](
}
def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = {
- val b1 = cbf1(coll1.repr)
- val b2 = cbf2(coll2.repr)
- val elems2 = coll2.iterator
+ val b1 = cbf1(colls._1.repr)
+ val b2 = cbf2(colls._2.repr)
+ val elems2 = colls._2.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext) {
val el2 = elems2.next
if (f(el1, el2)) {
@@ -80,9 +79,9 @@ class Tuple2Zipped[El1, Repr1, El2, Repr2](
}
def exists(f: (El1, El2) => Boolean): Boolean = {
- val elems2 = coll2.iterator
+ val elems2 = colls._2.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext) {
if (f(el1, elems2.next))
return true
@@ -96,9 +95,9 @@ class Tuple2Zipped[El1, Repr1, El2, Repr2](
!exists((x, y) => !f(x, y))
def foreach[U](f: (El1, El2) => U): Unit = {
- val elems2 = coll2.iterator
+ val elems2 = colls._2.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext)
f(el1, elems2.next)
else
@@ -108,7 +107,7 @@ class Tuple2Zipped[El1, Repr1, El2, Repr2](
}
object Tuple2Zipped {
- class Ops[T1, T2](x: (T1, T2)) {
+ final class Ops[T1, T2](val x: (T1, T2)) extends AnyVal {
def invert[El1, CC1[X] <: TraversableOnce[X], El2, CC2[X] <: TraversableOnce[X], That]
(implicit w1: T1 <:< CC1[El1],
w2: T2 <:< CC2[El2],
@@ -119,13 +118,13 @@ object Tuple2Zipped {
val it2 = x._2.toIterator
while (it1.hasNext && it2.hasNext)
buf += ((it1.next, it2.next))
-
+
buf.result
}
def zipped[El1, Repr1, El2, Repr2]
(implicit w1: T1 => TraversableLike[El1, Repr1],
w2: T2 => IterableLike[El2, Repr2]
- ): Tuple2Zipped[El1, Repr1, El2, Repr2] = new Tuple2Zipped(x._1, x._2)
+ ): Tuple2Zipped[El1, Repr1, El2, Repr2] = new Tuple2Zipped((x._1, x._2))
}
}
diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala
index f3ca08649d..f6aafe41fb 100644
--- a/src/library/scala/runtime/Tuple3Zipped.scala
+++ b/src/library/scala/runtime/Tuple3Zipped.scala
@@ -13,7 +13,7 @@ import scala.collection.generic.{ CanBuildFrom => CBF }
import language.{ higherKinds, implicitConversions }
/** See comment on ZippedTraversable2. */
-trait ZippedTraversable3[+El1, +El2, +El3] {
+trait ZippedTraversable3[+El1, +El2, +El3] extends Any {
def foreach[U](f: (El1, El2, El3) => U): Unit
}
object ZippedTraversable3 {
@@ -24,17 +24,15 @@ object ZippedTraversable3 {
}
}
-class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](
- coll1: TraversableLike[El1, Repr1],
- coll2: IterableLike[El2, Repr2],
- coll3: IterableLike[El3, Repr3]
-) extends ZippedTraversable3[El1, El2, El3] {
+final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (TraversableLike[El1, Repr1], IterableLike[El2, Repr2], IterableLike[El3, Repr3]))
+ extends AnyVal with ZippedTraversable3[El1, El2, El3] {
+
def map[B, To](f: (El1, El2, El3) => B)(implicit cbf: CBF[Repr1, B, To]): To = {
- val b = cbf(coll1.repr)
- val elems2 = coll2.iterator
- val elems3 = coll3.iterator
+ val b = cbf(colls._1.repr)
+ val elems2 = colls._2.iterator
+ val elems3 = colls._3.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext)
b += f(el1, elems2.next, elems3.next)
else
@@ -44,11 +42,11 @@ class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](
}
def flatMap[B, To](f: (El1, El2, El3) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = {
- val b = cbf(coll1.repr)
- val elems2 = coll2.iterator
- val elems3 = coll3.iterator
+ val b = cbf(colls._1.repr)
+ val elems2 = colls._2.iterator
+ val elems3 = colls._3.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext)
b ++= f(el1, elems2.next, elems3.next)
else
@@ -61,14 +59,14 @@ class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](
implicit cbf1: CBF[Repr1, El1, To1],
cbf2: CBF[Repr2, El2, To2],
cbf3: CBF[Repr3, El3, To3]): (To1, To2, To3) = {
- val b1 = cbf1(coll1.repr)
- val b2 = cbf2(coll2.repr)
- val b3 = cbf3(coll3.repr)
- val elems2 = coll2.iterator
- val elems3 = coll3.iterator
+ val b1 = cbf1(colls._1.repr)
+ val b2 = cbf2(colls._2.repr)
+ val b3 = cbf3(colls._3.repr)
+ val elems2 = colls._2.iterator
+ val elems3 = colls._3.iterator
def result = (b1.result, b2.result, b3.result)
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext) {
val el2 = elems2.next
val el3 = elems3.next
@@ -86,10 +84,10 @@ class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](
}
def exists(f: (El1, El2, El3) => Boolean): Boolean = {
- val elems2 = coll2.iterator
- val elems3 = coll3.iterator
+ val elems2 = colls._2.iterator
+ val elems3 = colls._3.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext) {
if (f(el1, elems2.next, elems3.next))
return true
@@ -103,10 +101,10 @@ class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](
!exists((x, y, z) => !f(x, y, z))
def foreach[U](f: (El1, El2, El3) => U): Unit = {
- val elems2 = coll2.iterator
- val elems3 = coll3.iterator
+ val elems2 = colls._2.iterator
+ val elems3 = colls._3.iterator
- for (el1 <- coll1) {
+ for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext)
f(el1, elems2.next, elems3.next)
else
@@ -116,7 +114,7 @@ class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](
}
object Tuple3Zipped {
- class Ops[T1, T2, T3](x: (T1, T2, T3)) {
+ final class Ops[T1, T2, T3](val x: (T1, T2, T3)) extends AnyVal {
def invert[El1, CC1[X] <: TraversableOnce[X], El2, CC2[X] <: TraversableOnce[X], El3, CC3[X] <: TraversableOnce[X], That]
(implicit w1: T1 <:< CC1[El1],
w2: T2 <:< CC2[El2],
@@ -129,14 +127,14 @@ object Tuple3Zipped {
val it3 = x._3.toIterator
while (it1.hasNext && it2.hasNext && it3.hasNext)
buf += ((it1.next, it2.next, it3.next))
-
+
buf.result
}
-
+
def zipped[El1, Repr1, El2, Repr2, El3, Repr3]
(implicit w1: T1 => TraversableLike[El1, Repr1],
w2: T2 => IterableLike[El2, Repr2],
w3: T3 => IterableLike[El3, Repr3]
- ): Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3] = new Tuple3Zipped(x._1, x._2, x._3)
+ ): Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3] = new Tuple3Zipped((x._1, x._2, x._3))
}
}
diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala
index 4a5209ecab..1567e06c22 100644
--- a/src/library/scala/util/control/Exception.scala
+++ b/src/library/scala/util/control/Exception.scala
@@ -145,7 +145,7 @@ object Exception {
}
final val nothingCatcher: Catcher[Nothing] = mkThrowableCatcher(_ => false, throw _)
- final def nonFatalCatcher[T]: Catcher[T] = mkThrowableCatcher({ case NonFatal(_) => false; case _ => true }, throw _)
+ final def nonFatalCatcher[T]: Catcher[T] = mkThrowableCatcher({ case NonFatal(_) => true; case _ => false }, throw _)
final def allCatcher[T]: Catcher[T] = mkThrowableCatcher(_ => true, throw _)
/** The empty `Catch` object. */
diff --git a/src/reflect/scala/reflect/api/FlagSets.scala b/src/reflect/scala/reflect/api/FlagSets.scala
index 36836e84a9..fdd43f1883 100644
--- a/src/reflect/scala/reflect/api/FlagSets.scala
+++ b/src/reflect/scala/reflect/api/FlagSets.scala
@@ -3,7 +3,7 @@ package api
import scala.language.implicitConversions
-trait FlagSets { self: Universe =>
+trait FlagSets extends base.FlagSets { self: Universe =>
type FlagSet
diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala
index 7d185d9879..8c4c423221 100644
--- a/src/reflect/scala/reflect/api/Mirrors.scala
+++ b/src/reflect/scala/reflect/api/Mirrors.scala
@@ -1,7 +1,7 @@
package scala.reflect
package api
-trait Mirrors { self: Universe =>
+trait Mirrors extends base.Mirrors { self: Universe =>
type RuntimeClass >: Null
diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala
index 9e7b3c9712..b17377795b 100644
--- a/src/reflect/scala/reflect/api/Symbols.scala
+++ b/src/reflect/scala/reflect/api/Symbols.scala
@@ -59,6 +59,9 @@ trait Symbols extends base.Symbols { self: Universe =>
*/
def typeSignature: Type
+ /** Returns all symbols overriden by this symbol. */
+ def allOverriddenSymbols: List[Symbol]
+
/******************* tests *******************/
/** Does this symbol represent a synthetic (i.e. a compiler-generated) entity?
@@ -197,9 +200,6 @@ trait Symbols extends base.Symbols { self: Universe =>
/** ...
*/
def suchThat(cond: Symbol => Boolean): Symbol
-
- /** The string discriminator of this symbol; useful for debugging */
- def kind: String
}
/** The API of term symbols */
diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala
index ebaedd7ac3..f22f8d3e75 100644
--- a/src/reflect/scala/reflect/api/Types.scala
+++ b/src/reflect/scala/reflect/api/Types.scala
@@ -66,6 +66,10 @@ trait Types extends base.Types { self: Universe =>
/** Does this type conform to given type argument `that`? */
def <:< (that: Type): Boolean
+ /** Is this type a weak subtype of that type? True also for numeric types, i.e. Int weak_<:< Long.
+ */
+ def weak_<:<(that: Type): Boolean
+
/** Is this type equivalent to given type argument `that`? */
def =:= (that: Type): Boolean
@@ -155,9 +159,6 @@ trait Types extends base.Types { self: Universe =>
/** Does this type contain a reference to given symbol? */
def contains(sym: Symbol): Boolean
-
- /** The string discriminator of this type; useful for debugging */
- def kind: String
}
/** .. */
diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala
index d5baad8ab1..4b3eb0cdc4 100644
--- a/src/reflect/scala/reflect/internal/Importers.scala
+++ b/src/reflect/scala/reflect/internal/Importers.scala
@@ -3,7 +3,7 @@ package internal
import scala.collection.mutable.WeakHashMap
// SI-6241: move importers to a mirror
-trait Importers { self: SymbolTable =>
+trait Importers extends api.Importers { self: SymbolTable =>
def mkImporter(from0: api.Universe): Importer { val from: from0.type } = (
if (self eq from0) {
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index fce057b21a..70de86a453 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -63,7 +63,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
abstract class SymbolContextApiImpl extends SymbolContextApi {
this: Symbol =>
- def kind: String = kindString
def isExistential: Boolean = this.isExistentiallyBound
def isParamWithDefault: Boolean = this.hasDefault
def isByNameParam: Boolean = this.isValueParameter && (this hasFlag BYNAMEPARAM)
diff --git a/src/reflect/scala/reflect/macros/Aliases.scala b/src/reflect/scala/reflect/macros/Aliases.scala
index 46b7066902..ad100d7e89 100644
--- a/src/reflect/scala/reflect/macros/Aliases.scala
+++ b/src/reflect/scala/reflect/macros/Aliases.scala
@@ -21,6 +21,8 @@ trait Aliases {
type TypeTag[T] = universe.TypeTag[T]
val AbsTypeTag = universe.AbsTypeTag
val TypeTag = universe.TypeTag
+ def absTypeTag[T](implicit attag: AbsTypeTag[T]) = attag
def typeTag[T](implicit ttag: TypeTag[T]) = ttag
+ def absTypeOf[T](implicit attag: AbsTypeTag[T]): Type = attag.tpe
def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe
}
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
index 967ac69148..9f2c3fc79c 100644
--- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala
+++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
@@ -124,7 +124,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym
private def ErrorInnerModule(wannabe: Symbol) = throw new ScalaReflectionException(s"$wannabe is an inner module, use reflectModule on an InstanceMirror to obtain its ModuleMirror")
private def ErrorStaticClass(wannabe: Symbol) = throw new ScalaReflectionException(s"$wannabe is a static class, use reflectClass on a RuntimeMirror to obtain its ClassMirror")
private def ErrorStaticModule(wannabe: Symbol) = throw new ScalaReflectionException(s"$wannabe is a static module, use reflectModule on a RuntimeMirror to obtain its ModuleMirror")
- private def ErrorNotMember(wannabe: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a member of $owner, you provided ${wannabe.kind} ${wannabe.fullName}")
+ private def ErrorNotMember(wannabe: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a member of $owner, you provided ${wannabe.kindString} ${wannabe.fullName}")
private def ErrorNotField(wannabe: Symbol) = throw new ScalaReflectionException(s"expected a field or an accessor method symbol, you provided $wannabe")
private def ErrorNonExistentField(wannabe: Symbol) = throw new ScalaReflectionException(s"""
|Scala field ${wannabe.name} isn't represented as a Java field, neither it has a Java accessor method
diff --git a/test/files/jvm/future-spec/TryTests.scala b/test/files/jvm/future-spec/TryTests.scala
index 82ca12276f..5d1b9b84b4 100644
--- a/test/files/jvm/future-spec/TryTests.scala
+++ b/test/files/jvm/future-spec/TryTests.scala
@@ -46,6 +46,12 @@ object TryTests extends MinimalScalaTest {
val e2 = new Exception
Failure[Int](e) map(_ => throw e2) mustEqual Failure(e)
}
+ "when there is a fatal exception" in {
+ val e3 = new ThreadDeath
+ intercept[ThreadDeath] {
+ Success(1) map (_ => throw e3)
+ }
+ }
}
"flatMap" in {
@@ -60,6 +66,12 @@ object TryTests extends MinimalScalaTest {
val e2 = new Exception
Failure[Int](e).flatMap[Int](_ => throw e2) mustEqual Failure(e)
}
+ "when there is a fatal exception" in {
+ val e3 = new ThreadDeath
+ intercept[ThreadDeath] {
+ Success(1).flatMap[Int](_ => throw e3)
+ }
+ }
}
"flatten" in {
@@ -115,4 +127,4 @@ object TryTests extends MinimalScalaTest {
}
}
}
-} \ No newline at end of file
+}
diff --git a/test/files/jvm/manifests-new.scala b/test/files/jvm/manifests-new.scala
index 8706881640..f730be67bb 100644
--- a/test/files/jvm/manifests-new.scala
+++ b/test/files/jvm/manifests-new.scala
@@ -106,6 +106,6 @@ trait TestUtil {
// val t1: TypeTag[T] = read(write(t))
val t1: TypeTag[T] = t
val x1 = x.toString.replaceAll("@[0-9a-z]+$", "")
- println("x="+x1+", t="+t1+", k="+t1.tpe.kind+", s="+t1.tpe.typeSymbol.toString)
+ println("x="+x1+", t="+t1+", k="+t1.tpe.asInstanceOf[Product].productPrefix+", s="+t1.tpe.typeSymbol.toString)
}
} \ No newline at end of file
diff --git a/test/files/neg/implicit-shadow.check b/test/files/neg/implicit-shadow.check
new file mode 100644
index 0000000000..042fca867a
--- /dev/null
+++ b/test/files/neg/implicit-shadow.check
@@ -0,0 +1,11 @@
+implicit-shadow.scala:4: <i2s: error> is not a valid implicit value for Int(1) => ?{def isEmpty: ?} because:
+reference to i2s is ambiguous;
+it is imported twice in the same scope by
+import C._
+and import B._
+ 1.isEmpty
+ ^
+implicit-shadow.scala:4: error: value isEmpty is not a member of Int
+ 1.isEmpty
+ ^
+one error found
diff --git a/test/files/neg/implicit-shadow.flags b/test/files/neg/implicit-shadow.flags
new file mode 100644
index 0000000000..44842a9d65
--- /dev/null
+++ b/test/files/neg/implicit-shadow.flags
@@ -0,0 +1 @@
+-Xlog-implicits
diff --git a/test/files/neg/implicit-shadow.scala b/test/files/neg/implicit-shadow.scala
new file mode 100644
index 0000000000..ffd34b6408
--- /dev/null
+++ b/test/files/neg/implicit-shadow.scala
@@ -0,0 +1,13 @@
+object Test {
+ import B._, C._
+
+ 1.isEmpty
+}
+
+trait A {
+ implicit def i2s(i: Int): String = ""
+}
+
+object B extends A
+
+object C extends A \ No newline at end of file
diff --git a/test/files/neg/javaConversions-2.10-ambiguity.check b/test/files/neg/javaConversions-2.10-ambiguity.check
new file mode 100644
index 0000000000..c064a22964
--- /dev/null
+++ b/test/files/neg/javaConversions-2.10-ambiguity.check
@@ -0,0 +1,6 @@
+javaConversions-2.10-ambiguity.scala:8: error: type mismatch;
+ found : scala.collection.concurrent.Map[String,String]
+ required: scala.collection.mutable.ConcurrentMap[String,String]
+ assertType[mutable.ConcurrentMap[String, String]](a)
+ ^
+one error found
diff --git a/test/files/neg/javaConversions-2.10-ambiguity.scala b/test/files/neg/javaConversions-2.10-ambiguity.scala
new file mode 100644
index 0000000000..e856846a29
--- /dev/null
+++ b/test/files/neg/javaConversions-2.10-ambiguity.scala
@@ -0,0 +1,10 @@
+import collection.{JavaConversions, mutable, concurrent}
+import JavaConversions._
+import java.util.concurrent.{ConcurrentHashMap => CHM}
+
+object Bar {
+ def assertType[T](t: T) = t
+ val a = new CHM[String, String]() += (("", ""))
+ assertType[mutable.ConcurrentMap[String, String]](a)
+}
+// vim: set et:
diff --git a/test/files/neg/t6227.check b/test/files/neg/t6227.check
new file mode 100644
index 0000000000..5e3c636712
--- /dev/null
+++ b/test/files/neg/t6227.check
@@ -0,0 +1,4 @@
+t6227.scala:2: error: illegal combination of modifiers: implicit and case for: class IntOps
+ implicit case class IntOps( i: Int ) {
+ ^
+one error found
diff --git a/test/files/neg/t6227.scala b/test/files/neg/t6227.scala
new file mode 100644
index 0000000000..46416839d1
--- /dev/null
+++ b/test/files/neg/t6227.scala
@@ -0,0 +1,6 @@
+object Test {
+ implicit case class IntOps( i: Int ) {
+ def twice = i * 2
+ }
+}
+
diff --git a/test/files/neg/t6264.check b/test/files/neg/t6264.check
new file mode 100644
index 0000000000..c0975a80b2
--- /dev/null
+++ b/test/files/neg/t6264.check
@@ -0,0 +1,6 @@
+t6264.scala:3: warning: non-variable type argument Tuple1[_] in type Tuple2[_, Tuple1[_]] is unchecked since it is eliminated by erasure
+ x.isInstanceOf[Tuple2[_, Tuple1[_]]]
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+one warning found
+one error found
diff --git a/test/files/neg/t6264.flags b/test/files/neg/t6264.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/t6264.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/t6264.scala b/test/files/neg/t6264.scala
new file mode 100644
index 0000000000..dc3b727934
--- /dev/null
+++ b/test/files/neg/t6264.scala
@@ -0,0 +1,6 @@
+class Foo {
+ def foo(x: AnyRef): Unit = {
+ x.isInstanceOf[Tuple2[_, Tuple1[_]]]
+ ()
+ }
+}
diff --git a/test/files/neg/t6283.check b/test/files/neg/t6283.check
new file mode 100644
index 0000000000..69e417ee93
--- /dev/null
+++ b/test/files/neg/t6283.check
@@ -0,0 +1,4 @@
+t6283.scala:1: error: `abstract' modifier cannot be used with value classes
+abstract class Funky(val i: Int) extends AnyVal
+ ^
+one error found
diff --git a/test/files/neg/t6283.scala b/test/files/neg/t6283.scala
new file mode 100644
index 0000000000..d41eb18a74
--- /dev/null
+++ b/test/files/neg/t6283.scala
@@ -0,0 +1 @@
+abstract class Funky(val i: Int) extends AnyVal
diff --git a/test/files/neg/t900.check b/test/files/neg/t900.check
index 4611ceba8c..ff5304a135 100644
--- a/test/files/neg/t900.check
+++ b/test/files/neg/t900.check
@@ -1,10 +1,6 @@
t900.scala:4: error: type mismatch;
found : Foo.this.x.type (with underlying type Foo.this.bar)
required: AnyRef
-Note that implicit conversions are not applicable because they are ambiguous:
- both method any2stringfmt in object Predef of type (x: Any)scala.runtime.StringFormat
- and method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd
- are possible conversion functions from Foo.this.x.type to AnyRef
def break(): x.type
^
one error found
diff --git a/test/files/neg/unit2anyref.check b/test/files/neg/unit2anyref.check
index 10fe1861f5..6d11461700 100644
--- a/test/files/neg/unit2anyref.check
+++ b/test/files/neg/unit2anyref.check
@@ -1,8 +1,6 @@
unit2anyref.scala:2: error: type mismatch;
found : Unit
required: AnyRef
-Note: Unit is not implicitly converted to AnyRef. You can safely
-pattern match `x: AnyRef` or cast `x.asInstanceOf[AnyRef]` to do so.
val x: AnyRef = () // this should not succeed.
^
one error found
diff --git a/test/files/pos/javaConversions-2.10-regression.scala b/test/files/pos/javaConversions-2.10-regression.scala
new file mode 100644
index 0000000000..e1b81015ba
--- /dev/null
+++ b/test/files/pos/javaConversions-2.10-regression.scala
@@ -0,0 +1,17 @@
+import collection.{JavaConversions, mutable, concurrent}
+import JavaConversions._
+import java.util.concurrent.{ConcurrentHashMap => CHM}
+
+object Foo {
+ def buildCache2_9_simple[K <: AnyRef, V <: AnyRef]: mutable.ConcurrentMap[K, V] =
+ asScalaConcurrentMap(new CHM())
+
+ def buildCache2_9_implicit[K <: AnyRef, V <: AnyRef]: mutable.ConcurrentMap[K, V] =
+ new CHM[K, V]()
+}
+
+object Bar {
+ def assertType[T](t: T) = t
+ val a = new CHM[String, String]() += (("", ""))
+ assertType[concurrent.Map[String, String]](a)
+}
diff --git a/test/files/pos/t5667.scala b/test/files/pos/t5667.scala
index 513de5b663..353eec93d6 100644
--- a/test/files/pos/t5667.scala
+++ b/test/files/pos/t5667.scala
@@ -1,6 +1,4 @@
object Main {
implicit class C(val s: String) extends AnyVal
implicit class C2(val s: String) extends AnyRef
-
- implicit case class Foo(i: Int)
}
diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check
index 2241108ba0..6519db2178 100644
--- a/test/files/run/classtags_core.check
+++ b/test/files/run/classtags_core.check
@@ -1,30 +1,30 @@
-true
-ClassTag[byte]
-true
-ClassTag[short]
-true
-ClassTag[char]
-true
-ClassTag[int]
-true
-ClassTag[long]
-true
-ClassTag[float]
-true
-ClassTag[double]
-true
-ClassTag[boolean]
-true
-ClassTag[void]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class scala.runtime.Null$]
-true
-ClassTag[Nothing]
+true
+ClassTag[byte]
+true
+ClassTag[short]
+true
+ClassTag[char]
+true
+ClassTag[int]
+true
+ClassTag[long]
+true
+ClassTag[float]
+true
+ClassTag[double]
+true
+ClassTag[boolean]
+true
+ClassTag[void]
+true
+ClassTag[class java.lang.Object]
+true
+ClassTag[class java.lang.Object]
+true
+ClassTag[class java.lang.Object]
+true
+ClassTag[class java.lang.Object]
+true
+ClassTag[class scala.runtime.Null$]
+true
+ClassTag[class scala.runtime.Nothing$]
diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check
index 0d6f694a68..a036d92a24 100644
--- a/test/files/run/existentials3-new.check
+++ b/test/files/run/existentials3-new.check
@@ -1,24 +1,24 @@
-Bar.type, t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
-Bar, t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
+Bar.type, t=TypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
+Bar, t=TypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
Test.ToS, t=RefinedType, s=f3
Test.ToS, t=RefinedType, s=f4
Test.ToS, t=RefinedType, s=f5
() => Test.ToS, t=TypeRef, s=class Function0
() => Test.ToS, t=TypeRef, s=class Function0
-$anon, t=AbstractTypeRef, s= <: B with Test.ToS
-$anon, t=AbstractTypeRef, s= <: B with A with Test.ToS
+$anon, t=TypeRef, s= <: B with Test.ToS
+$anon, t=TypeRef, s= <: B with A with Test.ToS
List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List
List[Seq[Int]], t=TypeRef, s=class List
List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List
-Bar.type, t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
-Bar, t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
+Bar.type, t=TypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
+Bar, t=TypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
Test.ToS, t=RefinedType, s=g3
Test.ToS, t=RefinedType, s=g4
Test.ToS, t=RefinedType, s=g5
() => Test.ToS, t=TypeRef, s=class Function0
() => Test.ToS, t=TypeRef, s=class Function0
-$anon, t=AbstractTypeRef, s= <: B with Test.ToS
-$anon, t=AbstractTypeRef, s= <: B with A with Test.ToS
+$anon, t=TypeRef, s= <: B with Test.ToS
+$anon, t=TypeRef, s= <: B with A with Test.ToS
List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List
List[Seq[Int]], t=TypeRef, s=class List
List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List
diff --git a/test/files/run/existentials3-new.scala b/test/files/run/existentials3-new.scala
index 649fac8327..16735eab4f 100644
--- a/test/files/run/existentials3-new.scala
+++ b/test/files/run/existentials3-new.scala
@@ -35,7 +35,7 @@ object Test {
def printTpe(t: Type) = {
val s = if (t.typeSymbol.isFreeType) t.typeSymbol.typeSignature.toString else t.typeSymbol.toString
- println("%s, t=%s, s=%s".format(t, t.kind, s))
+ println("%s, t=%s, s=%s".format(t, t.asInstanceOf[Product].productPrefix, s))
}
def m[T: TypeTag](x: T) = printTpe(typeOf[T])
def m2[T: AbsTypeTag](x: T) = printTpe(implicitly[AbsTypeTag[T]].tpe)
diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check
index a4c9f215e8..2bc72893e7 100644
--- a/test/files/run/inline-ex-handlers.check
+++ b/test/files/run/inline-ex-handlers.check
@@ -61,22 +61,22 @@
> ? LOAD_LOCAL(variable monitor4)
> 305 MONITOR_EXIT
> ? JUMP 12
-550c557,563
+550c557
< ? THROW(Throwable)
---
> ? JUMP 12
+556c563,570
+< ? THROW(Throwable)
+---
+> ? STORE_LOCAL(value t)
+> ? JUMP 13
>
> 12:
> ? LOAD_LOCAL(variable monitor3)
> 304 MONITOR_EXIT
> ? STORE_LOCAL(value t)
> ? JUMP 13
-556c569,582
-< ? THROW(Throwable)
----
-> ? STORE_LOCAL(value t)
-> ? JUMP 13
->
+571a586,597
> 13:
> 310 LOAD_MODULE object Predef
> 310 CALL_PRIMITIVE(StartConcat)
@@ -88,6 +88,7 @@
> 310 CALL_PRIMITIVE(EndConcat)
> 310 CALL_METHOD scala.Predef.println (dynamic)
> 310 JUMP 2
+>
580c606
< catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6
---
@@ -110,12 +111,12 @@
> 81 LOAD_LOCAL(value e)
> ? STORE_LOCAL(variable exc1)
> ? JUMP 12
-668c700,714
+668c700,701
< 81 THROW(Exception)
---
> ? STORE_LOCAL(variable exc1)
> ? JUMP 12
->
+684a718,730
> 12:
> 83 LOAD_MODULE object Predef
> 83 CONSTANT("finally")
@@ -128,6 +129,7 @@
> 84 STORE_LOCAL(variable result)
> 84 LOAD_LOCAL(variable exc1)
> 84 THROW(Throwable)
+>
690c736
< catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3
---
@@ -171,17 +173,18 @@
---
> ? STORE_LOCAL(value ex6)
> ? JUMP 33
-802c854,861
+802c854,855
< 170 THROW(Throwable)
---
> ? STORE_LOCAL(value ex6)
> ? JUMP 33
->
+811a865,870
> 33:
> 169 LOAD_LOCAL(value ex6)
> 169 STORE_LOCAL(value x4)
> 169 SCOPE_ENTER value x4
> 169 JUMP 5
+>
826,829d884
< 180 LOAD_LOCAL(value x5)
< 180 CALL_METHOD MyException.message (dynamic)
@@ -207,7 +210,7 @@
---
> ? STORE_LOCAL(variable exc2)
> ? JUMP 34
-842a902,914
+857a917,929
> 34:
> 184 LOAD_MODULE object Predef
> 184 CONSTANT("finally")
diff --git a/test/files/run/macro-expand-implicit-argument.check b/test/files/run/macro-expand-implicit-argument.check
new file mode 100644
index 0000000000..fb42345748
--- /dev/null
+++ b/test/files/run/macro-expand-implicit-argument.check
@@ -0,0 +1 @@
+List(1, 2, 3)
diff --git a/test/files/run/macro-expand-implicit-argument.flags b/test/files/run/macro-expand-implicit-argument.flags
new file mode 100644
index 0000000000..cd66464f2f
--- /dev/null
+++ b/test/files/run/macro-expand-implicit-argument.flags
@@ -0,0 +1 @@
+-language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-expand-implicit-argument/Macros_1.scala b/test/files/run/macro-expand-implicit-argument/Macros_1.scala
new file mode 100644
index 0000000000..7629c5a9e2
--- /dev/null
+++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala
@@ -0,0 +1,59 @@
+import annotation.tailrec
+import scala.math.{min, max}
+import scala.{specialized => spec}
+
+import language.experimental.macros
+
+import scala.reflect.{ClassTag, TypeTag}
+import scala.reflect.macros.Context
+
+object Macros {
+ def alloc[@spec A:ClassTag](src:Array[A], s1:Int, len:Int) = {
+ val as = Array.ofDim[A](len)
+ System.arraycopy(src, s1, as, 0, len)
+ as
+ }
+
+ /**
+ * Efficient alternative to Array.apply.
+ *
+ * "As seen on scala-internals!"
+ */
+ def array[A](as:A*)(implicit ct: ClassTag[A]) = macro arrayMacro[A]
+
+ /**
+ * Takes in something like:
+ * ArrayUtil.alloc[Int](11, 22, 33, 44)(ct)
+ *
+ * and builds a tree like:
+ * {
+ * val arr:Array[Int] = ct.newArray(4)
+ * arr.update(0, 11)
+ * arr.update(1, 22)
+ * arr.update(2, 33)
+ * arr.update(3, 44)
+ * arr
+ * }
+ */
+ def arrayMacro[A:c.AbsTypeTag](c:Context)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = {
+ import c.mirror._
+ import c.universe._
+ def const(x:Int) = Literal(Constant(x))
+
+ val n = as.length
+ val arr = newTermName("arr")
+
+ val create = Apply(Select(ct.tree, "newArray"), List(const(n)))
+ val arrtpe = TypeTree(implicitly[c.AbsTypeTag[Array[A]]].tpe)
+ val valdef = ValDef(Modifiers(), arr, arrtpe, create)
+
+ val updates = (0 until n).map {
+ i => Apply(Select(Ident(arr), "update"), List(const(i), as(i).tree))
+ }
+
+ val exprs = Seq(valdef) ++ updates ++ Seq(Ident(arr))
+ val block = Block(exprs:_*)
+
+ c.Expr[Array[A]](block)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macro-expand-implicit-argument/Test_2.scala b/test/files/run/macro-expand-implicit-argument/Test_2.scala
new file mode 100644
index 0000000000..ce8a068fb4
--- /dev/null
+++ b/test/files/run/macro-expand-implicit-argument/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ import Macros._
+ println(array(1, 2, 3).toList)
+} \ No newline at end of file
diff --git a/test/files/run/partialfun.check b/test/files/run/partialfun.check
new file mode 100644
index 0000000000..a317f7b150
--- /dev/null
+++ b/test/files/run/partialfun.check
@@ -0,0 +1,6 @@
+47
+147
+100
+0:isDefinedAt
+1:isDefinedAt
+2:apply
diff --git a/test/files/run/partialfun.scala b/test/files/run/partialfun.scala
new file mode 100644
index 0000000000..4b360750c9
--- /dev/null
+++ b/test/files/run/partialfun.scala
@@ -0,0 +1,86 @@
+import collection._
+import collection.generic._
+
+object Test {
+ def collectIDA[A, B, Repr, That](_this: TraversableLike[A, Repr])(pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
+ val repr: Repr = _this.asInstanceOf[Repr]
+ val b = bf(repr)
+ _this foreach { x => if (pf isDefinedAt x) b += pf(x) }
+ b.result
+ }
+
+ def collectRW[A, B, Repr, That](_this: TraversableLike[A, Repr])(pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
+ val repr: Repr = _this.asInstanceOf[Repr]
+ val b = bf(repr)
+ val f = pf runWith { b += _ }
+ _this foreach f
+ b.result
+ }
+
+ var cnt = 0
+
+ object Ex1 {
+ def unapply(x: Int) : Option[Int] = {
+ cnt += 1
+ if ((x % 3) == 0) Some(-x) else None
+ }
+ }
+
+ object Ex2 {
+ def unapply(x: Int) : Option[Int] = {
+ //cnt += 1
+ if ((x % 5) == 0) Some(x) else None
+ }
+ }
+
+ def resetCnt() = { val r = cnt; cnt = 0; r }
+
+ val pf: PartialFunction[Int,Int] = {
+ case Ex1(result) => result
+ case Ex2(result) => result
+ }
+
+ def collectTest() {
+ val xs = 1 to 100
+ resetCnt()
+
+ val ysIDA = collectIDA(xs)(pf)
+ val cntIDA = resetCnt()
+
+ val ysRW = collectRW(xs)(pf)
+ val cntRW = resetCnt()
+
+ val ys = xs collect pf
+
+ assert(ys == ysIDA)
+ assert(ys == ysRW)
+ assert(cntIDA == xs.length + ys.length)
+ assert(cntRW == xs.length)
+ println(ys.length)
+ println(cntIDA)
+ println(cntRW)
+ }
+
+ def orElseTest() {
+ val pf0 = new PartialFunction[Unit, Unit] {
+ def apply(u: Unit) { println("0:apply") }
+ def isDefinedAt(u: Unit) = { println("0:isDefinedAt"); false }
+ }
+ val pf1 = new PartialFunction[Unit, Unit] {
+ def apply(u: Unit) { println("1:apply") }
+ def isDefinedAt(u: Unit) = { println("1:isDefinedAt"); false }
+ }
+ val pf2 = new PartialFunction[Unit, Unit] {
+ def apply(u: Unit) { println("2:apply") }
+ def isDefinedAt(u: Unit) = { println("2:isDefinedAt"); true }
+ }
+
+ val chained = pf0 orElse pf1 orElse pf2
+ chained()
+ }
+
+ def main(args: Array[String]): Unit = {
+ collectTest()
+ orElseTest()
+ }
+}
diff --git a/test/files/run/reflection-sorted-decls.check b/test/files/run/reflection-sorted-decls.check
index 9a9832a683..02168c4e5f 100644
--- a/test/files/run/reflection-sorted-decls.check
+++ b/test/files/run/reflection-sorted-decls.check
@@ -1,7 +1,3 @@
value a
value b
value c
-method c
-method b
-method a
-constructor Foo$1
diff --git a/test/files/run/reflection-sorted-decls.scala b/test/files/run/reflection-sorted-decls.scala
index 242f17d9bb..5616e10b3b 100644
--- a/test/files/run/reflection-sorted-decls.scala
+++ b/test/files/run/reflection-sorted-decls.scala
@@ -3,6 +3,6 @@ object Test {
class Foo(val a: Int, val b: Int, val c: Int)
import scala.reflect.runtime.{currentMirror => cm}
val decls = cm.classSymbol(classOf[Foo]).typeSignature.declarations
- decls.sorted.toList foreach System.out.println
+ decls.sorted.toList.filter(!_.isMethod) foreach System.out.println
}
}
diff --git a/test/files/run/reflection-sorted-members.check b/test/files/run/reflection-sorted-members.check
index d58b691c42..bb85b5a13c 100644
--- a/test/files/run/reflection-sorted-members.check
+++ b/test/files/run/reflection-sorted-members.check
@@ -1,34 +1,4 @@
value a
value b
value c
-method c
-method b
-method a
-constructor Foo$1
value x
-method x
-constructor Bar$1
-method finalize
-method wait
-method wait
-method wait
-method equals
-method toString
-method hashCode
-method getClass
-method clone
-method notify
-method notifyAll
-constructor Object
-method eq
-method ne
-method ==
-method !=
-method ##
-method synchronized
-method $isInstanceOf
-method $asInstanceOf
-method ==
-method !=
-method isInstanceOf
-method asInstanceOf
diff --git a/test/files/run/reflection-sorted-members.scala b/test/files/run/reflection-sorted-members.scala
index 9980d79999..a8379234c0 100644
--- a/test/files/run/reflection-sorted-members.scala
+++ b/test/files/run/reflection-sorted-members.scala
@@ -6,6 +6,6 @@ object Test {
class Foo(val a: Int, val b: Int, val c: Int) extends Bar(a + b + c) with T1 with T2
import scala.reflect.runtime.{currentMirror => cm}
val members = cm.classSymbol(classOf[Foo]).typeSignature.members
- members.sorted.toList foreach System.out.println
+ members.sorted.toList.filter(!_.isMethod) foreach System.out.println
}
}
diff --git a/test/files/run/richWrapperEquals.scala b/test/files/run/richWrapperEquals.scala
index 44beb133b3..4a43617cde 100644
--- a/test/files/run/richWrapperEquals.scala
+++ b/test/files/run/richWrapperEquals.scala
@@ -1,10 +1,6 @@
object Test {
def main(args: Array[String]): Unit = {
- assert(intWrapper(5) == 5)
- assert(5 == intWrapper(5))
assert(5 == (5: java.lang.Integer))
assert((5: java.lang.Integer) == 5)
- assert((5: java.lang.Integer) == intWrapper(5))
- assert(intWrapper(5) == (5: java.lang.Integer))
}
}
diff --git a/test/files/run/stream-stack-overflow-filter-map.scala b/test/files/run/stream-stack-overflow-filter-map.scala
new file mode 100644
index 0000000000..f3a9dd49cb
--- /dev/null
+++ b/test/files/run/stream-stack-overflow-filter-map.scala
@@ -0,0 +1,44 @@
+import collection.generic.{FilterMonadic, CanBuildFrom}
+
+object Test extends App {
+ def mapSucc[Repr, That](s: FilterMonadic[Int, Repr])(implicit cbf: CanBuildFrom[Repr, Int, That]) = s map (_ + 1)
+ def flatMapId[T, Repr, That](s: FilterMonadic[T, Repr])(implicit cbf: CanBuildFrom[Repr, T, That]) = s flatMap (Seq(_))
+
+ def testStreamPred(s: Stream[Int])(p: Int => Boolean) {
+ val res1 = s withFilter p
+ val res2 = s filter p
+
+ val expected = s.toSeq filter p
+
+ val fMapped1 = flatMapId(res1)
+ val fMapped2 = flatMapId(res2)
+ assert(fMapped1 == fMapped2)
+ assert(fMapped1.toSeq == expected)
+
+ val mapped1 = mapSucc(res1)
+ val mapped2 = mapSucc(res2)
+ assert(mapped1 == mapped2)
+ assert(mapped1.toSeq == (expected map (_ + 1)))
+
+ assert((res1 map identity).toSeq == res2.toSeq)
+ }
+
+ def testStream(s: Stream[Int]) {
+ testStreamPred(s)(_ => false)
+ testStreamPred(s)(_ => true)
+ testStreamPred(s)(_ % 2 == 0)
+ testStreamPred(s)(_ % 3 == 0)
+ }
+
+ //Reduced version of the test case - either invocation used to cause a stack
+ //overflow before commit 80b3f433e5536d086806fa108ccdfacf10719cc2.
+ val resFMap = (1 to 10000).toStream withFilter (_ => false) flatMap (Seq(_))
+ val resMap = (1 to 10000).toStream withFilter (_ => false) map (_ + 1)
+
+ //Complete test case for withFilter + map/flatMap, as requested by @axel22.
+ for (j <- (0 to 3) :+ 10000) {
+ val stream = (1 to j).toStream
+ assert(stream.toSeq == (1 to j).toSeq)
+ testStream(stream)
+ }
+}
diff --git a/test/files/run/t1987b.check b/test/files/run/t1987b.check
new file mode 100644
index 0000000000..68d4b10e12
--- /dev/null
+++ b/test/files/run/t1987b.check
@@ -0,0 +1 @@
+ok!
diff --git a/test/files/run/t1987b/PullIteratees.scala b/test/files/run/t1987b/PullIteratees.scala
new file mode 100644
index 0000000000..a5a3e65d8f
--- /dev/null
+++ b/test/files/run/t1987b/PullIteratees.scala
@@ -0,0 +1,17 @@
+package scales.xml
+
+trait PullType
+class QName
+trait RetUrn[T]
+
+/**
+ * Iteratees related to pull parsing
+ */
+trait PullIteratees {
+ /**
+ * Without the overload it doesn't trigger the CCE, even though its
+ * not used
+ */
+ def iterate(path: List[QName], xml: String): RetUrn[String] = null
+ def iterate(path: List[QName], xml: Iterator[PullType]): RetUrn[String] = null
+}
diff --git a/test/files/run/t1987b/a.scala b/test/files/run/t1987b/a.scala
new file mode 100644
index 0000000000..c1be5fe3e0
--- /dev/null
+++ b/test/files/run/t1987b/a.scala
@@ -0,0 +1,6 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ scales.xml.CCE_Test.main(args)
+ println("ok!")
+ }
+}
diff --git a/test/files/run/t1987b/cce_test.scala b/test/files/run/t1987b/cce_test.scala
new file mode 100644
index 0000000000..4f9acf0264
--- /dev/null
+++ b/test/files/run/t1987b/cce_test.scala
@@ -0,0 +1,15 @@
+package scales.xml
+//import scales.xml._ // using another pacakge and importing doesn't CCE
+
+object CCE_Test {
+ def main(args: Array[String]): Unit = {
+ // without the import it doesn't trigger the CCE
+ import scaley.funny._
+
+ val pull = null.asInstanceOf[Iterator[PullType]]
+ val LogEntries = null.asInstanceOf[List[QName]]
+ // fully qualify with scales.xml. and it won't trigger it
+ iterate(LogEntries,
+ pull)
+ }
+}
diff --git a/test/files/run/t1987b/pkg1.scala b/test/files/run/t1987b/pkg1.scala
new file mode 100644
index 0000000000..6e749fc6b3
--- /dev/null
+++ b/test/files/run/t1987b/pkg1.scala
@@ -0,0 +1,4 @@
+package scaley
+
+package object funny {
+}
diff --git a/test/files/run/t1987b/pkg2.scala b/test/files/run/t1987b/pkg2.scala
new file mode 100644
index 0000000000..38056a199e
--- /dev/null
+++ b/test/files/run/t1987b/pkg2.scala
@@ -0,0 +1,3 @@
+package scales
+
+package object xml extends PullIteratees
diff --git a/test/files/run/t5356.check b/test/files/run/t5356.check
index 21c4aef07b..7522e7ea74 100644
--- a/test/files/run/t5356.check
+++ b/test/files/run/t5356.check
@@ -1,6 +1,6 @@
-1 scala.runtime.RichInt
-1 scala.runtime.RichInt
+1 java.lang.Integer
+1 java.lang.Integer
1 scala.math.BigInt
-1 scala.runtime.RichDouble
-1 scala.runtime.RichFloat
+1 java.lang.Double
+1 java.lang.Float
1
diff --git a/test/files/run/t5356.scala b/test/files/run/t5356.scala
index f7696c6088..ec17e036ad 100644
--- a/test/files/run/t5356.scala
+++ b/test/files/run/t5356.scala
@@ -1,12 +1,12 @@
object Test {
- def f(x: { def toInt: Int }) = println(x.toInt + " " + x.getClass.getName)
-
+ def f(x: Any { def toInt: Int }) = println(x.toInt + " " + x.getClass.getName)
+
def main(args: Array[String]): Unit = {
f(1)
f(1.toInt)
f(BigInt(1))
f(1d)
f(1f)
- println((1: { def toInt: Int }).toInt)
+ println((1: (Any { def toInt: Int })).toInt)
}
}
diff --git a/test/files/run/t6261.scala b/test/files/run/t6261.scala
new file mode 100644
index 0000000000..b4463256c9
--- /dev/null
+++ b/test/files/run/t6261.scala
@@ -0,0 +1,130 @@
+import scala.collection.immutable._
+
+object Test extends App {
+
+ def test0() {
+ val m=ListMap(1->2,3->4)
+ if(m.tail ne m.tail)
+ println("ListMap.tail uses a builder, so it is not O(1)")
+ }
+
+ def test1() {
+ // test that a HashTrieMap with one leaf element is not created!
+ val x = HashMap.empty + (1->1) + (2->2)
+ if(x.getClass.getSimpleName != "HashTrieMap")
+ println("A hash map containing two non-colliding values should be a HashTrieMap")
+
+ val y = x - 1
+ if(y.getClass.getSimpleName != "HashMap1")
+ println("A hash map containing one element should always use HashMap1")
+ }
+
+ def test2() {
+ // class that always causes hash collisions
+ case class Collision(value:Int) { override def hashCode = 0 }
+
+ // create a set that should have a collison
+ val x = HashMap.empty + (Collision(0)->0) + (Collision(1) ->0)
+ if(x.getClass.getSimpleName != "HashMapCollision1")
+ println("HashMap of size >1 with collisions should use HashMapCollision")
+
+ // remove the collision again by removing all but one element
+ val y = x - Collision(0)
+ if(y.getClass.getSimpleName != "HashMap1")
+ println("HashMap of size 1 should use HashMap1" + y.getClass)
+ }
+ def test3() {
+ // finds an int x such that improved(x) differs in the first bit to improved(0),
+ // which is the worst case for the HashTrieSet
+ def findWorstCaseInts() {
+ // copy of improve from HashSet
+ def improve(hcode: Int) = {
+ var h: Int = hcode + ~(hcode << 9)
+ h = h ^ (h >>> 14)
+ h = h + (h << 4)
+ h ^ (h >>> 10)
+ }
+
+ // find two hashes which have a large separation
+ val x = 0
+ var y = 1
+ val ix = improve(x)
+ while(y!=0 && improve(y)!=ix+(1<<31))
+ y+=1
+ printf("%s %s %x %x\n",x,y,improve(x), improve(y))
+ }
+ // this is not done every test run since it would slow down ant test.suite too much.
+ // findWorstCaseInts()
+
+ // two numbers that are immediately adiacent when fed through HashSet.improve
+ val h0 = 0
+ val h1 = 1270889724
+
+ // h is the hashcode, i is ignored for the hashcode but relevant for equality
+ case class Collision(h:Int, i:Int) {
+ override def hashCode = h
+ }
+ val a = Collision(h0,0)->0
+ val b = Collision(h0,1)->0
+ val c = Collision(h1,0)->0
+
+ // create a HashSetCollision1
+ val x = HashMap(a) + b
+ if(x.getClass.getSimpleName != "HashMapCollision1")
+ println("x should be a HashMapCollision")
+ StructureTests.validate(x)
+ //StructureTests.printStructure(x)
+ require(x.size==2 && x.contains(a._1) && x.contains(b._1))
+
+ // go from a HashSetCollision1 to a HashTrieSet with maximum depth
+ val y = x + c
+ if(y.getClass.getSimpleName != "HashTrieMap")
+ println("y should be a HashTrieMap")
+ StructureTests.validate(y)
+ // StructureTests.printStructure(y)
+ require(y.size==3 && y.contains(a._1) && y.contains(b._1) && y.contains(c._1))
+
+ // go from a HashSet1 directly to a HashTrieSet with maximum depth
+ val z = HashMap(a) + c
+ if(y.getClass.getSimpleName != "HashTrieMap")
+ println("y should be a HashTrieMap")
+ StructureTests.validate(z)
+ // StructureTests.printStructure(z)
+ require(z.size == 2 && z.contains(a._1) && z.contains(c._1))
+ }
+ test0()
+ test1()
+ test2()
+ test3()
+}
+
+
+package scala.collection.immutable {
+ object StructureTests {
+ def printStructure(x:HashMap[_,_], prefix:String="") {
+ x match {
+ case m:HashMap.HashTrieMap[_,_] =>
+ println(prefix+m.getClass.getSimpleName + " " + m.size)
+ m.elems.foreach(child => printStructure(child, prefix + " "))
+ case m:HashMap.HashMapCollision1[_,_] =>
+ println(prefix+m.getClass.getSimpleName + " " + m.kvs.size)
+ case m:HashMap.HashMap1[_,_] =>
+ println(prefix+m.getClass.getSimpleName + " " + m.head)
+ case _ =>
+ println(prefix+"empty")
+ }
+ }
+
+ def validate(x:HashMap[_,_]) {
+ x match {
+ case m:HashMap.HashTrieMap[_,_] =>
+ require(m.elems.size>1 || (m.elems.size==1 && m.elems(0).isInstanceOf[HashMap.HashTrieMap[_,_]]))
+ m.elems.foreach(validate _)
+ case m:HashMap.HashMapCollision1[_,_] =>
+ require(m.kvs.size>1)
+ case m:HashMap.HashMap1[_,_] =>
+ case _ =>
+ }
+ }
+ }
+}
diff --git a/test/files/run/t6272.check b/test/files/run/t6272.check
new file mode 100644
index 0000000000..f00c965d83
--- /dev/null
+++ b/test/files/run/t6272.check
@@ -0,0 +1,10 @@
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
diff --git a/test/files/run/t6272.scala b/test/files/run/t6272.scala
new file mode 100644
index 0000000000..174436919b
--- /dev/null
+++ b/test/files/run/t6272.scala
@@ -0,0 +1,62 @@
+// x1, x2, and x3 resulted in: symbol variable bitmap$0 does not exist in A.<init>
+object A {
+
+ try {
+ lazy val x1 = 1
+ println(x1)
+ sys.error("!")
+ } catch {
+ case _: Throwable =>
+ lazy val x2 = 2
+ println(x2)
+ } finally {
+ lazy val x3 = 3
+ println(x3)
+ }
+
+ if ("".isEmpty) {
+ lazy val x4 = 4
+ println(x4)
+ }
+
+ var b = true
+ while(b) {
+ lazy val x5 = 5
+ println(x5)
+ b = false
+ }
+
+
+ def method {
+ try {
+ lazy val x6 = 6
+ println(x6)
+ sys.error("!")
+ } catch {
+ case _: Throwable =>
+ lazy val x7 = 7
+ println(x7)
+ } finally {
+ lazy val x8 = 8
+ println(x8)
+ }
+
+ if ("".isEmpty) {
+ lazy val x9 = 9
+ println(x9)
+ }
+
+ var b = true
+ while(b) {
+ lazy val x10 = 10
+ println(x10)
+ b = false
+ }
+ }
+}
+
+object Test {
+ def main(args: Array[String]) {
+ A.method
+ }
+}
diff --git a/test/files/run/t6292.scala b/test/files/run/t6292.scala
new file mode 100644
index 0000000000..51e31f95fc
--- /dev/null
+++ b/test/files/run/t6292.scala
@@ -0,0 +1,18 @@
+ import scala.collection.mutable.DoubleLinkedList
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ cloneAndtest(DoubleLinkedList[Int]())
+ cloneAndtest(DoubleLinkedList[Int](1))
+ cloneAndtest(DoubleLinkedList[Int](1,2,3,4))
+ }
+
+ def cloneAndtest(l: DoubleLinkedList[Int]): Unit =
+ testSame(l, l.clone.asInstanceOf[DoubleLinkedList[Int]])
+
+ def testSame(one: DoubleLinkedList[Int], two: DoubleLinkedList[Int]): Unit = {
+ def msg = s" for ${one} and ${two} !"
+ assert(one.size == two.size, s"Cloned sizes are not the same $msg!")
+ assert(one == two, s"Cloned lists are not equal $msg")
+ }
+}
diff --git a/test/files/run/try-catch-unify.check b/test/files/run/try-catch-unify.check
index b1de2bfa74..67a8c64a33 100644
--- a/test/files/run/try-catch-unify.check
+++ b/test/files/run/try-catch-unify.check
@@ -1,3 +1,4 @@
Failure(java.lang.NumberFormatException: For input string: "Hi")
Success(5.0)
O NOES
+Failure(java.lang.NumberFormatException: For input string: "Hi")
diff --git a/test/files/run/try-catch-unify.scala b/test/files/run/try-catch-unify.scala
index 0d819ab957..8cb14d060e 100644
--- a/test/files/run/try-catch-unify.scala
+++ b/test/files/run/try-catch-unify.scala
@@ -11,5 +11,6 @@ object Test {
} catch {
case t => println(t.getMessage)
}
+ println(nonFatalCatch withTry ("Hi".toDouble))
}
}