From 74fadfea451b318fda4d2cc41d91224b8e23f447 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 25 Sep 2018 17:00:17 -0500 Subject: [PATCH] Fix the IDE always crashing due to an incorrect cast under Java 9+ --- .../tools/dotc/interactive/InteractiveDriver.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala index 895b8c4f9318..e7f432107829 100644 --- a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala +++ b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala @@ -119,10 +119,14 @@ class InteractiveDriver(val settings: List[String]) extends Driver { private val (zipClassPaths, dirClassPaths) = currentCtx.platform.classPath(currentCtx) match { case AggregateClassPath(cps) => - val (zipCps, dirCps) = cps.partition(_.isInstanceOf[ZipArchiveFileLookup[_]]) - // This will be wrong if any other subclass of ClassPath is either used, - // like `JrtClassPath` once we get Java 9 support - (zipCps.asInstanceOf[Seq[ZipArchiveFileLookup[_]]], dirCps.asInstanceOf[Seq[JFileDirectoryLookup[_]]]) + // FIXME: We shouldn't assume that ClassPath doesn't have other + // subclasses. For now, the only other subclass is JrtClassPath on Java + // 9+, we can safely ignore it for now because it's only used for the + // standard Java library, but this will change once we start supporting + // adding entries to the modulepath. + val zipCps = cps.collect { case cp: ZipArchiveFileLookup[_] => cp } + val dirCps = cps.collect { case cp: JFileDirectoryLookup[_] => cp } + (zipCps, dirCps) case _ => (Seq(), Seq()) }