Skip to content

Commit

Permalink
Remove explicit casting
Browse files Browse the repository at this point in the history
At least the ugly casting is gone... Looks like other parts of zinc also relys on pattern matching instead of java style casting.
  • Loading branch information
Friendseeker committed Jan 2, 2024
1 parent cd376cb commit e7cb256
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

package xsbt

import xsbti.{ AnalysisCallback, AnalysisCallback3, PathBasedFile, Severity }
import xsbti.{AnalysisCallback, AnalysisCallback3, PathBasedFile, Severity, VirtualFileWrite}
import xsbti.compile._

import scala.tools.nsc._
import io.AbstractFile
import java.nio.file.{ Files, Path }
import java.nio.file.{Files, Path}
import scala.reflect.io.PlainFile
import scala.reflect.ReflectAccess._
import scala.reflect.internal.util.BatchSourceFile
Expand Down Expand Up @@ -79,10 +79,13 @@ sealed class ZincCompiler(settings: Settings, dreporter: DelegatingReporter, out
with ZincGlobalCompat {

override def getSourceFile(f: AbstractFile): BatchSourceFile = {
val file = f match {
case plainFile: PlainFile =>
val vf = callback.asInstanceOf[AnalysisCallback3].toVirtualFile(plainFile.file.toPath)
new ZincPlainFile(vf.asInstanceOf[PathBasedFile])
val file = (f, callback) match {
case (plainFile: PlainFile, callback3: AnalysisCallback3) =>
val virtualFile = callback3.toVirtualFile(plainFile.file.toPath)
virtualFile match {
case underlying: PathBasedFile => new ZincPlainFile(underlying)
case _ => f
}
case _ => f
}
super.getSourceFile(file)
Expand Down

0 comments on commit e7cb256

Please sign in to comment.