Skip to content

REPL: extract into separate subproject #18536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tags

# sbt specific
dist/*
dist/target
target/
lib_managed/
src_managed/
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ val `scala3-compiler-bootstrapped` = Build.`scala3-compiler-bootstrapped`
val `scala3-library` = Build.`scala3-library`
val `scala3-library-bootstrapped` = Build.`scala3-library-bootstrapped`
val `scala3-library-bootstrappedJS` = Build.`scala3-library-bootstrappedJS`
val `scala3-repl` = Build.`scala3-repl`
val `scala3-sbt-bridge` = Build.`scala3-sbt-bridge`
val `scala3-sbt-bridge-tests` = Build.`scala3-sbt-bridge-tests`
val `scala3-staging` = Build.`scala3-staging`
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/quoted/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import dotty.tools.dotc.quoted._
import dotty.tools.dotc.typer.ImportInfo.withRootImports
import dotty.tools.dotc.util.SrcPos
import dotty.tools.dotc.reporting.Message
import dotty.tools.repl.AbstractFileClassLoader
import dotty.tools.dotc.core.CyclicReference
import dotty.tools.io.AbstractFileClassLoader

/** Tree interpreter for metaprogramming constructs */
class Interpreter(pos: SrcPos, classLoader0: ClassLoader)(using Context):
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Splicer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import dotty.tools.dotc.quoted.Interpreter

import scala.util.control.NonFatal
import dotty.tools.dotc.util.SrcPos
import dotty.tools.repl.AbstractFileClassLoader

import scala.reflect.ClassTag

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.language.unsafeNulls
import java.net.URLClassLoader
import java.nio.file.Paths

import dotty.tools.repl.AbstractFileClassLoader
import dotty.tools.io.AbstractFileClassLoader

object ClasspathFromClassloader {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

package dotty.tools
package repl
package io

import scala.language.unsafeNulls

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package dotty.tools.repl
package dotty.tools
package io

import scala.language.unsafeNulls

Expand Down
4 changes: 4 additions & 0 deletions dist/bin/common
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ TASTY_CORE=$(find_lib "*tasty-core*")
SCALA_ASM=$(find_lib "*scala-asm*")
SCALA_LIB=$(find_lib "*scala-library*")
SBT_INTF=$(find_lib "*compiler-interface*")
DOTTY_DIST=$(find_lib "*scala3-dist*")
DOTTY_REPL=$(find_lib "*scala3-repl*")
JLINE_READER=$(find_lib "*jline-reader-3*")
JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
Expand All @@ -182,6 +184,8 @@ compilerJavaClasspathArgs () {
toolchain+="$TASTY_CORE$PSEP"
toolchain+="$DOTTY_STAGING$PSEP"
toolchain+="$DOTTY_TASTY_INSPECTOR$PSEP"
toolchain+="$DOTTY_DIST$PSEP"
toolchain+="$DOTTY_REPL$PSEP"

# jine
toolchain+="$JLINE_READER$PSEP"
Expand Down
2 changes: 2 additions & 0 deletions dist/bin/common.bat
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*tasty-core*"') do
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-asm*"') do set "_SCALA_ASM=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala-library*"') do set "_SCALA_LIB=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*compiler-interface*"') do set "_SBT_INTF=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala3-dist*"') do set "_SCALA3_DIST=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*scala3-repl*"') do set "_SCALA3_REPL=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-reader-3*"') do set "_JLINE_READER=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-terminal-3*"') do set "_JLINE_TERMINAL=%_LIB_DIR%\%%f"
for /f "delims=" %%f in ('dir /a-d /b "%_LIB_DIR%\*jline-terminal-jna-3*"') do set "_JLINE_TERMINAL_JNA=%_LIB_DIR%\%%f"
Expand Down
2 changes: 2 additions & 0 deletions dist/bin/scala.bat
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_COMP%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_TASTY_CORE%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_STAGING%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_TASTY_INSPECTOR%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_DIST%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_REPL%%_PSEP%"

@rem # jline
set "__TOOLCHAIN=%__TOOLCHAIN%%_JLINE_READER%%_PSEP%"
Expand Down
2 changes: 2 additions & 0 deletions dist/bin/scalac.bat
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_COMP%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_TASTY_CORE%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_STAGING%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_TASTY_INSPECTOR%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_DIST%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_REPL%%_PSEP%"

@rem # jline
set "__TOOLCHAIN=%__TOOLCHAIN%%_JLINE_READER%%_PSEP%"
Expand Down
2 changes: 2 additions & 0 deletions dist/bin/scaladoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ classpathArgs () {
CLASS_PATH+="$(find_lib "*scala3-library*")$PSEP"
CLASS_PATH+="$(find_lib "*tasty-core*")$PSEP"
CLASS_PATH+="$(find_lib "*scala3-tasty-inspector*")$PSEP"
CLASS_PATH+="$(find_lib "*scala3-repl*")$PSEP"
CLASS_PATH+="$(find_lib "*scala3-dist*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-0*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark*")$PSEP"
CLASS_PATH+="$(find_lib "*flexmark-ext-anchorlink*")$PSEP"
Expand Down
2 changes: 2 additions & 0 deletions dist/bin/scaladoc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ call :updateClasspath "scala3-interfaces"
call :updateClasspath "scala3-library"
call :updateClasspath "tasty-core"
call :updateClasspath "scala3-tasty-inspector"
call :updateClasspath "scala3-repl"
call :updateClasspath "scala3-dist"
call :updateClasspath "flexmark-0"
call :updateClasspath "flexmark-html-parser"
call :updateClasspath "flexmark-ext-anchorlink"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import dotty.tools.io.Jar
import dotty.tools.runner.ScalaClassLoader
import java.nio.file.Paths
import dotty.tools.dotc.config.CommandLineParser
import dotty.tools.repl
import dotty.tools.scripting
import dotty.tools.scripting.StringDriver

enum CompileMode:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import dotty.tools.io.Jar
import dotty.tools.runner.ScalaClassLoader
import java.nio.file.Paths
import dotty.tools.dotc.config.CommandLineParser
import dotty.tools.repl
import dotty.tools.scripting
import dotty.tools.scripting.{StringDriver, StringDriverException, ScriptingException}

enum ExecuteMode:
Expand Down
31 changes: 23 additions & 8 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,6 @@ object Build {
libraryDependencies ++= Seq(
"org.scala-lang.modules" % "scala-asm" % "9.5.0-scala-1", // used by the backend
Dependencies.compilerInterface,
"org.jline" % "jline-reader" % "3.19.0", // used by the REPL
"org.jline" % "jline-terminal" % "3.19.0",
"org.jline" % "jline-terminal-jna" % "3.19.0", // needed for Windows
("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
),

Expand Down Expand Up @@ -642,8 +639,6 @@ object Build {
"-Ddotty.tests.classes.compilerInterface=" + findArtifactPath(externalDeps, "compiler-interface"),
"-Ddotty.tests.classes.scalaLibrary=" + findArtifactPath(externalDeps, "scala-library"),
"-Ddotty.tests.classes.scalaAsm=" + findArtifactPath(externalDeps, "scala-asm"),
"-Ddotty.tests.classes.jlineTerminal=" + findArtifactPath(externalDeps, "jline-terminal"),
"-Ddotty.tests.classes.jlineReader=" + findArtifactPath(externalDeps, "jline-reader"),
)
},

Expand Down Expand Up @@ -896,6 +891,24 @@ object Build {
lazy val `scala3-library` = project.in(file("library")).asDottyLibrary(NonBootstrapped)
lazy val `scala3-library-bootstrapped`: Project = project.in(file("library")).asDottyLibrary(Bootstrapped)

lazy val `scala3-repl` = project.in(file("repl")).
asDottyLibrary(NonBootstrapped).
dependsOn(`scala3-compiler` % "compile->compile;test->test").
settings(
libraryDependencies ++= Seq(
"org.jline" % "jline-reader" % "3.19.0",
"org.jline" % "jline-terminal" % "3.19.0",
"org.jline" % "jline-terminal-jna" % "3.19.0", // needed for Windows
),
javaOptions ++= {
val externalDeps = externalCompilerClasspathTask.value
Seq(
"-Ddotty.tests.classes.jlineTerminal=" + findArtifactPath(externalDeps, "jline-terminal"),
"-Ddotty.tests.classes.jlineReader=" + findArtifactPath(externalDeps, "jline-reader"),
)
}
)

def dottyLibrary(implicit mode: Mode): Project = mode match {
case NonBootstrapped => `scala3-library`
case Bootstrapped => `scala3-library-bootstrapped`
Expand Down Expand Up @@ -954,6 +967,7 @@ object Build {
// when compiling a project that depends on scala3-staging (see sbt-test/sbt-dotty/quoted-example-project),
// but we always need it to be present on the JVM classpath at runtime.
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
dependsOn(`scala3-repl` % "test->test").
settings(
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value
)
Expand Down Expand Up @@ -1164,7 +1178,7 @@ object Build {
lazy val `scala3-sbt-bridge` = project.in(file("sbt-bridge/src")).
// We cannot depend on any bootstrapped project to compile the bridge, since the
// bridge is needed to compile these projects.
dependsOn(`scala3-compiler` % Provided).
dependsOn(`scala3-compiler` % Provided, `scala3-repl` % Provided).
settings(commonJavaSettings).
settings(
description := "sbt compiler bridge for Dotty",
Expand Down Expand Up @@ -1272,6 +1286,7 @@ object Build {

lazy val `scala3-language-server` = project.in(file("language-server")).
dependsOn(dottyCompiler(Bootstrapped)).
dependsOn(`scala3-repl`).
settings(commonBootstrappedSettings).
settings(
libraryDependencies ++= Seq(
Expand Down Expand Up @@ -1976,8 +1991,8 @@ object Build {
)

lazy val commonDistSettings = Seq(
name := "scala3-dist",
packMain := Map(),
publishArtifact := false,
packGenerateMakefile := false,
packExpandedClasspath := true,
packArchiveName := "scala3-" + dottyVersion
Expand Down Expand Up @@ -2076,7 +2091,7 @@ object Build {
def asDist(implicit mode: Mode): Project = project.
enablePlugins(PackPlugin).
withCommonSettings.
dependsOn(`scala3-interfaces`, dottyCompiler, dottyLibrary, tastyCore, `scala3-staging`, `scala3-tasty-inspector`, scaladoc).
dependsOn(`scala3-interfaces`, dottyCompiler, dottyLibrary, tastyCore, `scala3-staging`, `scala3-tasty-inspector`, `scala3-repl`, scaladoc).
settings(commonDistSettings).
bootstrappedSettings(
target := baseDirectory.value / "target" // override setting in commonBootstrappedSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package repl
import scala.language.unsafeNulls

import dotc.*, core.*
import dotty.tools.io.AbstractFileClassLoader
import Contexts.*, Denotations.*, Flags.*, NameOps.*, StdNames.*, Symbols.*
import printing.ReplPrinter
import reporting.Diagnostic
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import dotty.tools.dotc.interfaces.{SourceFile => ISourceFile}
import dotty.tools.dotc.reporting.{ Diagnostic, StoreReporter }
import dotty.tools.dotc.parsing.Parsers.Parser
import dotty.tools.dotc.{ Compiler, Run }
import dotty.tools.io.{AbstractFile, VirtualDirectory}
import dotty.tools.repl.AbstractFileClassLoader
import dotty.tools.io.{AbstractFile, AbstractFileClassLoader, VirtualDirectory}
import dotty.tools.dotc.util.Spans._
import dotty.tools.dotc.interfaces.Diagnostic._
import dotty.tools.dotc.util.{ SourcePosition, NoSourcePosition, SourceFile, NoSource }
Expand Down
3 changes: 1 addition & 2 deletions staging/src/scala/quoted/staging/QuoteDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.Driver
import dotty.tools.dotc.core.Contexts.{Context, ContextBase, FreshContext}
import dotty.tools.dotc.quoted.QuotesCache
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory, VirtualDirectory}
import dotty.tools.repl.AbstractFileClassLoader
import dotty.tools.io.{AbstractFile, AbstractFileClassLoader, Directory, PlainDirectory, VirtualDirectory}
import dotty.tools.dotc.reporting._
import dotty.tools.dotc.util.ClasspathFromClassloader
import scala.quoted._
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-with-compiler-cc/dotc/quoted/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import dotty.tools.dotc.transform.TreeMapWithStages._
import dotty.tools.dotc.typer.ImportInfo.withRootImports
import dotty.tools.dotc.util.SrcPos
import dotty.tools.dotc.reporting.Message
import dotty.tools.repl.AbstractFileClassLoader
import dotty.tools.io.AbstractFileClassLoader

/** Tree interpreter for metaprogramming constructs */
abstract class Interpreter(pos: SrcPos, classLoader: ClassLoader)(using DetachedContext):
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-with-compiler-cc/dotc/transform/Splicer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import dotty.tools.dotc.quoted.Interpreter

import scala.util.control.NonFatal
import dotty.tools.dotc.util.SrcPos
import dotty.tools.repl.AbstractFileClassLoader
import dotty.tools.io.AbstractFileClassLoader

import scala.reflect.ClassTag

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.language.unsafeNulls
import java.net.URLClassLoader
import java.nio.file.Paths

import dotty.tools.repl.AbstractFileClassLoader
import dotty.tools.io.AbstractFileClassLoader

object ClasspathFromClassloader {

Expand Down