diff options
35 files changed, 673 insertions, 121 deletions
diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf index 13e4f4ba85..3808083dd3 100644 --- a/bincompat-forward.whitelist.conf +++ b/bincompat-forward.whitelist.conf @@ -314,6 +314,11 @@ filter { { matchName="scala.reflect.runtime.Settings#IntSetting.valueSetByUser" problemName=MissingMethodProblem + }, + // SI-9059 + { + matchName="scala.util.Random.scala$util$Random$$nextAlphaNum$1" + problemName=MissingMethodProblem } ] } @@ -1445,15 +1445,7 @@ TODO: <stopwatch name="quick.sbt-interface.timer" action="total"/> </target> - <target name="test.junit.init" depends="quick.done"> - <uptodate property="test.junit.available" targetfile="${build-junit.dir}/test-compile.complete"> - <srcfiles dir="${test.junit.src}"> - <include name="**/*.scala"/> - </srcfiles> - </uptodate> - </target> - - <target name="test.junit.comp" depends="test.junit.init, quick.done" unless="test.junit.available"> + <target name="test.junit.comp" depends="pack.done"> <stopwatch name="test.junit.compiler.timer"/> <mkdir dir="${test.junit.classes}"/> <scalacfork @@ -1469,7 +1461,7 @@ TODO: <stopwatch name="test.junit.compiler.timer" action="total"/> </target> - <target name="test.junit" depends="test.junit.comp, test.junit.init"> + <target name="test.junit" depends="test.junit.comp"> <stopwatch name="test.junit.timer"/> <mkdir dir="${test.junit.classes}"/> <echo message="Note: details of failed tests will be output to ${build-junit.dir}"/> diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index 7acb3632d2..9862ea7987 100755 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -109,9 +109,6 @@ if [[ -n "$cygwin" ]]; then JAVA_HOME="$(cygpath --$format "$JAVA_HOME")" fi TOOL_CLASSPATH="$(cygpath --path --$format "$TOOL_CLASSPATH")" -elif [[ -n "$mingw" ]]; then - SCALA_HOME="$(cmd //c echo "$SCALA_HOME")" - TOOL_CLASSPATH="$(cmd //c echo "$TOOL_CLASSPATH")" fi if [[ -n "$cygwin$mingw" ]]; then @@ -131,23 +128,6 @@ fi declare -a java_args declare -a scala_args -# default to the boot classpath for speed, except on cygwin/mingw because -# JLine on Windows requires a custom DLL to be loaded. -unset usebootcp -if [[ -z "$cygwin$mingw" ]]; then - usebootcp="true" -fi - -# If using the boot classpath, also pass an empty classpath -# to java to suppress "." from materializing. -classpathArgs () { - if [[ -n $usebootcp ]]; then - echo "-Xbootclasspath/a:$TOOL_CLASSPATH -classpath \"\"" - else - echo "-classpath $TOOL_CLASSPATH" - fi -} - # SI-8358, SI-8368 -- the default should really be false, # but I don't want to flip the default during 2.11's RC cycle OVERRIDE_USEJAVACP="-Dscala.usejavacp=true" @@ -200,6 +180,23 @@ if [[ -z "$JAVACMD" && -n "$JAVA_HOME" && -x "$JAVA_HOME/bin/java" ]]; then JAVACMD="$JAVA_HOME/bin/java" fi +declare -a classpath_args + +# default to the boot classpath for speed, except on cygwin/mingw because +# JLine on Windows requires a custom DLL to be loaded. +unset usebootcp +if [[ -z "$cygwin$mingw" ]]; then + usebootcp="true" +fi + +# If using the boot classpath, also pass an empty classpath +# to java to suppress "." from materializing. +if [[ -n $usebootcp ]]; then + classpath_args=("-Xbootclasspath/a:$TOOL_CLASSPATH" -classpath "\"\"") +else + classpath_args=(-classpath "$TOOL_CLASSPATH") +fi + # note that variables which may intentionally be empty must not # be quoted: otherwise an empty string will appear as a command line # argument, and java will think that is the program to run. @@ -207,7 +204,7 @@ execCommand \ "${JAVACMD:=java}" \ $JAVA_OPTS \ "${java_args[@@]}" \ - $(classpathArgs) \ + "${classpath_args[@@]}" \ -Dscala.home="$SCALA_HOME" \ $OVERRIDE_USEJAVACP \ "$EMACS_OPT" \ diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 71558273a6..d3cd26f256 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -609,7 +609,7 @@ trait Implicits { val itree2 = if (!isView) fallback else pt match { case Function1(arg1, arg2) => typed1( - atPos(itree0.pos)(Apply(itree1, List(Ident("<argument>") setType approximate(arg1)))), + atPos(itree0.pos)(Apply(itree1, List(Ident(nme.argument) setType approximate(arg1)))), EXPRmode, approximate(arg2) ) match { @@ -918,7 +918,7 @@ trait Implicits { /** Returns all eligible ImplicitInfos and their SearchResults in a map. */ - def findAll() = mapFrom(eligible)(typedImplicit(_, ptChecked = false, isLocalToCallsite)) + def findAll() = linkedMapFrom(eligible)(typedImplicit(_, ptChecked = false, isLocalToCallsite)) /** Returns the SearchResult of the best match. */ @@ -963,7 +963,7 @@ trait Implicits { * symbols of the same name in succeeding lists. * @return map from infos to search results */ - def applicableInfos(iss: Infoss, isLocalToCallsite: Boolean): Map[ImplicitInfo, SearchResult] = { + def applicableInfos(iss: Infoss, isLocalToCallsite: Boolean): mutable.LinkedHashMap[ImplicitInfo, SearchResult] = { val start = if (Statistics.canEnable) Statistics.startCounter(subtypeAppInfos) else null val computation = new ImplicitComputation(iss, isLocalToCallsite) { } val applicable = computation.findAll() diff --git a/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala b/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala index bf718c27cc..a4cb3efa4f 100644 --- a/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala +++ b/src/interactive/scala/tools/nsc/interactive/ContextTrees.scala @@ -55,7 +55,11 @@ trait ContextTrees { self: Global => context } } - locateContextTree(contexts, pos) map locateFinestContextTree map (_.context) + def sanitizeContext(c: Context): Context = { + c.retyping = false + c + } + locateContextTree(contexts, pos) map locateFinestContextTree map (ct => sanitizeContext(ct.context)) } /** Returns the ContextTree containing `pos`, or the ContextTree positioned just before `pos`, diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index a3d0346f81..2d09435f60 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -1084,7 +1084,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") case t => t } val context = doLocateContext(pos) - val shouldTypeQualifier = tree0.tpe match { case null => true case mt: MethodType => mt.isImplicit @@ -1139,7 +1138,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") for (view <- applicableViews) { val vtree = viewApply(view) val vpre = stabilizedType(vtree) - for (sym <- vtree.tpe.members) { + for (sym <- vtree.tpe.members if sym.isTerm) { addTypeMember(sym, vpre, inherited = false, view.tree.symbol) } } diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index 7643b84a8b..ecf64624e8 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -218,12 +218,12 @@ self => val b = newBuilder b.sizeHintBounded(n, this) val lead = this.iterator drop n - var go = false - for (x <- this) { - if (lead.hasNext) lead.next() - else go = true - if (go) b += x + val it = this.iterator + while (lead.hasNext) { + lead.next() + it.next() } + while (it.hasNext) b += it.next() b.result() } @@ -283,7 +283,7 @@ self => var i = 0 for (x <- this) { b += ((x, i)) - i +=1 + i += 1 } b.result() } diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala index 3e549f72cd..f8ac1d754d 100644 --- a/src/library/scala/collection/SetLike.scala +++ b/src/library/scala/collection/SetLike.scala @@ -107,22 +107,36 @@ self => */ def + (elem: A): This - /** Creates a new $coll with additional elements. + /** Creates a new $coll with additional elements, omitting duplicates. * - * This method takes two or more elements to be added. Another overloaded - * variant of this method handles the case where a single element is added. + * This method takes two or more elements to be added. Elements that already exist in the $coll will + * not be added. Another overloaded variant of this method handles the case where a single element is added. + * + * Example: + * {{{ + * scala> val a = Set(1, 3) + 2 + 3 + * a: scala.collection.immutable.Set[Int] = Set(1, 3, 2) + * }}} * * @param elem1 the first element to add. * @param elem2 the second element to add. * @param elems the remaining elements to add. - * @return a new $coll with the given elements added. + * @return a new $coll with the given elements added, omitting duplicates. */ def + (elem1: A, elem2: A, elems: A*): This = this + elem1 + elem2 ++ elems - /** Creates a new $coll by adding all elements contained in another collection to this $coll. + /** Creates a new $coll by adding all elements contained in another collection to this $coll, omitting duplicates. + * + * This method takes a collection of elements and adds all elements, omitting duplicates, into $coll. + * + * Example: + * {{{ + * scala> val a = Set(1, 2) ++ Set(2, "a") + * a: scala.collection.immutable.Set[Any] = Set(1, 2, a) + * }}} * - * @param elems the collection containing the added elements. - * @return a new $coll with the given elements added. + * @param elems the collection containing the elements to add. + * @return a new $coll with the given elements added, omitting duplicates. */ def ++ (elems: GenTraversableOnce[A]): This = (repr /: elems.seq)(_ + _) @@ -171,7 +185,7 @@ self => * * @return the iterator. */ - def subsets: Iterator[This] = new AbstractIterator[This] { + def subsets(): Iterator[This] = new AbstractIterator[This] { private val elms = self.toIndexedSeq private var len = 0 private var itr: Iterator[This] = Iterator.empty diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index fccc1d81b9..bcfea7a463 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -873,6 +873,44 @@ extends scala.collection.concurrent.Map[K, V] insertifhc(k, hc, v, INode.KEY_ABSENT) } + // TODO once computeIfAbsent is added to concurrent.Map, + // move the comment there and tweak the 'at most once' part + /** If the specified key is not already in the map, computes its value using + * the given thunk `op` and enters it into the map. + * + * Since concurrent maps cannot contain `null` for keys or values, + * a `NullPointerException` is thrown if the thunk `op` + * returns `null`. + * + * If the specified mapping function throws an exception, + * that exception is rethrown. + * + * Note: This method will invoke op at most once. + * However, `op` may be invoked without the result being added to the map if + * a concurrent process is also trying to add a value corresponding to the + * same key `k`. + * + * @param k the key to modify + * @param op the expression that computes the value + * @return the newly added value + */ + override def getOrElseUpdate(k: K, op: =>V): V = { + val oldv = lookup(k) + if (oldv != null) oldv.asInstanceOf[V] + else { + val v = op + if (v == null) { + throw new NullPointerException("Concurrent TrieMap values cannot be null.") + } else { + val hc = computeHash(k) + insertifhc(k, hc, v, INode.KEY_ABSENT) match { + case Some(oldv) => oldv + case None => v + } + } + } + } + def remove(k: K, v: V): Boolean = { val hc = computeHash(k) removehc(k, v, hc).nonEmpty diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala index 78150b5e88..e92d48cfeb 100644 --- a/src/library/scala/collection/mutable/BitSet.scala +++ b/src/library/scala/collection/mutable/BitSet.scala @@ -121,8 +121,10 @@ class BitSet(protected final var elems: Array[Long]) extends AbstractSet[Int] * @return the bitset itself. */ def &= (other: BitSet): this.type = { - ensureCapacity(other.nwords - 1) - for (i <- 0 until other.nwords) + // Different from other operations: no need to ensure capacity because + // anything beyond the capacity is 0. Since we use other.word which is 0 + // off the end, we also don't need to make sure we stay in bounds there. + for (i <- 0 until nwords) elems(i) = elems(i) & other.word(i) this } diff --git a/src/library/scala/collection/mutable/MapLike.scala b/src/library/scala/collection/mutable/MapLike.scala index af28df1b88..44af886cf5 100644 --- a/src/library/scala/collection/mutable/MapLike.scala +++ b/src/library/scala/collection/mutable/MapLike.scala @@ -178,6 +178,10 @@ trait MapLike[A, B, +This <: MapLike[A, B, This] with Map[A, B]] * * Otherwise, computes value from given expression `op`, stores with key * in map and returns that value. + * + * Concurrent map implementations may evaluate the expression `op` + * multiple times, or may evaluate `op` without inserting the result. + * * @param key the key to test * @param op the computation yielding the value to associate with `key`, if * `key` is previously unbound. diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 2f4aa9cb84..9dd96183da 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -69,22 +69,22 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial * `SomeExtractor(...)` is turned into `ct(SomeExtractor(...))` if `T` in `SomeExtractor.unapply(x: T)` * is uncheckable, but we have an instance of `ClassTag[T]`. */ - def unapply(x: Any): Option[T] = x match { - case null => None - case b: Byte => unapply(b) - case s: Short => unapply(s) - case c: Char => unapply(c) - case i: Int => unapply(i) - case l: Long => unapply(l) - case f: Float => unapply(f) - case d: Double => unapply(d) - case b: Boolean => unapply(b) - case u: Unit => unapply(u) - case a: Any => unapplyImpl(a) - } + def unapply(x: Any): Option[T] = + if (null != x && ( + (runtimeClass.isInstance(x)) + || (x.isInstanceOf[Byte] && runtimeClass.isAssignableFrom(classOf[Byte])) + || (x.isInstanceOf[Short] && runtimeClass.isAssignableFrom(classOf[Short])) + || (x.isInstanceOf[Char] && runtimeClass.isAssignableFrom(classOf[Char])) + || (x.isInstanceOf[Int] && runtimeClass.isAssignableFrom(classOf[Int])) + || (x.isInstanceOf[Long] && runtimeClass.isAssignableFrom(classOf[Long])) + || (x.isInstanceOf[Float] && runtimeClass.isAssignableFrom(classOf[Float])) + || (x.isInstanceOf[Double] && runtimeClass.isAssignableFrom(classOf[Double])) + || (x.isInstanceOf[Boolean] && runtimeClass.isAssignableFrom(classOf[Boolean])) + || (x.isInstanceOf[Unit] && runtimeClass.isAssignableFrom(classOf[Unit]))) + ) Some(x.asInstanceOf[T]) + else None - // TODO: Inline the bodies of these into the Any-accepting unapply overload above and delete them. - // This cannot be done until at least 2.12.0 for reasons of binary compatibility + // TODO: deprecate overloads in 2.12.0, remove in 2.13.0 def unapply(x: Byte) : Option[T] = unapplyImpl(x, classOf[Byte]) def unapply(x: Short) : Option[T] = unapplyImpl(x, classOf[Short]) def unapply(x: Char) : Option[T] = unapplyImpl(x, classOf[Char]) @@ -94,11 +94,10 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial def unapply(x: Double) : Option[T] = unapplyImpl(x, classOf[Double]) def unapply(x: Boolean) : Option[T] = unapplyImpl(x, classOf[Boolean]) def unapply(x: Unit) : Option[T] = unapplyImpl(x, classOf[Unit]) - - private[this] def unapplyImpl(x: Any, alternative: jClass[_] = null): Option[T] = { - val conforms = runtimeClass.isAssignableFrom(x.getClass) || (alternative != null && runtimeClass.isAssignableFrom(alternative)) - if (conforms) Some(x.asInstanceOf[T]) else None - } + + private[this] def unapplyImpl(x: Any, primitiveCls: java.lang.Class[_]): Option[T] = + if (runtimeClass.isInstance(x) || runtimeClass.isAssignableFrom(primitiveCls)) Some(x.asInstanceOf[T]) + else None // case class accessories override def canEqual(x: Any) = x.isInstanceOf[ClassTag[_]] diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala index 8d68c5be38..2d38c9d4a0 100644 --- a/src/library/scala/util/Random.scala +++ b/src/library/scala/util/Random.scala @@ -121,15 +121,21 @@ class Random(val self: java.util.Random) extends AnyRef with Serializable { (bf(xs) ++= buf).result() } + @deprecated("Preserved for backwards binary compatibility. To remove in 2.12.x.", "2.11.6") + final def `scala$util$Random$$isAlphaNum$1`(c: Char) = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') + /** Returns a Stream of pseudorandomly chosen alphanumeric characters, * equally chosen from A-Z, a-z, and 0-9. * * @since 2.8 */ def alphanumeric: Stream[Char] = { - def isAlphaNum(c: Char) = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') + def nextAlphaNum: Char = { + val chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + chars charAt (self nextInt chars.length) + } - Stream continually nextPrintableChar filter isAlphaNum + Stream continually nextAlphaNum } } diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index f32b7326fe..c0562b0679 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -1078,6 +1078,7 @@ trait StdNames { val reflPolyCacheName: NameType = "reflPoly$Cache" val reflParamsCacheName: NameType = "reflParams$Cache" val reflMethodName: NameType = "reflMethod$Method" + val argument: NameType = "<argument>" } diff --git a/src/reflect/scala/reflect/internal/util/Collections.scala b/src/reflect/scala/reflect/internal/util/Collections.scala index d128521be8..a743d8962a 100644 --- a/src/reflect/scala/reflect/internal/util/Collections.scala +++ b/src/reflect/scala/reflect/internal/util/Collections.scala @@ -181,6 +181,9 @@ trait Collections { final def mapFrom[A, A1 >: A, B](xs: List[A])(f: A => B): Map[A1, B] = { Map[A1, B](xs map (x => (x, f(x))): _*) } + final def linkedMapFrom[A, A1 >: A, B](xs: List[A])(f: A => B): mutable.LinkedHashMap[A1, B] = { + mutable.LinkedHashMap[A1, B](xs map (x => (x, f(x))): _*) + } final def mapWithIndex[A, B](xs: List[A])(f: (A, Int) => B): List[B] = { val lb = new ListBuffer[B] diff --git a/src/scaladoc/scala/tools/nsc/doc/Universe.scala b/src/scaladoc/scala/tools/nsc/doc/Universe.scala index 11520c810e..edf5112d7b 100644 --- a/src/scaladoc/scala/tools/nsc/doc/Universe.scala +++ b/src/scaladoc/scala/tools/nsc/doc/Universe.scala @@ -5,6 +5,8 @@ package scala.tools.nsc.doc +import scala.tools.nsc.doc.html.page.diagram.DotRunner + /** * Class to hold common dependencies across Scaladoc classes. * @author Pedro Furlanetto @@ -13,4 +15,5 @@ package scala.tools.nsc.doc trait Universe { def settings: Settings def rootPackage: model.Package + def dotRunner: DotRunner } diff --git a/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala b/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala index a0dd154d2e..61ab18d42d 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala @@ -13,8 +13,6 @@ import io.{ Streamable, Directory } import scala.collection._ import page.diagram._ -import html.page.diagram.DiagramGenerator - /** A class that can generate Scaladoc sites to some fixed root folder. * @author David Bernard * @author Gilles Dubochet */ @@ -121,28 +119,27 @@ class HtmlFactory(val universe: doc.Universe, index: doc.Index) { finally out.close() } - DiagramGenerator.initialize(universe.settings) - libResources foreach (s => copyResource("lib/" + s)) new page.Index(universe, index) writeFor this new page.IndexScript(universe, index) writeFor this - - writeTemplates(_ writeFor this) - - for (letter <- index.firstLetterIndex) { - new html.page.ReferenceIndex(letter._1, index, universe) writeFor this + try { + writeTemplates(_ writeFor this) + for (letter <- index.firstLetterIndex) { + new html.page.ReferenceIndex(letter._1, index, universe) writeFor this + } + } finally { + DiagramStats.printStats(universe.settings) + universe.dotRunner.cleanup() } - - DiagramGenerator.cleanup() } def writeTemplates(writeForThis: HtmlPage => Unit) { val written = mutable.HashSet.empty[DocTemplateEntity] - val diagramGenerator: DiagramGenerator = new DotDiagramGenerator(universe.settings) def writeTemplate(tpl: DocTemplateEntity) { if (!(written contains tpl)) { + val diagramGenerator: DiagramGenerator = new DotDiagramGenerator(universe.settings, universe.dotRunner) writeForThis(new page.Template(universe, diagramGenerator, tpl)) written += tpl tpl.templates collect { case d: DocTemplateEntity => d } map writeTemplate diff --git a/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala b/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala index 3738e79ffe..ce75749859 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala @@ -227,6 +227,18 @@ abstract class HtmlPage extends Page { thisPage => <img src={ relativeLinkTo(List("permalink.png", "lib")) } /> </a> </span> + + def docEntityKindToCompanionTitle(ety: DocTemplateEntity, baseString: String = "See companion") = + ety.companion match{ + case Some(companion) => + s"$baseString${ + if(companion.isObject) " object" + else if(companion.isTrait) " trait" + else if(companion.isClass) " class" + else "" + }" + case None => baseString + } def companionAndPackage(tpl: DocTemplateEntity): Elem = <span class="morelinks">{ @@ -238,7 +250,7 @@ abstract class HtmlPage extends Page { thisPage => else s"class ${companionTpl.name}" <div> Related Docs: - <a href={relativeLinkTo(tpl.companion.get)} title="See companion">{objClassTrait}</a> + <a href={relativeLinkTo(tpl.companion.get)} title={docEntityKindToCompanionTitle(tpl)}>{objClassTrait}</a> | {templateToHtml(tpl.inTemplate, s"package ${tpl.inTemplate.name}")} </div> case None => diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala index eda52c5fbf..e10c54a414 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala @@ -89,7 +89,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp val templateName = if (tpl.isRootPackage) "root package" else tpl.name val displayName = tpl.companion match { case Some(companion) if (companion.visibility.isPublic && companion.inSource != None) => - <a href={relativeLinkTo(companion)} title="Go to companion">{ templateName }</a> + <a href={relativeLinkTo(companion)} title={docEntityKindToCompanionTitle(tpl)}>{ templateName }</a> case _ => templateName } @@ -105,7 +105,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp { tpl.companion match { case Some(companion) if (companion.visibility.isPublic && companion.inSource != None) => - <a href={relativeLinkTo(companion)} title="Go to companion"><img src={ relativeLinkTo(List(docEntityKindToBigImage(tpl), "lib")) }/></a> + <a href={relativeLinkTo(companion)} title={docEntityKindToCompanionTitle(tpl)}><img src={ relativeLinkTo(List(docEntityKindToBigImage(tpl), "lib")) }/></a> case _ => <img src={ relativeLinkTo(List(docEntityKindToBigImage(tpl), "lib")) }/> }} diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala index 61c1819d11..cf65de4151 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala @@ -25,29 +25,3 @@ trait DiagramGenerator { */ def generate(d: Diagram, t: DocTemplateEntity, p: HtmlPage):NodeSeq } - -object DiagramGenerator { - - // TODO: This is tailored towards the dot generator, since it's the only generator. In the future it should be more - // general. - - private[this] var dotRunner: DotRunner = null - private[this] var settings: doc.Settings = null - - def initialize(s: doc.Settings) = - settings = s - - def getDotRunner() = { - if (dotRunner == null) - dotRunner = new DotRunner(settings) - dotRunner - } - - def cleanup() = { - DiagramStats.printStats(settings) - if (dotRunner != null) { - dotRunner.cleanup() - dotRunner = null - } - } -}
\ No newline at end of file diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index 4ff436bdc6..b541cf721b 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -15,7 +15,7 @@ import scala.collection.immutable._ import model._ import model.diagram._ -class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { +class DotDiagramGenerator(settings: doc.Settings, dotRunner: DotRunner) extends DiagramGenerator { // the page where the diagram will be embedded private var page: HtmlPage = null @@ -317,7 +317,7 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { * Calls dot with a given dot string and returns the SVG output. */ private def generateSVG(dotInput: String, template: DocTemplateEntity) = { - val dotOutput = DiagramGenerator.getDotRunner().feedToDot(dotInput, template) + val dotOutput = dotRunner.feedToDot(dotInput, template) var tSVG = -System.currentTimeMillis val result = if (dotOutput != null) { diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala index 7289edc137..03d71f15a3 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala @@ -9,8 +9,11 @@ import base.comment._ import diagram._ import scala.collection._ +import scala.tools.nsc.doc.html.HtmlPage +import scala.tools.nsc.doc.html.page.diagram.{DotRunner} import scala.util.matching.Regex import scala.reflect.macros.internal.macroImpl +import scala.xml.NodeSeq import symtab.Flags import io._ @@ -47,6 +50,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory.universe = thisUniverse val settings = thisFactory.settings val rootPackage = modelCreation.createRootPackage + lazy val dotRunner = new DotRunner(settings) } _modelFinished = true // complete the links between model entities, everthing that couldn't have been done before diff --git a/test/files/pos/t9116.scala b/test/files/pos/t9116.scala new file mode 100644 index 0000000000..16b04c2e6b --- /dev/null +++ b/test/files/pos/t9116.scala @@ -0,0 +1,7 @@ + +trait X { + List(1, 2, 3).toSet.subsets.map(_.toList) // ok now + + List(1, 2, 3).toSet.subsets().map(_.toList) // now also + List(1, 2, 3).toSet.subsets(2).map(_.toList) // still ok +} diff --git a/test/files/presentation/infix-completion.check b/test/files/presentation/infix-completion.check new file mode 100644 index 0000000000..f62dc81d34 --- /dev/null +++ b/test/files/presentation/infix-completion.check @@ -0,0 +1,193 @@ +reload: Snippet.scala + +askTypeCompletion at Snippet.scala(1,34) +================================================================================ +[response] askTypeCompletion at (1,34) +retrieved 192 members +[inaccessible] protected def integralNum: math.Numeric.DoubleAsIfIntegral.type +[inaccessible] protected def num: math.Numeric.DoubleIsFractional.type +[inaccessible] protected def ord: math.Ordering.Double.type +[inaccessible] protected def unifiedPrimitiveEquals(x: Any): Boolean +[inaccessible] protected def unifiedPrimitiveHashcode(): Int +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def !=(x: Byte): Boolean +def !=(x: Char): Boolean +def !=(x: Double): Boolean +def !=(x: Float): Boolean +def !=(x: Int): Boolean +def !=(x: Long): Boolean +def !=(x: Short): Boolean +def %(x: Byte): Int +def %(x: Char): Int +def %(x: Double): Double +def %(x: Float): Float +def %(x: Int): Int +def %(x: Long): Long +def %(x: Short): Int +def &(x: Byte): Int +def &(x: Char): Int +def &(x: Int): Int +def &(x: Long): Long +def &(x: Short): Int +def *(x: Byte): Int +def *(x: Char): Int +def *(x: Double): Double +def *(x: Float): Float +def *(x: Int): Int +def *(x: Long): Long +def *(x: Short): Int +def +(x: Byte): Int +def +(x: Char): Int +def +(x: Double): Double +def +(x: Float): Float +def +(x: Int): Int +def +(x: Long): Long +def +(x: Short): Int +def +(x: String): String +def -(x: Byte): Int +def -(x: Char): Int +def -(x: Double): Double +def -(x: Float): Float +def -(x: Int): Int +def -(x: Long): Long +def -(x: Short): Int +def ->[B](y: B): (Int, B) +def /(x: Byte): Int +def /(x: Char): Int +def /(x: Double): Double +def /(x: Float): Float +def /(x: Int): Int +def /(x: Long): Long +def /(x: Short): Int +def <(x: Byte): Boolean +def <(x: Char): Boolean +def <(x: Double): Boolean +def <(x: Float): Boolean +def <(x: Int): Boolean +def <(x: Long): Boolean +def <(x: Short): Boolean +def <<(x: Int): Int +def <<(x: Long): Int +def <=(x: Byte): Boolean +def <=(x: Char): Boolean +def <=(x: Double): Boolean +def <=(x: Float): Boolean +def <=(x: Int): Boolean +def <=(x: Long): Boolean +def <=(x: Short): Boolean +def ==(x: Byte): Boolean +def ==(x: Char): Boolean +def ==(x: Double): Boolean +def ==(x: Float): Boolean +def ==(x: Int): Boolean +def ==(x: Long): Boolean +def ==(x: Short): Boolean +def >(x: Byte): Boolean +def >(x: Char): Boolean +def >(x: Double): Boolean +def >(x: Float): Boolean +def >(x: Int): Boolean +def >(x: Long): Boolean +def >(x: Short): Boolean +def >=(x: Byte): Boolean +def >=(x: Char): Boolean +def >=(x: Double): Boolean +def >=(x: Float): Boolean +def >=(x: Int): Boolean +def >=(x: Long): Boolean +def >=(x: Short): Boolean +def >>(x: Int): Int +def >>(x: Long): Int +def >>>(x: Int): Int +def >>>(x: Long): Int +def ^(x: Byte): Int +def ^(x: Char): Int +def ^(x: Int): Int +def ^(x: Long): Long +def ^(x: Short): Int +def byteValue(): Byte +def ceil: Double +def compare(y: Double): Int +def compare(y: Long): Int +def compareTo(that: Double): Int +def compareTo(that: Long): Int +def compareTo(x$1: Double): Int +def compareTo(x$1: Long): Int +def doubleValue(): Double +def ensuring(cond: Boolean): Int +def ensuring(cond: Boolean,msg: => Any): Int +def ensuring(cond: Int => Boolean): Int +def ensuring(cond: Int => Boolean,msg: => Any): Int +def equals(x$1: Any): Boolean +def floatValue(): Float +def floor: Double +def formatted(fmtstr: String): String +def hashCode(): Int +def intValue(): Int +def isInfinite(): Boolean +def isInfinity: Boolean +def isNaN(): Boolean +def isNegInfinity: Boolean +def isPosInfinity: Boolean +def isValidLong: Boolean +def longValue(): Long +def round: Long +def shortValue(): Short +def to(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]] +def to(end: Double,step: Double): scala.collection.immutable.NumericRange.Inclusive[Double] +def to(end: Long): scala.collection.immutable.NumericRange.Inclusive[Long] +def to(end: Long,step: Long): scala.collection.immutable.NumericRange.Inclusive[Long] +def toBinaryString: String +def toByte: Byte +def toChar: Char +def toDegrees: Double +def toDouble: Double +def toFloat: Float +def toHexString: String +def toInt: Int +def toLong: Long +def toOctalString: String +def toRadians: Double +def toShort: Short +def toString(): String +def unary_+: Int +def unary_-: Int +def unary_~: Int +def underlying(): AnyRef +def until(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]] +def until(end: Double,step: Double): scala.collection.immutable.NumericRange.Exclusive[Double] +def until(end: Long): scala.collection.immutable.NumericRange.Exclusive[Long] +def until(end: Long,step: Long): scala.collection.immutable.NumericRange.Exclusive[Long] +def |(x: Byte): Int +def |(x: Char): Int +def |(x: Int): Int +def |(x: Long): Long +def |(x: Short): Int +def →[B](y: B): (Int, B) +final def !=(x$1: Any): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +override def abs: Double +override def isValidByte: Boolean +override def isValidChar: Boolean +override def isValidInt: Boolean +override def isValidShort: Boolean +override def isWhole(): Boolean +override def max(that: Double): Double +override def max(that: Long): Long +override def min(that: Double): Double +override def min(that: Long): Long +override def signum: Int +private[this] val self: Double +================================================================================ diff --git a/test/files/presentation/infix-completion/Runner.scala b/test/files/presentation/infix-completion/Runner.scala new file mode 100644 index 0000000000..1c03e3d5ba --- /dev/null +++ b/test/files/presentation/infix-completion/Runner.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests._ + +object Test extends InteractiveTest diff --git a/test/files/presentation/infix-completion/src/Snippet.scala b/test/files/presentation/infix-completion/src/Snippet.scala new file mode 100644 index 0000000000..7e03c486ba --- /dev/null +++ b/test/files/presentation/infix-completion/src/Snippet.scala @@ -0,0 +1 @@ +object Snippet{val x = 123; 1 + 1./*!*/} diff --git a/test/files/presentation/infix-completion2.check b/test/files/presentation/infix-completion2.check new file mode 100644 index 0000000000..5c69cd84cb --- /dev/null +++ b/test/files/presentation/infix-completion2.check @@ -0,0 +1,211 @@ +reload: Snippet.scala + +askTypeCompletion at Snippet.scala(1,34) +================================================================================ +[response] askTypeCompletion at (1,34) +retrieved 211 members +[inaccessible] protected def integralNum: math.Numeric.DoubleAsIfIntegral.type +[inaccessible] protected def num: math.Numeric.DoubleIsFractional.type +[inaccessible] protected def ord: math.Ordering.Double.type +[inaccessible] protected def unifiedPrimitiveEquals(x: Any): Boolean +[inaccessible] protected def unifiedPrimitiveHashcode(): Int +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def !=(x: Byte): Boolean +def !=(x: Char): Boolean +def !=(x: Double): Boolean +def !=(x: Float): Boolean +def !=(x: Int): Boolean +def !=(x: Long): Boolean +def !=(x: Short): Boolean +def %(x: Byte): Int +def %(x: Char): Int +def %(x: Double): Double +def %(x: Float): Float +def %(x: Int): Int +def %(x: Long): Long +def %(x: Short): Int +def &(x: Byte): Int +def &(x: Char): Int +def &(x: Int): Int +def &(x: Long): Long +def &(x: Short): Int +def *(x: Byte): Int +def *(x: Char): Int +def *(x: Double): Double +def *(x: Float): Float +def *(x: Int): Int +def *(x: Long): Long +def *(x: Short): Int +def +(x: Byte): Int +def +(x: Char): Int +def +(x: Double): Double +def +(x: Float): Float +def +(x: Int): Int +def +(x: Long): Long +def +(x: Short): Int +def +(x: String): String +def -(x: Byte): Int +def -(x: Char): Int +def -(x: Double): Double +def -(x: Float): Float +def -(x: Int): Int +def -(x: Long): Long +def -(x: Short): Int +def ->[B](y: B): (Int, B) +def /(x: Byte): Int +def /(x: Char): Int +def /(x: Double): Double +def /(x: Float): Float +def /(x: Int): Int +def /(x: Long): Long +def /(x: Short): Int +def <(x: Byte): Boolean +def <(x: Char): Boolean +def <(x: Double): Boolean +def <(x: Float): Boolean +def <(x: Int): Boolean +def <(x: Long): Boolean +def <(x: Short): Boolean +def <<(x: Int): Int +def <<(x: Long): Int +def <=(x: Byte): Boolean +def <=(x: Char): Boolean +def <=(x: Double): Boolean +def <=(x: Float): Boolean +def <=(x: Int): Boolean +def <=(x: Long): Boolean +def <=(x: Short): Boolean +def ==(x: Byte): Boolean +def ==(x: Char): Boolean +def ==(x: Double): Boolean +def ==(x: Float): Boolean +def ==(x: Int): Boolean +def ==(x: Long): Boolean +def ==(x: Short): Boolean +def >(x: Byte): Boolean +def >(x: Char): Boolean +def >(x: Double): Boolean +def >(x: Float): Boolean +def >(x: Int): Boolean +def >(x: Long): Boolean +def >(x: Short): Boolean +def >=(x: Byte): Boolean +def >=(x: Char): Boolean +def >=(x: Double): Boolean +def >=(x: Float): Boolean +def >=(x: Int): Boolean +def >=(x: Long): Boolean +def >=(x: Short): Boolean +def >>(x: Int): Int +def >>(x: Long): Int +def >>>(x: Int): Int +def >>>(x: Long): Int +def ^(x: Byte): Int +def ^(x: Char): Int +def ^(x: Int): Int +def ^(x: Long): Long +def ^(x: Short): Int +def byteValue(): Byte +def ceil: Double +def compare(y: Double): Int +def compare(y: Float): Int +def compare(y: Int): Int +def compare(y: Long): Int +def compareTo(that: Double): Int +def compareTo(that: Float): Int +def compareTo(that: Int): Int +def compareTo(that: Long): Int +def compareTo(x$1: Double): Int +def compareTo(x$1: Float): Int +def compareTo(x$1: Integer): Int +def compareTo(x$1: Long): Int +def doubleValue(): Double +def ensuring(cond: Boolean): Int +def ensuring(cond: Boolean,msg: => Any): Int +def ensuring(cond: Int => Boolean): Int +def ensuring(cond: Int => Boolean,msg: => Any): Int +def equals(x$1: Any): Boolean +def floatValue(): Float +def floor: Double +def formatted(fmtstr: String): String +def hashCode(): Int +def intValue(): Int +def isInfinite(): Boolean +def isInfinity: Boolean +def isNaN(): Boolean +def isNegInfinity: Boolean +def isPosInfinity: Boolean +def isValidLong: Boolean +def longValue(): Long +def round: Long +def shortValue(): Short +def to(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]] +def to(end: Double,step: Double): scala.collection.immutable.NumericRange.Inclusive[Double] +def to(end: Float): Range.Partial[Float,scala.collection.immutable.NumericRange[Float]] +def to(end: Float,step: Float): scala.collection.immutable.NumericRange.Inclusive[Float] +def to(end: Int): scala.collection.immutable.Range.Inclusive +def to(end: Int,step: Int): scala.collection.immutable.Range.Inclusive +def to(end: Long): scala.collection.immutable.NumericRange.Inclusive[Long] +def to(end: Long,step: Long): scala.collection.immutable.NumericRange.Inclusive[Long] +def toBinaryString: String +def toByte: Byte +def toChar: Char +def toDegrees: Double +def toDouble: Double +def toFloat: Float +def toHexString: String +def toInt: Int +def toLong: Long +def toOctalString: String +def toRadians: Double +def toShort: Short +def toString(): String +def unary_+: Int +def unary_-: Int +def unary_~: Int +def underlying(): AnyRef +def until(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]] +def until(end: Double,step: Double): scala.collection.immutable.NumericRange.Exclusive[Double] +def until(end: Float): Range.Partial[Float,scala.collection.immutable.NumericRange[Float]] +def until(end: Float,step: Float): scala.collection.immutable.NumericRange.Exclusive[Float] +def until(end: Int): scala.collection.immutable.Range +def until(end: Int,step: Int): scala.collection.immutable.Range +def until(end: Long): scala.collection.immutable.NumericRange.Exclusive[Long] +def until(end: Long,step: Long): scala.collection.immutable.NumericRange.Exclusive[Long] +def |(x: Byte): Int +def |(x: Char): Int +def |(x: Int): Int +def |(x: Long): Long +def |(x: Short): Int +def →[B](y: B): (Int, B) +final def !=(x$1: Any): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +override def abs: Double +override def isValidByte: Boolean +override def isValidChar: Boolean +override def isValidInt: Boolean +override def isValidShort: Boolean +override def isWhole(): Boolean +override def max(that: Double): Double +override def max(that: Float): Float +override def max(that: Int): Int +override def max(that: Long): Long +override def min(that: Double): Double +override def min(that: Float): Float +override def min(that: Int): Int +override def min(that: Long): Long +override def signum: Int +private[this] val self: Double +================================================================================ diff --git a/test/files/presentation/infix-completion2/Runner.scala b/test/files/presentation/infix-completion2/Runner.scala new file mode 100644 index 0000000000..1c03e3d5ba --- /dev/null +++ b/test/files/presentation/infix-completion2/Runner.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests._ + +object Test extends InteractiveTest diff --git a/test/files/presentation/infix-completion2/src/Snippet.scala b/test/files/presentation/infix-completion2/src/Snippet.scala new file mode 100644 index 0000000000..4eb8c24a2e --- /dev/null +++ b/test/files/presentation/infix-completion2/src/Snippet.scala @@ -0,0 +1 @@ +object Snippet{val x = 123; 1 + x./*!*/} diff --git a/test/files/run/settings-parse.scala b/test/files/run/settings-parse.scala index 2754feb972..8d83caf68f 100644 --- a/test/files/run/settings-parse.scala +++ b/test/files/run/settings-parse.scala @@ -3,9 +3,8 @@ import scala.language.postfixOps import scala.tools.nsc._ object Test { - val tokens = List("", "-deprecation", "foo.scala") - val subsets = tokens.toSet.subsets.toList - val permutations0 = subsets.flatMap(_.toList.permutations).distinct + val tokens = "" :: "-deprecation" :: "foo.scala" :: Nil + val permutations0 = tokens.toSet.subsets.flatMap(_.toList.permutations).toList.distinct def runWithCp(cp: String) = { val permutations = permutations0 flatMap ("-cp CPTOKEN" :: _ permutations) diff --git a/test/files/scalacheck/Ctrie.scala b/test/files/scalacheck/Ctrie.scala index 714f1c3b09..eef9d06f37 100644 --- a/test/files/scalacheck/Ctrie.scala +++ b/test/files/scalacheck/Ctrie.scala @@ -186,6 +186,25 @@ object Test extends Properties("concurrent.TrieMap") { }) } + property("concurrent getOrElseUpdate") = forAll(threadCounts, sizes) { + (p, sz) => + val totalInserts = new java.util.concurrent.atomic.AtomicInteger + val ct = new TrieMap[Wrap, String] + + val results = inParallel(p) { + idx => + (0 until sz) foreach { + i => + val v = ct.getOrElseUpdate(Wrap(i), idx + ":" + i) + if (v == idx + ":" + i) totalInserts.incrementAndGet() + } + } + + (totalInserts.get == sz) && ((0 until sz) forall { + case i => ct(Wrap(i)).split(":")(1).toInt == i + }) + } + } diff --git a/test/junit/scala/collection/mutable/BitSetTest.scala b/test/junit/scala/collection/mutable/BitSetTest.scala index 8d164b50d4..d56cc45601 100644 --- a/test/junit/scala/collection/mutable/BitSetTest.scala +++ b/test/junit/scala/collection/mutable/BitSetTest.scala @@ -19,4 +19,13 @@ class BitSetTest { bitSet &~= bitSet assert(bitSet.toBitMask.length == size, "Capacity of bitset changed after &~=") } + + @Test def test_SI8917() { + val bigBitSet = BitSet(1, 100, 10000) + val littleBitSet = BitSet(100) + bigBitSet &= littleBitSet + assert(!(bigBitSet contains 10000), "&= not applied to the full bitset") + littleBitSet &= bigBitSet + assert(littleBitSet.toBitMask.length < bigBitSet.toBitMask.length, "Needlessly extended the size of bitset on &=") + } } diff --git a/test/junit/scala/reflect/ClassTag.scala b/test/junit/scala/reflect/ClassTag.scala new file mode 100644 index 0000000000..90cc981fc1 --- /dev/null +++ b/test/junit/scala/reflect/ClassTag.scala @@ -0,0 +1,29 @@ +package scala.reflect + +import org.junit.Test +import org.junit.Assert._ +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +import scala.tools.testing.AssertUtil._ + +class Misc + +@RunWith(classOf[JUnit4]) +class ClassTagTest { + def checkNotString[A: ClassTag](a: Any) = a match { case x: String => false case x: A => true case _ => false } + def checkNotInt[A: ClassTag](a: Any) = a match { case x: Int => false case x: A => true case _ => false } + def checkNotLong[A: ClassTag](a: Any) = a match { case x: Long => false case x: A => true case _ => false } + + @Test def checkMisc = assertTrue(checkNotString[Misc](new Misc)) + @Test def checkString = assertTrue(checkNotInt[String] ("woele")) + @Test def checkByte = assertTrue(checkNotInt[Byte] (0.toByte)) + @Test def checkShort = assertTrue(checkNotInt[Short] (0.toShort)) + @Test def checkChar = assertTrue(checkNotInt[Char] (0.toChar)) + @Test def checkInt = assertTrue(checkNotLong[Int] (0.toInt)) + @Test def checkLong = assertTrue(checkNotInt[Long] (0.toLong)) + @Test def checkFloat = assertTrue(checkNotInt[Float] (0.toFloat)) + @Test def checkDouble = assertTrue(checkNotInt[Double] (0.toDouble)) + @Test def checkBoolean = assertTrue(checkNotInt[Boolean](false)) + @Test def checkUnit = assertTrue(checkNotInt[Unit] ({})) +}
\ No newline at end of file diff --git a/test/junit/scala/util/RandomTest.scala b/test/junit/scala/util/RandomTest.scala new file mode 100644 index 0000000000..32959675ee --- /dev/null +++ b/test/junit/scala/util/RandomTest.scala @@ -0,0 +1,15 @@ +package scala.util + +import org.junit.{ Assert, Test } + +class RandomTest { + // Test for SI-9059 + @Test def testAlphanumeric: Unit = { + def isAlphaNum(c: Char) = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') + + val items = Random.alphanumeric.take(100000) + for (c <- items) { + Assert.assertTrue(s"$c should be alphanumeric", isAlphaNum(c)) + } + } +} diff --git a/test/scaladoc/filters b/test/scaladoc/filters new file mode 100644 index 0000000000..51a7507848 --- /dev/null +++ b/test/scaladoc/filters @@ -0,0 +1,8 @@ +# +#Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28). +Java HotSpot\(TM\) .* warning: +# Hotspot receiving VM options through the $_JAVA_OPTIONS +# env variable outputs them on stderr +Picked up _JAVA_OPTIONS: +# Filter out a message caused by this bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8021205 +objc\[\d+\]: Class JavaLaunchHelper is implemented in both .* and .*\. One of the two will be used\. Which one is undefined\. |