diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-01 19:03:35 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-01 19:03:35 +0000 |
commit | ff86078200fea24ad86b402438058fef032ec73f (patch) | |
tree | e83d4dae01820f7b94c7f24f9497320b8bb7f9fb | |
parent | 3953904fd0abf7c40b007dd94636177434657a36 (diff) | |
download | scala-ff86078200fea24ad86b402438058fef032ec73f.tar.gz scala-ff86078200fea24ad86b402438058fef032ec73f.tar.bz2 scala-ff86078200fea24ad86b402438058fef032ec73f.zip |
Sprinkling in some names to avoid reflective ca...
Sprinkling in some names to avoid reflective calls in the compiler as
suggested by magarcia. Closes #3974, no review.
-rw-r--r-- | src/compiler/scala/tools/nsc/io/ZipArchive.scala | 10 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/util/CharArrayReader.scala | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/io/ZipArchive.scala b/src/compiler/scala/tools/nsc/io/ZipArchive.scala index 21ec95d338..4a1ed2e67b 100644 --- a/src/compiler/scala/tools/nsc/io/ZipArchive.scala +++ b/src/compiler/scala/tools/nsc/io/ZipArchive.scala @@ -47,7 +47,11 @@ object ZipArchive { */ def fromURL(url: URL): AbstractFile = new URLZipArchive(url) - private[io] class ZipEntryTraversableClass(in: InputStream) extends Traversable[ZipEntry] { + private[io] trait ZipTrav extends Traversable[ZipEntry] { + def zis: () => ZipInputStream + } + + private[io] class ZipEntryTraversableClass(in: InputStream) extends ZipTrav { val zis = () => new ZipInputStream(in) def foreach[U](f: ZipEntry => U) = { @@ -72,6 +76,7 @@ object ZipArchive { } } } +import ZipArchive.ZipTrav /** This abstraction aims to factor out the common code between * ZipArchive (backed by a zip file) and URLZipArchive (backed @@ -81,7 +86,6 @@ private[io] trait ZipContainer extends AbstractFile { /** Abstract types */ type SourceType // InputStream or AbstractFile type CreationType // InputStream or ZipFile - type ZipTrav = Traversable[ZipEntry] { def zis: () => ZipInputStream } /** Abstract values */ protected val creationSource: CreationType @@ -245,7 +249,7 @@ final class ZipArchive(file: File, val archive: ZipFile) extends PlainFile(file) } private def zipTraversableFromZipFile(z: ZipFile): ZipTrav = - new Iterable[ZipEntry] { + new Iterable[ZipEntry] with ZipTrav { def zis: () => ZipInputStream = null // not valid for this type def iterator = new Iterator[ZipEntry] { val enum = z.entries() diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 3aa723bcfd..cfd78b7b08 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -114,8 +114,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. * </li> * </ul> */ - val erasure = new TypeMap { - + object erasure extends TypeMap { // Compute the dominant part of the intersection type with given `parents` according to new spec. def intersectionDominator(parents: List[Type]): Type = if (parents.isEmpty) ObjectClass.tpe diff --git a/src/compiler/scala/tools/nsc/util/CharArrayReader.scala b/src/compiler/scala/tools/nsc/util/CharArrayReader.scala index 907622e31f..4f4c9a1e13 100644 --- a/src/compiler/scala/tools/nsc/util/CharArrayReader.scala +++ b/src/compiler/scala/tools/nsc/util/CharArrayReader.scala @@ -100,7 +100,9 @@ abstract class CharArrayReader { self => } /** A new reader that takes off at the current character position */ - def lookaheadReader = new CharArrayReader { + def lookaheadReader = new CharArrayLookaheadReader + + class CharArrayLookaheadReader extends CharArrayReader { val buf = self.buf charOffset = self.charOffset ch = self.ch |