diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/GenericRunnerCommand.scala | 6 | ||||
-rw-r--r-- | src/library/scala/collection/GenTraversableOnce.scala | 20 | ||||
-rw-r--r-- | src/library/scala/collection/TraversableLike.scala | 11 | ||||
-rw-r--r-- | src/library/scala/collection/TraversableOnce.scala | 9 | ||||
-rw-r--r-- | src/manual/scala/man1/scala.scala | 9 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 38 |
6 files changed, 64 insertions, 29 deletions
diff --git a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala index 2584054686..24496fa013 100644 --- a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala +++ b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala @@ -87,7 +87,11 @@ A file argument will be run as a scala script unless it contains only self-contained compilation units (classes and objects) and exactly one runnable main method. In that case the file will be compiled and the main method invoked. This provides a bridge between scripts and standard -scala source.%n""" +scala source. + +When running a script or using -e, an already running compilation daemon +(fsc) is used, or a new one started on demand. The -nc option can be +used to prevent this.%n""" } object GenericRunnerCommand { diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index 244ff26397..4af2ca23be 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -67,6 +67,23 @@ trait GenTraversableOnce[+A] extends Any { */ def foreach[U](f: A => U): Unit + /** Tests whether this $coll is known to have a finite size. + * All strict collections are known to have finite size. For a non-strict + * collection such as `Stream`, the predicate returns `'''true'''` if all + * elements have been computed. It returns `'''false'''` if the stream is + * not yet evaluated to the end. Non-empty Iterators usually return + * `'''false'''` even if they were created from a collection with a known + * finite size. + * + * Note: many collection methods will not work on collections of infinite sizes. + * The typical failure mode is an infinite loop. These methods always attempt a + * traversal without checking first that `hasDefiniteSize` returns `'''true'''`. + * However, checking `hasDefiniteSize` can provide an assurance that size is + * well-defined and non-termination is not a concern. + * + * @return `'''true'''` if this collection is known to have finite size, + * `'''false'''` otherwise. + */ def hasDefiniteSize: Boolean def seq: TraversableOnce[A] @@ -81,6 +98,9 @@ trait GenTraversableOnce[+A] extends Any { /** Tests whether the $coll is empty. * + * Note: Implementations in subclasses that are not repeatedly traversable must take + * care not to consume any elements when `isEmpty` is called. + * * @return `true` if the $coll contains no elements, `false` otherwise. */ def isEmpty: Boolean diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index bd1be84e97..bbbc33b3f5 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -138,17 +138,6 @@ trait TraversableLike[+A, +Repr] extends Any result } - /** Tests whether this $coll is known to have a finite size. - * All strict collections are known to have finite size. For a non-strict - * collection such as `Stream`, the predicate returns `'''true'''` if all - * elements have been computed. It returns `'''false'''` if the stream is - * not yet evaluated to the end. - * - * Note: many collection methods will not work on collections of infinite sizes. - * - * @return `'''true'''` if this collection is known to have finite size, - * `'''false'''` otherwise. - */ def hasDefiniteSize = true def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = { diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 910c59b179..75c0d82922 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -38,9 +38,10 @@ import scala.reflect.ClassTag * `Traversables`, such as folds, conversions, and other operations which * traverse some or all of the elements and return a derived value. * Directly subclassing `TraversableOnce` is not recommended - instead, - * consider declaring an `Iterator` with a `next` and `hasNext` method, - * creating an `Iterator` with one of the methods on the `Iterator` object, - * or declaring a subclass of `Traversable`. + * consider declaring an `Iterator` with a `next` and `hasNext` method or + * creating an `Iterator` with one of the methods on the `Iterator` object. + * Consider declaring a subclass of `Traversable` instead if the elements + * can be traversed repeatedly. * * @define coll traversable or iterator * @define orderDependent @@ -61,8 +62,8 @@ import scala.reflect.ClassTag trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] { self => + //TODO 2.12: Remove these methods. They are already defined in GenTraversableOnce /* Self-documenting abstract methods. */ - def foreach[U](f: A => U): Unit def isEmpty: Boolean def hasDefiniteSize: Boolean diff --git a/src/manual/scala/man1/scala.scala b/src/manual/scala/man1/scala.scala index 92d9c59cca..0fc73d2c91 100644 --- a/src/manual/scala/man1/scala.scala +++ b/src/manual/scala/man1/scala.scala @@ -65,6 +65,10 @@ object scala extends Command { "Do not use the " & MBold("fsc") & " offline compiler."), Definition( + CmdOption("nc"), + "Same as " & Mono("-nocompdaemon") & "."), + + Definition( CmdOptionBound("D", "property=value"), "Set a Java system property. If no value is specified, " & "then the property is set to the empty string."), @@ -135,6 +139,11 @@ object scala extends Command { "line. Headers can be used to make stand-alone script files, as shown " & "in the examples below.", + "When running a script or using " & Mono("-e") & ", an already running " & + "compilation daemon (fsc) is used, or a new one started on demand. The " & + Mono("-nocompdaemon") & " or " & Mono("-nc") & " option can be used to " & + "prevent this.", + "If " & Mono("scala") & " is run from an sbaz(1) directory, " & "then it will add to its classpath any jars installed in the " & "lib directory of the sbaz directory. Additionally, if no " & diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 11e740117d..3b9ee9048a 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -1256,8 +1256,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** These should be moved somewhere like JavaPlatform. */ def javaSimpleName: Name = addModuleSuffix(simpleName.dropLocal) - def javaBinaryName: Name = addModuleSuffix(fullNameInternal('/')) - def javaClassName: String = addModuleSuffix(fullNameInternal('.')).toString + def javaBinaryName: Name = name.newName(javaBinaryNameString) + def javaBinaryNameString: String = fullName('/', moduleSuffix) + def javaClassName: String = fullName('.', moduleSuffix) /** The encoded full path name of this symbol, where outer names and inner names * are separated by `separator` characters. @@ -1265,18 +1266,29 @@ trait Symbols extends api.Symbols { self: SymbolTable => * Never adds id. * Drops package objects. */ - final def fullName(separator: Char): String = fullNameAsName(separator).toString - - /** Doesn't drop package objects, for those situations (e.g. classloading) - * where the true path is needed. - */ - private def fullNameInternal(separator: Char): Name = ( - if (isRoot || isRootPackage || this == NoSymbol) name - else if (owner.isEffectiveRoot) name - else effectiveOwner.enclClass.fullNameAsName(separator) append (separator, name) - ) + final def fullName(separator: Char): String = fullName(separator, "") + + private def fullName(separator: Char, suffix: CharSequence): String = { + var b: java.lang.StringBuffer = null + def loop(size: Int, sym: Symbol): Unit = { + val symName = sym.name + val nSize = symName.length - (if (symName.endsWith(nme.LOCAL_SUFFIX_STRING)) 1 else 0) + if (sym.isRoot || sym.isRootPackage || sym == NoSymbol || sym.owner.isEffectiveRoot) { + val capacity = size + nSize + b = new java.lang.StringBuffer(capacity) + b.append(chrs, symName.start, nSize) + } else { + loop(size + nSize + 1, sym.effectiveOwner.enclClass) + b.append(separator) + b.append(chrs, symName.start, nSize) + } + } + loop(suffix.length(), this) + b.append(suffix) + b.toString + } - def fullNameAsName(separator: Char): Name = fullNameInternal(separator).dropLocal + def fullNameAsName(separator: Char): Name = name.newName(fullName(separator, "")) /** The encoded full path name of this symbol, where outer names and inner names * are separated by periods. |