Skip to content

Commit defc455

Browse files
committed
Make sure only aliases in dotty.io are used
Previously, we would use `scala.reflect.io._` directly. The first part of abstracting away reflect is to kill this direct dependency.
1 parent 825f8de commit defc455

26 files changed

+45
-48
lines changed

compiler/sjs/backend/sjs/JSCodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class JSCodeGen()(implicit ctx: Context) {
182182

183183
private def getFileFor(cunit: CompilationUnit, sym: Symbol,
184184
suffix: String) = {
185-
import scala.reflect.io._
185+
import dotty.tools.io._
186186

187187
val outputDirectory: AbstractFile = // TODO Support virtual files
188188
new PlainDirectory(new Directory(new java.io.File(ctx.settings.d.value)))

compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import java.io.{File => JFile}
1515
import scala.collection.generic.Clearable
1616
import scala.collection.mutable
1717
import scala.reflect.ClassTag
18-
import scala.reflect.io.{Directory, PlainDirectory, AbstractFile}
18+
import dotty.tools.io.{Directory, PlainDirectory, AbstractFile}
1919
import scala.tools.asm.{ClassVisitor, FieldVisitor, MethodVisitor}
2020
import scala.tools.nsc.backend.jvm.{BCodeHelpers, BackendInterface}
2121
import dotty.tools.dotc.core._

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import scala.collection.generic.Clearable
1212
import scala.collection.mutable
1313
import scala.reflect.ClassTag
1414
import scala.reflect.internal.util.WeakHashSet
15-
import scala.reflect.io.{AbstractFile, Directory, PlainDirectory}
15+
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory}
1616
import scala.tools.asm.{AnnotationVisitor, ClassVisitor, FieldVisitor, MethodVisitor}
1717
import scala.tools.nsc.backend.jvm.{BCodeHelpers, BackendInterface}
1818
import dotty.tools.dotc.core._

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import dotty.tools.dotc.util.{DotClass, Positions}
3333
import tpd._
3434
import StdNames._
3535

36-
import scala.reflect.io.{AbstractFile, Directory, PlainDirectory}
36+
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory}
3737

3838
class GenBCode extends Phase {
3939
def phaseName: String = "genBCode"
@@ -62,10 +62,10 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
6262

6363
val sourceFile = ctx.compilationUnit.source
6464

65-
/** Convert a `scala.reflect.io.AbstractFile` into a
65+
/** Convert a `dotty.tools.io.AbstractFile` into a
6666
* `dotty.tools.dotc.interfaces.AbstractFile`.
6767
*/
68-
private[this] def convertAbstractFile(absfile: scala.reflect.io.AbstractFile): interfaces.AbstractFile =
68+
private[this] def convertAbstractFile(absfile: dotty.tools.io.AbstractFile): interfaces.AbstractFile =
6969
new interfaces.AbstractFile {
7070
override def name = absfile.name
7171
override def path = absfile.path

compiler/src/dotty/tools/backend/jvm/LabelDefs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import scala.collection.generic.Clearable
1616
import scala.collection.mutable
1717
import scala.collection.mutable.{ListBuffer, ArrayBuffer}
1818
import scala.reflect.ClassTag
19-
import scala.reflect.io.{Directory, PlainDirectory, AbstractFile}
19+
import dotty.tools.io.{Directory, PlainDirectory, AbstractFile}
2020
import scala.tools.asm.{ClassVisitor, FieldVisitor, MethodVisitor}
2121
import scala.tools.nsc.backend.jvm.{BCodeHelpers, BackendInterface}
2222
import dotty.tools.dotc.core._

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import java.io.{BufferedWriter, OutputStreamWriter}
1818
import printing.XprintMode
1919

2020
import scala.annotation.tailrec
21-
import scala.reflect.io.VirtualFile
21+
import dotty.tools.io.VirtualFile
2222
import scala.util.control.NonFatal
2323

2424
/** A compiler run. Exports various methods to compile source files */

compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
/*
22
* Copyright (c) 2014 Contributor. All rights reserved.
33
*/
4-
package dotty.tools.dotc.classpath
4+
package dotty.tools
5+
package dotc.classpath
56

67
import java.net.URL
78
import scala.annotation.tailrec
89
import scala.collection.mutable.ArrayBuffer
9-
import scala.reflect.internal.FatalError
10-
import scala.reflect.io.AbstractFile
11-
import dotty.tools.io.ClassPath
12-
import dotty.tools.io.ClassRepresentation
10+
import dotty.tools.io.{ AbstractFile, ClassPath, ClassRepresentation }
1311

1412
/**
1513
* A classpath unifying multiple class- and sourcepath entries.

compiler/src/dotty/tools/dotc/classpath/ClassPath.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
package dotty.tools.dotc.classpath
55

6-
import scala.reflect.io.AbstractFile
6+
import dotty.tools.io.AbstractFile
77
import dotty.tools.io.ClassRepresentation
88

99
case class ClassPathEntries(packages: Seq[PackageEntry], classesAndSources: Seq[ClassRepresentation])

compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44
package dotty.tools.dotc.classpath
55

6-
import scala.reflect.io.{AbstractFile, VirtualDirectory}
7-
import scala.reflect.io.Path.string2path
6+
import dotty.tools.io.{AbstractFile, VirtualDirectory}
7+
import dotty.tools.io.Path.string2path
88
import dotty.tools.dotc.config.Settings
99
import FileUtils.AbstractFileOps
1010
import dotty.tools.io.ClassPath

compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import java.util.function.IntFunction
1010
import java.util
1111
import java.util.Comparator
1212

13-
import scala.reflect.io.{AbstractFile, PlainFile}
14-
import dotty.tools.io.{ClassPath, ClassRepresentation, PlainNioFile}
13+
import dotty.tools.io.{AbstractFile, PlainFile, ClassPath, ClassRepresentation, PlainNioFile}
1514
import FileUtils._
1615
import scala.collection.JavaConverters._
1716

@@ -118,7 +117,7 @@ trait JFileDirectoryLookup[FileEntryType <: ClassRepresentation] extends Directo
118117
} else Array()
119118
}
120119
protected def getName(f: File): String = f.getName
121-
protected def toAbstractFile(f: File): AbstractFile = new PlainFile(new scala.reflect.io.File(f))
120+
protected def toAbstractFile(f: File): AbstractFile = new PlainFile(new dotty.tools.io.File(f))
122121
protected def isPackage(f: File): Boolean = f.isPackage
123122

124123
assert(dir != null, "Directory file in DirectoryFileLookup cannot be null")
@@ -208,7 +207,7 @@ case class DirectoryClassPath(dir: File) extends JFileDirectoryLookup[ClassFileE
208207
val relativePath = FileUtils.dirPath(className)
209208
val classFile = new File(s"$dir/$relativePath.class")
210209
if (classFile.exists) {
211-
val wrappedClassFile = new scala.reflect.io.File(classFile)
210+
val wrappedClassFile = new dotty.tools.io.File(classFile)
212211
val abstractClassFile = new PlainFile(wrappedClassFile)
213212
Some(abstractClassFile)
214213
} else None
@@ -235,7 +234,7 @@ case class DirectorySourcePath(dir: File) extends JFileDirectoryLookup[SourceFil
235234
.collectFirst { case file if file.exists() => file }
236235

237236
sourceFile.map { file =>
238-
val wrappedSourceFile = new scala.reflect.io.File(file)
237+
val wrappedSourceFile = new dotty.tools.io.File(file)
239238
val abstractSourceFile = new PlainFile(wrappedSourceFile)
240239
abstractSourceFile
241240
}

0 commit comments

Comments
 (0)