From 5cfb270a4182a21ae85781b7fff96536f0ac7391 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sun, 17 Sep 2017 22:44:58 +0200 Subject: [PATCH 1/8] Incorrect Java version check The dotty implementation of Properties.isJavaAtLeast is broken for Java 9 (Fixed in Scalac at https://github.com/scala/scala/pull/5276, but maybe we just shouldn't have a copy of Properties.scala in Dotty). The test is useless now anyway since we only compile with 2.12 which requires Java 8, so this code is never going to run on an older version of the JVM. --- .../dotty/tools/dotc/config/CompilerCommand.scala | 3 --- .../src/dotty/tools/dotc/config/Properties.scala | 15 --------------- 2 files changed, 18 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala index 383c2aa9b906..81b4bdade5bf 100644 --- a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala +++ b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala @@ -137,9 +137,6 @@ object CompilerCommand { else if (settings.version.value) { ctx.echo(versionMsg) Nil - } else if (!Properties.isJavaAtLeast("1.8")) { - ctx.error("Dotty requires Java 8 to run") - Nil } else if (shouldStopWithInfo) { ctx.echo(infoMessage) diff --git a/compiler/src/dotty/tools/dotc/config/Properties.scala b/compiler/src/dotty/tools/dotc/config/Properties.scala index 9122272d588e..a4523f5d4633 100644 --- a/compiler/src/dotty/tools/dotc/config/Properties.scala +++ b/compiler/src/dotty/tools/dotc/config/Properties.scala @@ -131,19 +131,4 @@ trait PropertiesTrait { def versionMsg = "Scala %s %s -- %s".format(propCategory, versionString, copyrightString) def scalaCmd = if (isWin) "dotr.bat" else "dotr" def scalacCmd = if (isWin) "dotc.bat" else "dotc" - - /** Can the java version be determined to be at least as high as the argument? - * Hard to properly future proof this but at the rate 1.7 is going we can leave - * the issue for our cyborg grandchildren to solve. - */ - def isJavaAtLeast(version: String) = { - val okVersions = version match { - case "1.5" => List("1.5", "1.6", "1.7", "1.8") - case "1.6" => List("1.6", "1.7", "1.8") - case "1.7" => List("1.7", "1.8") - case "1.8" => List("1.8") - case _ => Nil - } - okVersions exists (javaVersion startsWith _) - } } From c58495d852bc1147d448179064a9775934037500 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sat, 25 Aug 2018 14:51:43 +0900 Subject: [PATCH 2/8] Upgrade backend for Java 9 support --- .gitmodules | 2 +- scala-backend | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index fcc2a9370cbb..ac706eb5cfd3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "scala-backend"] path = scala-backend url = https://github.com/lampepfl/scala.git - branch = sharing-backend + branch = fix-java9-itf [submodule "scala2-library"] path = scala2-library url = https://github.com/lampepfl/scala.git diff --git a/scala-backend b/scala-backend index 52a9b6af1440..3fe795094b92 160000 --- a/scala-backend +++ b/scala-backend @@ -1 +1 @@ -Subproject commit 52a9b6af1440cdfd92f54f56cbe3b4a911a3243d +Subproject commit 3fe795094b92920ffcbf3f1e2cdbfabc874ec555 From 1cd8cf3481b7136a39ff6ce979ef6eb14565e931 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sat, 25 Aug 2018 14:51:57 +0900 Subject: [PATCH 3/8] Stop using depcreated Class#newInstance --- compiler/src/dotty/tools/dotc/config/Settings.scala | 2 +- compiler/src/dotty/tools/dotc/plugins/Plugin.scala | 2 +- compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala | 2 +- compiler/src/dotty/tools/dotc/transform/Splicer.scala | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index eea07b26c906..35ed62aa6366 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -132,7 +132,7 @@ object Settings { case (BooleanTag, _) => update(true, args) case (OptionTag, _) => - update(Some(propertyClass.get.newInstance), args) + update(Some(propertyClass.get.getConstructor().newInstance()), args) case (ListTag, _) => if (argRest.isEmpty) missingArg else update((argRest split ",").toList, args) diff --git a/compiler/src/dotty/tools/dotc/plugins/Plugin.scala b/compiler/src/dotty/tools/dotc/plugins/Plugin.scala index 33a783c03259..585fae1c53e8 100644 --- a/compiler/src/dotty/tools/dotc/plugins/Plugin.scala +++ b/compiler/src/dotty/tools/dotc/plugins/Plugin.scala @@ -177,7 +177,7 @@ object Plugin { /** Instantiate a plugin class, given the class and * the compiler it is to be used in. */ - def instantiate(clazz: AnyClass): Plugin = clazz.newInstance.asInstanceOf[Plugin] + def instantiate(clazz: AnyClass): Plugin = clazz.getConstructor().newInstance().asInstanceOf[Plugin] } class PluginLoadException(val path: String, message: String, cause: Exception) extends Exception(message, cause) { diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala index 2052e0324823..d6f77ccc6063 100644 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala @@ -36,7 +36,7 @@ class QuoteDriver extends Driver { val clazz = classLoader.loadClass(driver.outputClassName.toString) val method = clazz.getMethod("apply") - val instance = clazz.newInstance() + val instance = clazz.getConstructor().newInstance() method.invoke(instance).asInstanceOf[T] } diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index c0a077e441b2..92de6ed118c1 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -125,7 +125,7 @@ object Splicer { } else { // nested object in an object val clazz = loadClass(sym.fullNameSeparated(FlatName)) - (clazz, clazz.newInstance().asInstanceOf[Object]) + (clazz, clazz.getConstructor().newInstance().asInstanceOf[Object]) } } From 9ff6f0930735ba7cf13d2c0b531d4c3bbb620e44 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sun, 17 Sep 2017 23:46:54 +0200 Subject: [PATCH 4/8] Resolve classes found in the jrt:/ filesystem The standard Java library as well as any other module used will not be available in the regular Java classpath but only in the jrt:/ filesystem. --- .../dotty/tools/dotc/config/PathResolver.scala | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/PathResolver.scala b/compiler/src/dotty/tools/dotc/config/PathResolver.scala index 48dc6deed65c..cb9abd70d236 100644 --- a/compiler/src/dotty/tools/dotc/config/PathResolver.scala +++ b/compiler/src/dotty/tools/dotc/config/PathResolver.scala @@ -5,7 +5,7 @@ package config import java.net.{ URL, MalformedURLException } import WrappedProperties.AccessControl import io.{ ClassPath, File, Directory, Path, AbstractFile } -import classpath.{AggregateClassPath, ClassPathFactory } +import classpath.{AggregateClassPath, ClassPathFactory, JrtClassPath } import ClassPath.{ JavaContext, join, split } import PartialFunction.condOpt import scala.language.postfixOps @@ -225,13 +225,14 @@ class PathResolver(implicit ctx: Context) { // priority class path takes precedence def basis = List[Traversable[ClassPath]]( classesInExpandedPath(priorityClassPath), // 0. The priority class path (for testing). - classesInPath(javaBootClassPath), // 1. The Java bootstrap class path. - contentsOfDirsInPath(javaExtDirs), // 2. The Java extension class path. - classesInExpandedPath(javaUserClassPath), // 3. The Java application class path. - classesInPath(scalaBootClassPath), // 4. The Scala boot class path. - contentsOfDirsInPath(scalaExtDirs), // 5. The Scala extension class path. - classesInExpandedPath(userClassPath), // 6. The Scala application class path. - sourcesInPath(sourcePath) // 7. The Scala source path. + JrtClassPath.apply(), // 1. The Java 9 classpath (backed by the jrt:/ virtual system, if available) + classesInPath(javaBootClassPath), // 2. The Java bootstrap class path. + contentsOfDirsInPath(javaExtDirs), // 3. The Java extension class path. + classesInExpandedPath(javaUserClassPath), // 4. The Java application class path. + classesInPath(scalaBootClassPath), // 5. The Scala boot class path. + contentsOfDirsInPath(scalaExtDirs), // 6. The Scala extension class path. + classesInExpandedPath(userClassPath), // 7. The Scala application class path. + sourcesInPath(sourcePath) // 8. The Scala source path. ) lazy val containers = basis.flatten.distinct From e9634deadb7ce46e670ed59cbf0cd3d74a59c911 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 24 Aug 2018 01:54:17 +0900 Subject: [PATCH 5/8] Fix crash when recording dependency information --- .../src/dotty/tools/dotc/sbt/ExtractDependencies.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala index 3e8698589771..553a04a12df4 100644 --- a/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala +++ b/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala @@ -127,7 +127,14 @@ class ExtractDependencies extends Phase { // We can recover the fully qualified name of a classfile from // its path val classSegments = pf.givenPath.segments.takeRight(packages + 1) - binaryDependency(pf.file, binaryClassName(classSegments)) + // FIXME: pf.file is null for classfiles coming from the modulepath + // (handled by JrtClassPath) because they cannot be represented as + // java.io.File, since the `binaryDependency` callback must take a + // java.io.File, this means that we cannot record dependencies coming + // from the modulepath. For now this isn't a big deal since we only + // support having the standard Java library on the modulepath. + if (pf.file != null) + binaryDependency(pf.file, binaryClassName(classSegments)) case _ => ctx.warning(s"sbt-deps: Ignoring dependency $depFile of class ${depFile.getClass}}") From 4d394f7bd5a94f254bb663b2b2671374506ddafd Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 23 Aug 2018 21:37:33 +0900 Subject: [PATCH 6/8] Stop using the bootclasspath for Java 9 compatibility It's no longer introspectable under Java 9. The scalac 2.12 shell scripts work around this by passing the bootclasspath jars as an additional system property, but we can avoid this complication by just using -classpath instead. This may have a slight negative impact on startup performance since the JVM bytecode verifier is not run for classes from the bootclasspath, but we can worry about that later. --- bench/src/main/scala/Benchmarks.scala | 2 +- compiler/test/dotty/Jars.scala | 9 +++--- dist/bin/dotc | 9 +----- project/Build.scala | 41 +++++++++++++-------------- 4 files changed, 27 insertions(+), 34 deletions(-) diff --git a/bench/src/main/scala/Benchmarks.scala b/bench/src/main/scala/Benchmarks.scala index 163ec80ca9bc..b3224e6ee97b 100644 --- a/bench/src/main/scala/Benchmarks.scala +++ b/bench/src/main/scala/Benchmarks.scala @@ -37,7 +37,7 @@ object Bench { val libs = System.getProperty("BENCH_CLASS_PATH") val opts = new OptionsBuilder() - .jvmArgsPrepend("-Xbootclasspath/a:" + libs + ":", "-Xms2G", "-Xmx2G") + .jvmArgsPrepend(s"-classpath $libs", "-Xms2G", "-Xmx2G") .mode(Mode.AverageTime) .timeUnit(TimeUnit.MILLISECONDS) .warmupIterations(warmup) diff --git a/compiler/test/dotty/Jars.scala b/compiler/test/dotty/Jars.scala index 2d0617ee3ecc..4805699ac452 100644 --- a/compiler/test/dotty/Jars.scala +++ b/compiler/test/dotty/Jars.scala @@ -2,6 +2,9 @@ package dotty /** Jars used when compiling test, normally set from the sbt build */ object Jars { + def scalaLibrary: String = sys.env.get("DOTTY_SCALA_LIBRARY") + .getOrElse(findJarFromRuntime("scala-library")) + /** Dotty library Jar */ val dottyLib: String = sys.env.get("DOTTY_LIB") .getOrElse(Properties.dottyLib) @@ -36,14 +39,12 @@ object Jars { /** Dotty test dependencies */ val dottyTestDeps: List[String] = - dottyLib :: dottyCompiler :: dottyInterfaces :: jlineTerminal :: jlineReader :: dottyExtras + scalaLibrary :: dottyLib :: dottyCompiler :: dottyInterfaces :: jlineTerminal :: jlineReader :: dottyExtras /** Dotty runtime with compiler dependencies, used for quoted.Expr.run */ lazy val dottyRunWithCompiler: List[String] = - dottyLib :: dottyCompiler :: dottyInterfaces :: scalaAsm :: Nil + scalaLibrary :: dottyLib :: dottyCompiler :: dottyInterfaces :: scalaAsm :: Nil - def scalaLibrary: String = sys.env.get("DOTTY_SCALA_LIBRARY") - .getOrElse(findJarFromRuntime("scala-library")) /** Gets the scala 2.* library at runtime, note that doing this is unsafe * unless you know that the library will be on the classpath of the running diff --git a/dist/bin/dotc b/dist/bin/dotc index 1724c93f9b22..70154e490511 100755 --- a/dist/bin/dotc +++ b/dist/bin/dotc @@ -28,7 +28,6 @@ fi source "$PROG_HOME/bin/common" default_java_opts="-Xmx768m -Xms768m" -bootcp=true withCompiler=true CompilerMain=dotty.tools.dotc.Main @@ -70,11 +69,7 @@ classpathArgs () { toolchain+="$JLINE_TERMINAL$PSEP" toolchain+="$JLINE_TERMINAL_JNA" - if [[ -n "$bootcp" ]]; then - jvm_cp_args="-Xbootclasspath/a:\"$toolchain\"" - else - jvm_cp_args="-classpath \"$toolchain\"" - fi + jvm_cp_args="-classpath \"$toolchain\"" } while [[ $# -gt 0 ]]; do @@ -92,8 +87,6 @@ case "$1" in -decompile) PROG_NAME="$DecompilerMain" && shift ;; -print-tasty) PROG_NAME="$DecompilerMain" && addScala "-print-tasty" && shift ;; -run) PROG_NAME="$ReplMain" && shift ;; - -bootcp) bootcp=true && shift ;; - -nobootcp) unset bootcp && shift ;; -colors) colors=true && shift ;; -no-colors) unset colors && shift ;; -with-compiler) jvm_cp_args="$PSEP$DOTTY_COMP" && shift ;; diff --git a/project/Build.scala b/project/Build.scala index 55d7242c8ec1..8a0433f6e1ce 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -223,9 +223,6 @@ object Build { // non-bootstrapped dotty-library that will then take priority over // the bootstrapped dotty-library on the classpath or sourcepath. classpathOptions ~= (_.withAutoBoot(false)), - // We still need a Scala bootclasspath equal to the JVM bootclasspath, - // otherwise sbt 0.13 incremental compilation breaks (https://github.com/sbt/sbt/issues/3142) - scalacOptions ++= Seq("-bootclasspath", sys.props("sun.boot.class.path")), // Enforce that the only Scala 2 classfiles we unpickle come from scala-library /* @@ -551,22 +548,22 @@ object Build { val attList = (dependencyClasspath in Runtime).value val jars = packageAll.value - // put needed dependencies on classpath: - val path = for { - file <- attList.map(_.data) - path = file.getAbsolutePath - // FIXME: when we snip the cord, this should go bye-bye - if path.contains("scala-library") || - // FIXME: currently needed for tests referencing scalac internals - path.contains("scala-reflect") || - // used for tests that compile xml - path.contains("scala-xml") || - // used for tests that compile dotty - path.contains("scala-asm") || - // needed for the xsbti interface - path.contains("compiler-interface") || - path.contains("util-interface") - } yield "-Xbootclasspath/p:" + path + // // put needed dependencies on classpath: + // val path = for { + // file <- attList.map(_.data) + // path = file.getAbsolutePath + // // FIXME: when we snip the cord, this should go bye-bye + // if path.contains("scala-library") || + // // FIXME: currently needed for tests referencing scalac internals + // path.contains("scala-reflect") || + // // used for tests that compile xml + // path.contains("scala-xml") || + // // used for tests that compile dotty + // path.contains("scala-asm") || + // // needed for the xsbti interface + // path.contains("compiler-interface") || + // path.contains("util-interface") + // } yield "-Xbootclasspath/p:" + path val ci_build = // propagate if this is a ci build sys.props.get("dotty.drone.mem") match { @@ -586,7 +583,7 @@ object Build { "-Ddotty.tests.classes.compiler=" + jars("dotty-compiler") ) - jarOpts ::: tuning ::: agentOptions ::: ci_build ::: path.toList + jarOpts ::: tuning ::: agentOptions ::: ci_build }, testCompilation := testOnlyFiltered("dotty.tools.dotc.*CompilationTests", "--exclude-categories=dotty.SlowTests").evaluated, @@ -661,7 +658,9 @@ object Build { ) def runCompilerMain(repl: Boolean = false) = Def.inputTaskDyn { + val attList = (dependencyClasspath in Runtime).value val jars = packageAll.value + val scalaLib = findLib(attList, "scala-library") val dottyLib = jars("dotty-library") val dottyCompiler = jars("dotty-compiler") val args0: List[String] = spaceDelimited("").parsed.toList @@ -677,7 +676,7 @@ object Build { else if (debugFromTasty) "dotty.tools.dotc.fromtasty.Debug" else "dotty.tools.dotc.Main" - var extraClasspath = dottyLib + var extraClasspath = s"$scalaLib:$dottyLib" if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += ":." if (args0.contains("-with-compiler")) { if (!isDotty.value) { From 58bc541efeb59bd1d3b089a8fb6af4d3ccabd4a7 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 24 Aug 2018 18:07:37 +0900 Subject: [PATCH 7/8] Adapt tests for Java 9 - scala-library and scala-xml used to be on the bootclasspath and need to be on the regular classpath now. - Jars.findJarFromRuntime relied on ClassLoader.getSystemClassLoader being an URLClassLoader, this isn't true anymore in Java 9. This is replaced by passing properties from the sbt build instead, like we were already doing for the dotty jars. While I was at it I completely killed dotty.Jars and cleaned things a bit. --- compiler/test/dotty/Jars.scala | 62 --------------- compiler/test/dotty/Properties.scala | 34 ++++++--- compiler/test/dotty/tools/DottyTest.scala | 4 +- .../tools/backend/jvm/DottyBytecodeTest.scala | 4 +- .../BootstrappedOnlyCompilationTests.scala | 76 +++++++++---------- .../dotty/tools/dotc/CompilationTests.scala | 7 +- .../tools/dotc/MissingCoreLibTests.scala | 4 +- .../test/dotty/tools/dotc/SettingsTests.scala | 11 +-- .../transform/PatmatExhaustivityTest.scala | 4 +- compiler/test/dotty/tools/repl/ReplTest.scala | 8 +- .../dotty/tools/vulpix/ParallelTesting.scala | 2 +- .../tools/vulpix/RunnerOrchestration.scala | 2 +- .../tools/vulpix/TestConfiguration.scala | 59 +++++++------- doc-tool/test/DottyDocTest.scala | 4 +- doc-tool/test/GenDocs.scala | 5 +- doc-tool/test/MarkdownTests.scala | 4 +- project/Build.scala | 12 ++- 17 files changed, 137 insertions(+), 165 deletions(-) delete mode 100644 compiler/test/dotty/Jars.scala diff --git a/compiler/test/dotty/Jars.scala b/compiler/test/dotty/Jars.scala deleted file mode 100644 index 4805699ac452..000000000000 --- a/compiler/test/dotty/Jars.scala +++ /dev/null @@ -1,62 +0,0 @@ -package dotty - -/** Jars used when compiling test, normally set from the sbt build */ -object Jars { - def scalaLibrary: String = sys.env.get("DOTTY_SCALA_LIBRARY") - .getOrElse(findJarFromRuntime("scala-library")) - - /** Dotty library Jar */ - val dottyLib: String = sys.env.get("DOTTY_LIB") - .getOrElse(Properties.dottyLib) - - /** Dotty Compiler Jar */ - val dottyCompiler: String = sys.env.get("DOTTY_COMPILER") - .getOrElse(Properties.dottyCompiler) - - /** Dotty Interfaces Jar */ - val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE") - .getOrElse(Properties.dottyInterfaces) - - /** Scala asm Jar */ - lazy val scalaAsm: String = - findJarFromRuntime("scala-asm-6.0.0-scala-1") - - /** scala-xml jar */ - lazy val scalaXml: String = - findJarFromRuntime("scala-xml") - - /** jline-terminal jar */ - lazy val jlineTerminal: String = - findJarFromRuntime("jline-terminal-3.9.0") - - /** jline-reader jar */ - lazy val jlineReader: String = - findJarFromRuntime("jline-reader-3.9.0") - - /** Dotty extras classpath from env or properties */ - val dottyExtras: List[String] = sys.env.get("DOTTY_EXTRAS") - .map(_.split(":").toList).getOrElse(Properties.dottyExtras) - - /** Dotty test dependencies */ - val dottyTestDeps: List[String] = - scalaLibrary :: dottyLib :: dottyCompiler :: dottyInterfaces :: jlineTerminal :: jlineReader :: dottyExtras - - /** Dotty runtime with compiler dependencies, used for quoted.Expr.run */ - lazy val dottyRunWithCompiler: List[String] = - scalaLibrary :: dottyLib :: dottyCompiler :: dottyInterfaces :: scalaAsm :: Nil - - - /** Gets the scala 2.* library at runtime, note that doing this is unsafe - * unless you know that the library will be on the classpath of the running - * application. It is currently safe to call this function if the tests are - * run by sbt. - */ - private def findJarFromRuntime(partialName: String) = { - val urls = ClassLoader.getSystemClassLoader.asInstanceOf[java.net.URLClassLoader].getURLs.map(_.getFile.toString) - urls.find(_.contains(partialName)).getOrElse { - throw new java.io.FileNotFoundException( - s"""Unable to locate $partialName on classpath:\n${urls.toList.mkString("\n")}""" - ) - } - } -} diff --git a/compiler/test/dotty/Properties.scala b/compiler/test/dotty/Properties.scala index 70db82092619..56ae72a26913 100644 --- a/compiler/test/dotty/Properties.scala +++ b/compiler/test/dotty/Properties.scala @@ -32,18 +32,30 @@ object Properties { */ val testsSafeMode: Boolean = sys.props.isDefinedAt("dotty.tests.safemode") - /** Dotty compiler path provided through define */ - def dottyCompiler: String = sys.props("dotty.tests.classes.compiler") + /** dotty-interfaces jar */ + def dottyInterfaces: String = sys.props("dotty.tests.classes.dottyInterfaces") - /** Dotty classpath extras provided through define */ - def dottyExtras: List[String] = - Option(sys.props("dotty.tests.extraclasspath")) - .map(_.split(":").toList) - .getOrElse(Nil) + /** dotty-library jar */ + def dottyLibrary: String = sys.props("dotty.tests.classes.dottyLibrary") - /** Dotty interfaces path provided through define */ - def dottyInterfaces: String = sys.props("dotty.tests.classes.interfaces") + /** dotty-compiler jar */ + def dottyCompiler: String = sys.props("dotty.tests.classes.dottyCompiler") - /** Dotty library path provided through define */ - def dottyLib: String = sys.props("dotty.tests.classes.library") + /** compiler-interface jar */ + def compilerInterface: String = sys.props("dotty.tests.classes.compilerInterface") + + /** scala-library jar */ + def scalaLibrary: String = sys.props("dotty.tests.classes.scalaLibrary") + + /** scala-asm jar */ + def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm") + + /** scala-xml jar */ + def scalaXml: String = sys.props("dotty.tests.classes.scalaXml") + + /** jline-terminal jar */ + def jlineTerminal: String = sys.props("dotty.tests.classes.jlineTerminal") + + /** jline-reader jar */ + def jlineReader: String = sys.props("dotty.tests.classes.jlineReader") } diff --git a/compiler/test/dotty/tools/DottyTest.scala b/compiler/test/dotty/tools/DottyTest.scala index 5b356e169567..54c8f4e1ad60 100644 --- a/compiler/test/dotty/tools/DottyTest.scala +++ b/compiler/test/dotty/tools/DottyTest.scala @@ -1,6 +1,8 @@ package dotty package tools +import vulpix.TestConfiguration + import dotc.core._ import dotc.core.Comments.{ContextDoc, ContextDocstrings} import dotc.core.Contexts._ @@ -39,7 +41,7 @@ trait DottyTest extends ContextEscapeDetection { protected def initializeCtx(fc: FreshContext): Unit = { fc.setSetting(fc.settings.encoding, "UTF8") - fc.setSetting(fc.settings.classpath, Jars.dottyLib) + fc.setSetting(fc.settings.classpath, TestConfiguration.basicClasspath) fc.setProperty(ContextDoc, new ContextDocstrings) } diff --git a/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala b/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala index b1848834ab9c..1c8648455c7e 100644 --- a/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala +++ b/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala @@ -2,6 +2,8 @@ package dotty package tools package backend.jvm +import vulpix.TestConfiguration + import dotc.core.Contexts.{Context, ContextBase} import dotc.core.Comments.{ContextDoc, ContextDocstrings} import dotc.core.Phases.Phase @@ -44,7 +46,7 @@ trait DottyBytecodeTest { def initCtx = { val ctx0 = (new ContextBase).initialCtx.fresh val outputDir = new VirtualDirectory("") - ctx0.setSetting(ctx0.settings.classpath, Jars.dottyLib) + ctx0.setSetting(ctx0.settings.classpath, TestConfiguration.basicClasspath) ctx0.setProperty(ContextDoc, new ContextDocstrings) ctx0.setSetting(ctx0.settings.outputDir, outputDir) } diff --git a/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala b/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala index d7f08cf20d8a..68f05e11881e 100644 --- a/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala @@ -33,24 +33,24 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting { @Test def posWithCompiler: Unit = { implicit val testGroup: TestGroup = TestGroup("compilePosWithCompiler") - compileFilesInDir("tests/pos-with-compiler", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/ast", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/config", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/core", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/transform", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/parsing", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/printing", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/reporting", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/typer", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/util", defaultOptions) + - compileDir("compiler/src/dotty/tools/io", defaultOptions) + - compileDir("compiler/src/dotty/tools/dotc/core", TestFlags(classPath, noCheckOptions)) + compileFilesInDir("tests/pos-with-compiler", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/ast", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/config", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/core", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/transform", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/parsing", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/printing", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/reporting", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/typer", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/util", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/io", withCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/core", withCompilerOptions) }.checkCompile() @Test def posTwiceWithCompiler: Unit = { implicit val testGroup: TestGroup = TestGroup("posTwiceWithCompiler") - compileFile("tests/pos-with-compiler/Labels.scala", defaultOptions) + - compileFile("tests/pos-with-compiler/Patterns.scala", defaultOptions) + + compileFile("tests/pos-with-compiler/Labels.scala", withCompilerOptions) + + compileFile("tests/pos-with-compiler/Patterns.scala", withCompilerOptions) + compileList( "testNonCyclic", List( @@ -58,7 +58,7 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting { "compiler/src/dotty/tools/dotc/core/Types.scala", "compiler/src/dotty/tools/dotc/ast/Trees.scala" ), - defaultOptions.and("-Xprompt") + withCompilerOptions ) + compileList( "testIssue34", @@ -66,7 +66,7 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting { "compiler/src/dotty/tools/dotc/config/Properties.scala", "compiler/src/dotty/tools/dotc/config/PathResolver.scala" ), - defaultOptions.and("-Xprompt") + withCompilerOptions ) }.times(2).checkCompile() @@ -74,15 +74,15 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting { @Test def negAll: Unit = { implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler") - compileFilesInDir("tests/neg-with-compiler", defaultOptions) + compileFilesInDir("tests/neg-with-compiler", withCompilerOptions) }.checkExpectedErrors() // Run tests ----------------------------------------------------------------- @Test def runWithCompiler: Unit = { implicit val testGroup: TestGroup = TestGroup("runWithCompiler") - compileFilesInDir("tests/run-with-compiler", defaultRunWithCompilerOptions) + - compileFile("tests/run-with-compiler-custom-args/staged-streams_1.scala", defaultRunWithCompilerOptions without "-Yno-deep-subtypes") + compileFilesInDir("tests/run-with-compiler", withCompilerOptions) + + compileFile("tests/run-with-compiler-custom-args/staged-streams_1.scala", withCompilerOptions without "-Yno-deep-subtypes") }.checkRuns() // Pickling Tests ------------------------------------------------------------ @@ -92,24 +92,24 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting { @Test def picklingWithCompiler: Unit = { implicit val testGroup: TestGroup = TestGroup("testPicklingWithCompiler") - compileDir("compiler/src/dotty/tools", picklingOptions, recursive = false) + - compileDir("compiler/src/dotty/tools/dotc", picklingOptions, recursive = false) + - compileDir("library/src/dotty/runtime", picklingOptions) + - compileDir("compiler/src/dotty/tools/backend/jvm", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/ast", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/core", picklingOptions, recursive = false) + - compileDir("compiler/src/dotty/tools/dotc/config", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/parsing", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/printing", picklingOptions) + - compileDir("compiler/src/dotty/tools/repl", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/rewrite", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/transform", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/typer", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/util", picklingOptions) + - compileDir("compiler/src/dotty/tools/io", picklingOptions) + - compileFile("tests/pos/pickleinf.scala", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/core/classfile", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/core/tasty", picklingOptions) + - compileDir("compiler/src/dotty/tools/dotc/core/unpickleScala2", picklingOptions) + compileDir("compiler/src/dotty/tools", picklingWithCompilerOptions, recursive = false) + + compileDir("compiler/src/dotty/tools/dotc", picklingWithCompilerOptions, recursive = false) + + compileDir("library/src/dotty/runtime", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/backend/jvm", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/ast", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/core", picklingWithCompilerOptions, recursive = false) + + compileDir("compiler/src/dotty/tools/dotc/config", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/parsing", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/printing", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/repl", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/rewrite", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/transform", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/typer", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/util", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/io", picklingWithCompilerOptions) + + compileFile("tests/pos/pickleinf.scala", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/core/classfile", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/core/tasty", picklingWithCompilerOptions) + + compileDir("compiler/src/dotty/tools/dotc/core/unpickleScala2", picklingWithCompilerOptions) }.limitThreads(4).checkCompile() } diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 5b2fc17e3c15..53af8e996140 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -204,8 +204,9 @@ class CompilationTests extends ParallelTesting { defaultOutputDir + libGroup + "/src/:" + // as well as bootstrapped compiler: defaultOutputDir + dotty1Group + "/dotty/:" + - // and the other compiler dependecies: - Jars.dottyInterfaces + ":" + Jars.jlineTerminal + ":" + Jars.jlineReader, + // and the other compiler dependenies: + Properties.compilerInterface + ":" + Properties.scalaLibrary + ":" + Properties.scalaAsm + ":" + + Properties.dottyInterfaces + ":" + Properties.jlineTerminal + ":" + Properties.jlineReader, Array("-Ycheck-reentrant", "-Yemit-tasty-in-class") ) @@ -277,7 +278,7 @@ class CompilationTests extends ParallelTesting { val compileDir = createOutputDirsForDir(dir, sourceDir, outDir) import java.nio.file.StandardCopyOption.REPLACE_EXISTING Files.copy(dir.toPath.resolve(pluginFile), compileDir.toPath.resolve(pluginFile), REPLACE_EXISTING) - val flags = TestFlags(classPath, noCheckOptions) and ("-Xplugin:" + compileDir.getAbsolutePath) + val flags = TestFlags(withCompilerClasspath, noCheckOptions) and ("-Xplugin:" + compileDir.getAbsolutePath) SeparateCompilationSource("testPlugins", dir, flags, compileDir) } diff --git a/compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala b/compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala index 24f4532a43c6..687e66100f1b 100644 --- a/compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala +++ b/compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala @@ -5,12 +5,12 @@ package dotc import org.junit.Test import org.junit.Assert._ -import vulpix.TestConfiguration.mkClassPath +import vulpix.TestConfiguration.mkClasspath class MissingCoreLibTests { @Test def missingDottyLib: Unit = { - val classPath = mkClassPath(Jars.dottyCompiler :: Jars.dottyInterfaces :: Jars.dottyExtras) // missing Jars.dottyLib + val classPath = mkClasspath(List(Properties.scalaLibrary)) // missing Properties.dottyLibrary val source = "tests/pos/Foo.scala" val options = Array("-classpath", classPath, source) val reporter = Main.process(options) diff --git a/compiler/test/dotty/tools/dotc/SettingsTests.scala b/compiler/test/dotty/tools/dotc/SettingsTests.scala index 3e0d8668a3c9..a48e14cfaaec 100644 --- a/compiler/test/dotty/tools/dotc/SettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/SettingsTests.scala @@ -1,12 +1,14 @@ -package dotty.tools.dotc +package dotty.tools +package dotc + +import vulpix.TestConfiguration import org.junit.Test import org.junit.Assert._ import java.nio.file._ -import dotty.Jars -import dotty.tools.vulpix.TestConfiguration.mkClassPath +import dotty.tools.vulpix.TestConfiguration.mkClasspath class SettingsTests { @@ -18,11 +20,10 @@ class SettingsTests { } @Test def jarOutput: Unit = { - val classPath = mkClassPath(Jars.dottyTestDeps) val source = "tests/pos/Foo.scala" val out = Paths.get("out/jaredFoo.jar").normalize if (Files.exists(out)) Files.delete(out) - val options = Array("-classpath", classPath, "-d", out.toString, source) + val options = Array("-classpath", TestConfiguration.basicClasspath, "-d", out.toString, source) val reporter = Main.process(options) assertEquals(0, reporter.errorCount) assertTrue(Files.exists(out)) diff --git a/compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala b/compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala index 53c6e0c53238..8fb80462951f 100644 --- a/compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala +++ b/compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala @@ -3,6 +3,8 @@ package tools package dotc package transform +import vulpix.TestConfiguration + import java.io._ import java.nio.file.{Path => JPath} @@ -15,7 +17,7 @@ import vulpix.TestConfiguration class PatmatExhaustivityTest { val testsDir = "tests/patmat" // stop-after: patmatexhaust-huge.scala crash compiler - val options = List("-color:never", "-Ystop-after:splitter", "-Ycheck-all-patmat", "-classpath", TestConfiguration.classPath) + val options = List("-color:never", "-Ystop-after:splitter", "-Ycheck-all-patmat", "-classpath", TestConfiguration.basicClasspath) private def compileFile(path: JPath) = { val stringBuffer = new StringWriter() diff --git a/compiler/test/dotty/tools/repl/ReplTest.scala b/compiler/test/dotty/tools/repl/ReplTest.scala index 0baeab61399c..a849da598ef3 100644 --- a/compiler/test/dotty/tools/repl/ReplTest.scala +++ b/compiler/test/dotty/tools/repl/ReplTest.scala @@ -1,14 +1,16 @@ -package dotty.tools.repl +package dotty.tools +package repl + +import vulpix.TestConfiguration import java.io.{ByteArrayOutputStream, PrintStream} -import dotty.Jars import dotty.tools.dotc.reporting.MessageRendering import org.junit.{After, Before} class ReplTest private (out: ByteArrayOutputStream) extends ReplDriver( - Array("-classpath", List(Jars.dottyLib, Jars.dottyInterfaces).mkString(":"), "-color:never"), + Array("-classpath", TestConfiguration.basicClasspath, "-color:never"), new PrintStream(out) ) with MessageRendering { diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala index 65d46e5d7bda..651cbe8073f9 100644 --- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala +++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala @@ -346,7 +346,7 @@ trait ParallelTesting extends RunnerOrchestration { self => "javac", "-encoding", "UTF-8", "-classpath", - s"${Jars.scalaLibrary}:${targetDir.getAbsolutePath}" + s"${Properties.scalaLibrary}:${targetDir.getAbsolutePath}" ) ++ flags.all.takeRight(2) ++ fs val process = Runtime.getRuntime.exec(fullArgs) diff --git a/compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala b/compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala index 767e92fc584e..f8c2569a55dc 100644 --- a/compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala +++ b/compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala @@ -159,7 +159,7 @@ trait RunnerOrchestration { val sep = sys.props("file.separator") val cp = classOf[ChildJVMMain].getProtectionDomain.getCodeSource.getLocation.getFile + ":" + - Jars.scalaLibrary + Properties.scalaLibrary val javaBin = sys.props("java.home") + sep + "bin" + sep + "java" new ProcessBuilder(javaBin, "-Xmx1g", "-cp", cp, "dotty.tools.vulpix.ChildJVMMain") .redirectErrorStream(true) diff --git a/compiler/test/dotty/tools/vulpix/TestConfiguration.scala b/compiler/test/dotty/tools/vulpix/TestConfiguration.scala index 995bc4a7593f..facd9f7ddc75 100644 --- a/compiler/test/dotty/tools/vulpix/TestConfiguration.scala +++ b/compiler/test/dotty/tools/vulpix/TestConfiguration.scala @@ -2,6 +2,8 @@ package dotty package tools package vulpix +import java.io.File + object TestConfiguration { val noCheckOptions = Array( @@ -10,47 +12,44 @@ object TestConfiguration { ) val checkOptions = Array( - // "-Yscala2-unpickler", s"${Jars.scalaLibrary}:${Jars.scalaXml}", + // "-Yscala2-unpickler", s"${Properties.scalaLibrary}:${Properties.scalaXml}", "-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-Xverify-signatures" ) - val classPath = mkClassPath(Jars.dottyTestDeps) - val runClassPath = mkClassPath(Jars.dottyLib :: Nil) + val basicClasspath = mkClasspath(List( + Properties.scalaLibrary, + Properties.scalaXml, + Properties.dottyLibrary + )) + + val withCompilerClasspath = mkClasspath(List( + Properties.scalaLibrary, + Properties.scalaXml, + Properties.scalaAsm, + Properties.jlineTerminal, + Properties.jlineReader, + Properties.compilerInterface, + Properties.dottyInterfaces, + Properties.dottyLibrary, + Properties.dottyCompiler + )) - def mkClassPath(classPaths: List[String]): String = { - classPaths map { p => + def mkClasspath(classpaths: List[String]): String = + classpaths.map({ p => val file = new java.io.File(p) - assert( - file.exists, - s"""|File "$p" couldn't be found. Run `packageAll` from build tool before - |testing. - | - |If running without sbt, test paths need to be setup environment variables: - | - | - DOTTY_LIBRARY - | - DOTTY_COMPILER - | - DOTTY_INTERFACES - | - DOTTY_EXTRAS - | - |Where these all contain locations, except extras which is a colon - |separated list of jars. - | - |When compiling with eclipse, you need the sbt-interfaces jar, put - |it in extras.""" - ) + assert(file.exists, s"File $p couldn't be found.") file.getAbsolutePath - } mkString(":") - } + }).mkString(File.pathSeparator) - // Ideally should be Ycheck:all val yCheckOptions = Array("-Ycheck:all") - val basicDefaultOptions = checkOptions ++ noCheckOptions ++ yCheckOptions - val defaultOptions = TestFlags(classPath, runClassPath, basicDefaultOptions) - val defaultRunWithCompilerOptions = defaultOptions.withRunClasspath(Jars.dottyRunWithCompiler.mkString(":")) + val commonOptions = checkOptions ++ noCheckOptions ++ yCheckOptions + val defaultOptions = TestFlags(basicClasspath, commonOptions) + val withCompilerOptions = + defaultOptions.withClasspath(withCompilerClasspath).withRunClasspath(withCompilerClasspath) val allowDeepSubtypes = defaultOptions without "-Yno-deep-subtypes" val allowDoubleBindings = defaultOptions without "-Yno-double-bindings" val picklingOptions = defaultOptions and ( @@ -59,6 +58,8 @@ object TestConfiguration { "-Yprint-pos", "-Yprint-pos-syms" ) + val picklingWithCompilerOptions = + picklingOptions.withClasspath(withCompilerClasspath).withRunClasspath(withCompilerClasspath) val scala2Mode = defaultOptions and "-language:Scala2" val explicitUTF8 = defaultOptions and ("-encoding", "UTF8") val explicitUTF16 = defaultOptions and ("-encoding", "UTF16") diff --git a/doc-tool/test/DottyDocTest.scala b/doc-tool/test/DottyDocTest.scala index 30c7ec2cbf79..c950af38d143 100644 --- a/doc-tool/test/DottyDocTest.scala +++ b/doc-tool/test/DottyDocTest.scala @@ -1,6 +1,8 @@ package dotty.tools package dottydoc +import vulpix.TestConfiguration + import dotc.core.Contexts.{ Context, ContextBase, FreshContext } import dotc.core.Comments.{ ContextDoc, ContextDocstrings } import dotc.util.SourceFile @@ -30,7 +32,7 @@ trait DottyDocTest extends MessageRendering { ctx.setProperty(ContextDoc, new ContextDottydoc) ctx.setSetting( ctx.settings.classpath, - dotty.Jars.dottyLib + TestConfiguration.basicClasspath ) ctx.setReporter(new StoreReporter(ctx.reporter)) base.initialize()(ctx) diff --git a/doc-tool/test/GenDocs.scala b/doc-tool/test/GenDocs.scala index 942347975c3e..78b0a6f89294 100644 --- a/doc-tool/test/GenDocs.scala +++ b/doc-tool/test/GenDocs.scala @@ -1,6 +1,8 @@ package dotty.tools package dottydoc +import vulpix.TestConfiguration + object Files { type JFile = java.io.File @@ -11,7 +13,6 @@ object Files { trait LocalResources extends DocDriver { import Files._ - import dotty.Jars def getFiles(file: JFile): Array[JFile] = if (file.isDirectory) file.listFiles.flatMap(getFiles) @@ -23,7 +24,7 @@ trait LocalResources extends DocDriver { "-project" +: "Dotty" +: "-language:Scala2" +: "-classpath" +: - (Jars.dottyLib + ":" + Jars.dottyInterfaces) +: + TestConfiguration.basicClasspath +: files } diff --git a/doc-tool/test/MarkdownTests.scala b/doc-tool/test/MarkdownTests.scala index 5d392ada1379..98ed3085a0a7 100644 --- a/doc-tool/test/MarkdownTests.scala +++ b/doc-tool/test/MarkdownTests.scala @@ -1,6 +1,8 @@ package dotty.tools package dottydoc +import vulpix.TestConfiguration + import org.junit.Test import org.junit.Assert._ @@ -22,7 +24,7 @@ class MarkdownTests extends DottyDocTest { ctx.setProperty(ContextDoc, new ContextDottydoc) ctx.setSetting( ctx.settings.classpath, - dotty.Jars.dottyLib + TestConfiguration.basicClasspath ) base.initialize()(ctx) ctx diff --git a/project/Build.scala b/project/Build.scala index 8a0433f6e1ce..c6b375dbcd9b 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -578,9 +578,15 @@ object Build { else List() val jarOpts = List( - "-Ddotty.tests.classes.interfaces=" + jars("dotty-interfaces"), - "-Ddotty.tests.classes.library=" + jars("dotty-library"), - "-Ddotty.tests.classes.compiler=" + jars("dotty-compiler") + "-Ddotty.tests.classes.dottyInterfaces=" + jars("dotty-interfaces"), + "-Ddotty.tests.classes.dottyLibrary=" + jars("dotty-library"), + "-Ddotty.tests.classes.dottyCompiler=" + jars("dotty-compiler"), + "-Ddotty.tests.classes.compilerInterface=" + findLib(attList, "compiler-interface"), + "-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library"), + "-Ddotty.tests.classes.scalaAsm=" + findLib(attList, "scala-asm"), + "-Ddotty.tests.classes.scalaXml=" + findLib(attList, "scala-xml"), + "-Ddotty.tests.classes.jlineTerminal=" + findLib(attList, "jline-terminal"), + "-Ddotty.tests.classes.jlineReader=" + findLib(attList, "jline-reader") ) jarOpts ::: tuning ::: agentOptions ::: ci_build From 5061c29128bea03f771e03d8181d02ef46fa3d28 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 24 Aug 2018 18:54:01 +0900 Subject: [PATCH 8/8] Remove broken special case when typing annotations This broke tests/pos/t2484.scala with Java 9 and doesn't seem to actually be useful for anything. --- compiler/src/dotty/tools/dotc/ast/tpd.scala | 34 ++----------------- .../dotty/tools/dotc/core/Annotations.scala | 2 +- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index f4f4535931c4..f2e4b3e14c84 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -980,7 +980,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { } } - def applyOverloaded(receiver: Tree, method: TermName, args: List[Tree], targs: List[Type], expectedType: Type, isAnnotConstructor: Boolean = false)(implicit ctx: Context): Tree = { + def applyOverloaded(receiver: Tree, method: TermName, args: List[Tree], targs: List[Type], expectedType: Type)(implicit ctx: Context): Tree = { val typer = ctx.typer val proto = new FunProtoTyped(args, expectedType)(typer) val denot = receiver.tpe.member(method) @@ -998,7 +998,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { assert(alternatives.size == 1, i"${if (alternatives.isEmpty) "no" else "multiple"} overloads available for " + i"$method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, % of types ${args.tpes}%, %; expectedType: $expectedType." + - i" isAnnotConstructor = $isAnnotConstructor.\n" + i"all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(", ")}\n" + i"matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(", ")}.") // this is parsed from bytecode tree. there's nothing user can do about it alternatives.head @@ -1008,35 +1007,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { .select(TermRef(receiver.tpe, selected.termSymbol.asTerm)) .appliedToTypes(targs) - def adaptLastArg(lastParam: Tree, expectedType: Type) = { - if (isAnnotConstructor && !(lastParam.tpe <:< expectedType)) { - val defn = ctx.definitions - val prefix = args.take(selected.widen.paramInfoss.head.size - 1) - expectedType match { - case defn.ArrayOf(el) => - lastParam.tpe match { - case defn.ArrayOf(el2) if el2 <:< el => - // we have a JavaSeqLiteral with a more precise type - // we cannot construct a tree as JavaSeqLiteral inferred to precise type - // if we add typed than it would be both type-correct and - // will pass Ycheck - prefix ::: List(tpd.Typed(lastParam, TypeTree(defn.ArrayOf(el)))) - case _ => - ??? - } - case _ => args - } - } else args - } - - val callArgs: List[Tree] = if (args.isEmpty) Nil else { - val expectedType = selected.widen.paramInfoss.head.last - val lastParam = args.last - adaptLastArg(lastParam, expectedType) - } - - val apply = untpd.Apply(fun, callArgs) - new typer.ApplyToTyped(apply, fun, selected, callArgs, expectedType).result.asInstanceOf[Tree] // needed to handle varargs + val apply = untpd.Apply(fun, args) + new typer.ApplyToTyped(apply, fun, selected, args, expectedType).result.asInstanceOf[Tree] // needed to handle varargs } @tailrec diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index ade035224780..48c18455e512 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -114,7 +114,7 @@ object Annotations { private def resolveConstructor(atp: Type, args:List[Tree])(implicit ctx: Context): Tree = { val targs = atp.argTypes - tpd.applyOverloaded(New(atp.typeConstructor), nme.CONSTRUCTOR, args, targs, atp, isAnnotConstructor = true) + tpd.applyOverloaded(New(atp.typeConstructor), nme.CONSTRUCTOR, args, targs, atp) } def applyResolve(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation = {