summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/io
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-05-03 10:15:10 -0700
committerPaul Phillips <paulp@improving.org>2013-05-03 11:36:37 -0700
commit80ac7d006350c0d60ff1b293ee955c3435288a9e (patch)
tree1cb3f2dfbec47cb1a966b7bc459907a14f937f1b /src/reflect/scala/reflect/io
parent6eb33d4ad15ae3548c21535de652ea246582a44f (diff)
downloadscala-80ac7d006350c0d60ff1b293ee955c3435288a9e.tar.gz
scala-80ac7d006350c0d60ff1b293ee955c3435288a9e.tar.bz2
scala-80ac7d006350c0d60ff1b293ee955c3435288a9e.zip
Absolutized paths involving the scala package.
Confusing, now-it-happens now-it-doesn't mysteries lurk in the darkness. When scala packages are declared like this: package scala.collection.mutable Then paths relative to scala can easily be broken via the unlucky presence of an empty (or nonempty) directory. Example: // a.scala package scala.foo class Bar { new util.Random } % scalac ./a.scala % mkdir util % scalac ./a.scala ./a.scala:4: error: type Random is not a member of package util new util.Random ^ one error found There are two ways to play defense against this: - don't use relative paths; okay sometimes, less so others - don't "opt out" of the scala package This commit mostly pursues the latter, with occasional doses of the former. I created a scratch directory containing these empty directories: actors annotation ant api asm beans cmd collection compat concurrent control convert docutil dtd duration event factory forkjoin generic hashing immutable impl include internal io logging macros man1 matching math meta model mutable nsc parallel parsing partest persistent process pull ref reflect reify remote runtime scalap scheduler script swing sys text threadpool tools transform unchecked util xml I stopped when I could compile the main src directories even with all those empties on my classpath.
Diffstat (limited to 'src/reflect/scala/reflect/io')
-rw-r--r--src/reflect/scala/reflect/io/AbstractFile.scala3
-rw-r--r--src/reflect/scala/reflect/io/Directory.scala3
-rw-r--r--src/reflect/scala/reflect/io/File.scala9
-rw-r--r--src/reflect/scala/reflect/io/FileOperationException.scala3
-rw-r--r--src/reflect/scala/reflect/io/IOStats.scala3
-rw-r--r--src/reflect/scala/reflect/io/NoAbstractFile.scala8
-rw-r--r--src/reflect/scala/reflect/io/Path.scala6
-rw-r--r--src/reflect/scala/reflect/io/PlainFile.scala3
-rw-r--r--src/reflect/scala/reflect/io/Streamable.scala3
-rw-r--r--src/reflect/scala/reflect/io/VirtualDirectory.scala3
-rw-r--r--src/reflect/scala/reflect/io/VirtualFile.scala6
-rw-r--r--src/reflect/scala/reflect/io/ZipArchive.scala7
12 files changed, 34 insertions, 23 deletions
diff --git a/src/reflect/scala/reflect/io/AbstractFile.scala b/src/reflect/scala/reflect/io/AbstractFile.scala
index 4ac56da628..ac1159b2ac 100644
--- a/src/reflect/scala/reflect/io/AbstractFile.scala
+++ b/src/reflect/scala/reflect/io/AbstractFile.scala
@@ -4,7 +4,8 @@
*/
-package scala.reflect
+package scala
+package reflect
package io
import java.io.{ FileOutputStream, IOException, InputStream, OutputStream, BufferedOutputStream, ByteArrayOutputStream }
diff --git a/src/reflect/scala/reflect/io/Directory.scala b/src/reflect/scala/reflect/io/Directory.scala
index c11119286f..2b965e6d69 100644
--- a/src/reflect/scala/reflect/io/Directory.scala
+++ b/src/reflect/scala/reflect/io/Directory.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.reflect
+package scala
+package reflect
package io
import java.io.{ File => JFile }
diff --git a/src/reflect/scala/reflect/io/File.scala b/src/reflect/scala/reflect/io/File.scala
index 64651dcfbd..a9c6807e88 100644
--- a/src/reflect/scala/reflect/io/File.scala
+++ b/src/reflect/scala/reflect/io/File.scala
@@ -7,13 +7,16 @@
\* */
-package scala.reflect
+package scala
+package reflect
package io
import java.io.{
FileInputStream, FileOutputStream, BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter,
- BufferedInputStream, BufferedOutputStream, IOException, PrintStream, PrintWriter, Closeable => JCloseable }
-import java.io.{ File => JFile }
+ BufferedInputStream, BufferedOutputStream, IOException, PrintStream, PrintWriter, Closeable => JCloseable,
+ File => JFile
+}
+
import java.nio.channels.{ Channel, FileChannel }
import scala.io.Codec
import scala.language.{reflectiveCalls, implicitConversions}
diff --git a/src/reflect/scala/reflect/io/FileOperationException.scala b/src/reflect/scala/reflect/io/FileOperationException.scala
index 13a1322798..fdfe0234e0 100644
--- a/src/reflect/scala/reflect/io/FileOperationException.scala
+++ b/src/reflect/scala/reflect/io/FileOperationException.scala
@@ -7,7 +7,8 @@
\* */
-package scala.reflect
+package scala
+package reflect
package io
/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
case class FileOperationException(msg: String) extends RuntimeException(msg)
diff --git a/src/reflect/scala/reflect/io/IOStats.scala b/src/reflect/scala/reflect/io/IOStats.scala
index 64e1e952cd..71f8be330d 100644
--- a/src/reflect/scala/reflect/io/IOStats.scala
+++ b/src/reflect/scala/reflect/io/IOStats.scala
@@ -1,4 +1,5 @@
-package scala.reflect.io
+package scala
+package reflect.io
import scala.reflect.internal.util.Statistics
diff --git a/src/reflect/scala/reflect/io/NoAbstractFile.scala b/src/reflect/scala/reflect/io/NoAbstractFile.scala
index 2c59fd8aae..a4e869ed41 100644
--- a/src/reflect/scala/reflect/io/NoAbstractFile.scala
+++ b/src/reflect/scala/reflect/io/NoAbstractFile.scala
@@ -3,15 +3,15 @@
* @author Paul Phillips
*/
-package scala.reflect
+package scala
+package reflect
package io
import java.io.InputStream
-import java.io.{ File => JFile }
/** A distinguished object so you can avoid both null
* and Option.
- *
+ *
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
*/
object NoAbstractFile extends AbstractFile {
@@ -19,7 +19,7 @@ object NoAbstractFile extends AbstractFile {
def container: AbstractFile = this
def create(): Unit = ???
def delete(): Unit = ???
- def file: JFile = null
+ def file: java.io.File = null
def input: InputStream = null
def isDirectory: Boolean = false
override def isVirtual: Boolean = true
diff --git a/src/reflect/scala/reflect/io/Path.scala b/src/reflect/scala/reflect/io/Path.scala
index 56d4faed99..0da962955c 100644
--- a/src/reflect/scala/reflect/io/Path.scala
+++ b/src/reflect/scala/reflect/io/Path.scala
@@ -3,13 +3,13 @@
* @author Paul Phillips
*/
-package scala.reflect
+package scala
+package reflect
package io
import java.io.{
FileInputStream, FileOutputStream, BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter,
- BufferedInputStream, BufferedOutputStream, RandomAccessFile }
-import java.io.{ File => JFile }
+ BufferedInputStream, BufferedOutputStream, RandomAccessFile, File => JFile }
import java.net.{ URI, URL }
import scala.util.Random.alphanumeric
import scala.language.implicitConversions
diff --git a/src/reflect/scala/reflect/io/PlainFile.scala b/src/reflect/scala/reflect/io/PlainFile.scala
index b892fe7cef..8f24d84488 100644
--- a/src/reflect/scala/reflect/io/PlainFile.scala
+++ b/src/reflect/scala/reflect/io/PlainFile.scala
@@ -3,7 +3,8 @@
* @author Martin Odersky
*/
-package scala.reflect
+package scala
+package reflect
package io
import java.io.{ FileInputStream, FileOutputStream, IOException }
diff --git a/src/reflect/scala/reflect/io/Streamable.scala b/src/reflect/scala/reflect/io/Streamable.scala
index 1d51ad7f54..aa47947672 100644
--- a/src/reflect/scala/reflect/io/Streamable.scala
+++ b/src/reflect/scala/reflect/io/Streamable.scala
@@ -3,7 +3,8 @@
* @author Paul Phillips
*/
-package scala.reflect
+package scala
+package reflect
package io
import java.net.{ URI, URL }
diff --git a/src/reflect/scala/reflect/io/VirtualDirectory.scala b/src/reflect/scala/reflect/io/VirtualDirectory.scala
index 210167e5c6..aa6ceaa09f 100644
--- a/src/reflect/scala/reflect/io/VirtualDirectory.scala
+++ b/src/reflect/scala/reflect/io/VirtualDirectory.scala
@@ -2,7 +2,8 @@
* Copyright 2005-2013 LAMP/EPFL
*/
-package scala.reflect
+package scala
+package reflect
package io
import scala.collection.mutable
diff --git a/src/reflect/scala/reflect/io/VirtualFile.scala b/src/reflect/scala/reflect/io/VirtualFile.scala
index d34eece3f0..45f38db745 100644
--- a/src/reflect/scala/reflect/io/VirtualFile.scala
+++ b/src/reflect/scala/reflect/io/VirtualFile.scala
@@ -3,11 +3,11 @@
* @author Martin Odersky
*/
-package scala.reflect
+package scala
+package reflect
package io
-import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, InputStream, OutputStream }
-import java.io.{ File => JFile }
+import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, InputStream, OutputStream, File => JFile }
/** This class implements an in-memory file.
*
diff --git a/src/reflect/scala/reflect/io/ZipArchive.scala b/src/reflect/scala/reflect/io/ZipArchive.scala
index 11d04538e9..eabf1dcbab 100644
--- a/src/reflect/scala/reflect/io/ZipArchive.scala
+++ b/src/reflect/scala/reflect/io/ZipArchive.scala
@@ -3,7 +3,8 @@
* @author Paul Phillips
*/
-package scala.reflect
+package scala
+package reflect
package io
import java.net.URL
@@ -267,8 +268,8 @@ final class ManifestResources(val url: URL) extends ZipArchive(null) {
def input = url.openStream()
def lastModified =
try url.openConnection().getLastModified()
- catch { case _: IOException => 0 }
-
+ catch { case _: IOException => 0 }
+
override def canEqual(other: Any) = other.isInstanceOf[ManifestResources]
override def hashCode() = url.hashCode
override def equals(that: Any) = that match {