From 2b04d2a96100fad5fc88b78b6b4094ae6ae25a37 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 5 Apr 2017 00:10:30 +0200 Subject: Fix #2186: Synchronize classpath handling with Scala 2.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit is a very crude port of the classpath handling as it exists in the 2.12.x branch of scalac (hash: 232d95a198c94da0c6c8393624e83e9b9ac84e81), this replaces the existing Classpath code that was adapted from scalac years ago. This code was written by Grzegorz Kossakowski, MichaƂ Pociecha, Lukas Rytz, Jason Zaugg and other scalac contributors, many thanks to them! For more information on this implementation, see the description of the PR that originally added it to scalac: https://github.com/scala/scala/pull/4060 Changes made to the copied code to get it to compile with dotty: - Rename scala.tools.nsc.util.ClassPath to dotty.tools.io.ClassPath - Rename scala.tools.nsc.classpath.* to dotty.tools.dotc.classpath.* - Replace "private[nsc]" by "private[dotty]" - Changed `isClass` methods in FileUtils to skip Scala 2.11 implementation classes (needed until we stop being retro-compatible with Scala 2.11) I also copied PlainFile.scala from scalac to get access to `PlainNioFile`. --- compiler/src/dotty/tools/dotc/config/JavaPlatform.scala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/config/JavaPlatform.scala') diff --git a/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala b/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala index 8bc18c387..d2a8e18a2 100644 --- a/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala +++ b/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala @@ -2,8 +2,8 @@ package dotty.tools package dotc package config -import io.{AbstractFile,ClassPath,JavaClassPath,MergedClassPath,DeltaClassPath} -import ClassPath.{ JavaContext, DefaultJavaContext } +import io._ +import classpath.AggregateClassPath import core._ import Symbols._, Types._, Contexts._, Denotations._, SymDenotations._, StdNames._, Names._ import Flags._, Scopes._, Decorators._, NameOps._, util.Positions._ @@ -11,7 +11,7 @@ import transform.ExplicitOuter, transform.SymUtils._ class JavaPlatform extends Platform { - private var currentClassPath: Option[MergedClassPath] = None + private var currentClassPath: Option[ClassPath] = None def classPath(implicit ctx: Context): ClassPath = { if (currentClassPath.isEmpty) @@ -35,8 +35,12 @@ class JavaPlatform extends Platform { } /** Update classpath with a substituted subentry */ - def updateClassPath(subst: Map[ClassPath, ClassPath]) = - currentClassPath = Some(new DeltaClassPath(currentClassPath.get, subst)) + def updateClassPath(subst: Map[ClassPath, ClassPath]): Unit = currentClassPath.get match { + case AggregateClassPath(entries) => + currentClassPath = Some(AggregateClassPath(entries map (e => subst.getOrElse(e, e)))) + case cp: ClassPath => + currentClassPath = Some(subst.getOrElse(cp, cp)) + } def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader = new ctx.base.loaders.PackageLoader(root, classPath) -- cgit v1.2.3