Skip to content

Commit 0402ce3

Browse files
committed
chore: drop shadding of repl dependencies
1 parent c05242b commit 0402ce3

27 files changed

+149
-205
lines changed

.github/workflows/stdlib.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,24 @@ jobs:
279279
- name: Compile `scala3-library` for Scala.js
280280
run: ./project/scripts/sbt scala3-library-sjs/compile
281281

282+
repl:
283+
runs-on: ubuntu-latest
284+
needs: [scala3-compiler-bootstrapped]
285+
steps:
286+
- name: Git Checkout
287+
uses: actions/checkout@v5
288+
289+
- name: Set up JDK 17
290+
uses: actions/setup-java@v5
291+
with:
292+
distribution: 'temurin'
293+
java-version: 17
294+
cache: 'sbt'
295+
- uses: sbt/setup-sbt@v1
296+
297+
- name: Compile REPL
298+
run: ./project/scripts/sbt scala3-repl/compile
299+
282300
scaladoc:
283301
runs-on: ubuntu-latest
284302
needs: [scala3-compiler-bootstrapped, scala3-tasty-inspector]
@@ -547,6 +565,23 @@ jobs:
547565
run: ./project/scripts/sbt ";sjsJUnitTests/clean ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToLatestESVersion ;set Global/enableWebAssembly := true; sjsJUnitTests/test"
548566
# TODO Scala.js on Windows
549567

568+
test-repl:
569+
runs-on: ubuntu-latest
570+
needs: [repl]
571+
steps:
572+
- name: Git Checkout
573+
uses: actions/checkout@v5
574+
575+
- name: Set up JDK 17
576+
uses: actions/setup-java@v5
577+
with:
578+
distribution: 'temurin'
579+
java-version: 17
580+
cache: 'sbt'
581+
- uses: sbt/setup-sbt@v1
582+
- name: Test REPL
583+
run: ./project/scripts/sbt scala3-repl/test
584+
550585
scripted-tests:
551586
runs-on: ubuntu-latest
552587
needs: [scala3-compiler-bootstrapped, tasty-core-bootstrapped, scala3-staging, scala3-tasty-inspector, scala-library-sjs, scaladoc]

compiler/test/dotty/Properties.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ object Properties {
6060
/** dotty-compiler jar */
6161
def dottyCompiler: String = sys.props("dotty.tests.classes.dottyCompiler")
6262

63+
/** dotty-repl jar */
64+
def dottyRepl: String = sys.props("dotty.tests.classes.dottyRepl")
65+
6366
/** dotty-staging jar */
6467
def dottyStaging: String = sys.props("dotty.tests.classes.dottyStaging")
6568

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,17 @@ class BootstrappedOnlyCompilationTests {
156156

157157
@Test def picklingWithCompiler: Unit = {
158158
implicit val testGroup: TestGroup = TestGroup("testPicklingWithCompiler")
159-
// Exclude this file from the test as it contains some changes that require scala 2.13.17
160-
// This filter can be dropped once we drop the dependency to Scala 2 (in 3.8.0)
161-
val rlibscala3 = FileFilter.exclude(List("ScalaRunTime.scala"))
162-
163159
aggregateTests(
164160
compileDir("compiler/src/dotty/tools", picklingWithCompilerOptions, recursive = false),
165161
compileDir("compiler/src/dotty/tools/dotc", picklingWithCompilerOptions, recursive = false),
166162
compileDir("library/src/scala/runtime/function", picklingWithCompilerOptions),
167-
compileFilesInDir("library/src/scala/runtime", picklingWithCompilerOptions, rlibscala3),
163+
compileFilesInDir("library/src/scala/runtime", picklingWithCompilerOptions),
168164
compileFilesInDir("compiler/src/dotty/tools/backend/jvm", picklingWithCompilerOptions),
169165
compileDir("compiler/src/dotty/tools/dotc/ast", picklingWithCompilerOptions),
170166
compileDir("compiler/src/dotty/tools/dotc/core", picklingWithCompilerOptions, recursive = false),
171167
compileDir("compiler/src/dotty/tools/dotc/config", picklingWithCompilerOptions),
172168
compileDir("compiler/src/dotty/tools/dotc/parsing", picklingWithCompilerOptions),
173169
compileDir("compiler/src/dotty/tools/dotc/printing", picklingWithCompilerOptions),
174-
compileDir("compiler/src/dotty/tools/repl", picklingWithCompilerOptions),
175170
compileDir("compiler/src/dotty/tools/dotc/rewrites", picklingWithCompilerOptions),
176171
compileDir("compiler/src/dotty/tools/dotc/transform", picklingWithCompilerOptions),
177172
compileDir("compiler/src/dotty/tools/dotc/typer", picklingWithCompilerOptions),

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ object TestConfiguration {
3434
val withCompilerClasspath = mkClasspath(List(
3535
Properties.scalaLibrary,
3636
Properties.scalaAsm,
37-
Properties.jlineTerminal,
38-
Properties.jlineReader,
3937
Properties.compilerInterface,
4038
Properties.dottyInterfaces,
4139
Properties.tastyCore,
@@ -54,6 +52,16 @@ object TestConfiguration {
5452
Properties.scalaJSLibrary,
5553
))
5654

55+
lazy val replClassPath =
56+
withCompilerClasspath + File.pathSeparator + mkClasspath(List(
57+
Properties.dottyRepl,
58+
Properties.jlineTerminal,
59+
Properties.jlineReader,
60+
))
61+
62+
lazy val replWithStagingClasspath =
63+
replClassPath + File.pathSeparator + mkClasspath(List(Properties.dottyStaging))
64+
5765
def mkClasspath(classpaths: List[String]): String =
5866
classpaths.map({ p =>
5967
val file = new java.io.File(p)
@@ -71,6 +79,8 @@ object TestConfiguration {
7179
val unindentOptions = TestFlags(basicClasspath, Array("-no-indent") ++ checkOptions ++ noCheckOptions ++ yCheckOptions)
7280
val withCompilerOptions =
7381
defaultOptions.withClasspath(withCompilerClasspath).withRunClasspath(withCompilerClasspath)
82+
val withReplOptions =
83+
defaultOptions.withRunClasspath(replClassPath)
7484
lazy val withStagingOptions =
7585
defaultOptions.withClasspath(withStagingClasspath).withRunClasspath(withStagingClasspath)
7686
lazy val withTastyInspectorOptions =

project/Build.scala

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,6 @@ object Build {
727727
("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
728728
),
729729

730-
(Compile / sourceGenerators) += ShadedSourceGenerator.task.taskValue,
731-
732730
// For convenience, change the baseDirectory when running the compiler
733731
Compile / forkOptions := (Compile / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
734732
Compile / run / forkOptions := (Compile / run / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
@@ -770,8 +768,6 @@ object Build {
770768
"-Ddotty.tests.classes.compilerInterface=" + findArtifactPath(externalDeps, "compiler-interface"),
771769
"-Ddotty.tests.classes.scalaLibrary=" + findArtifactPath(externalDeps, "scala-library"),
772770
"-Ddotty.tests.classes.scalaAsm=" + findArtifactPath(externalDeps, "scala-asm"),
773-
"-Ddotty.tests.classes.jlineTerminal=" + findArtifactPath(externalDeps, "jline-terminal"),
774-
"-Ddotty.tests.classes.jlineReader=" + findArtifactPath(externalDeps, "jline-reader"),
775771
)
776772
},
777773

@@ -1781,11 +1777,13 @@ object Build {
17811777
version := dottyVersion,
17821778
versionScheme := Some("semver-spec"),
17831779
scalaVersion := referenceVersion,
1784-
crossPaths := true, // org.scala-lang:scala3-tasty-inspector has a crosspath
1785-
autoScalaLibrary := false, // do not add a dependency to stdlib, we depend transitively on the stdlib from `scala3-compiler-bootstrapped`
1780+
crossPaths := true,
1781+
autoScalaLibrary := false,
17861782
// Add the source directories for the sbt-bridge (boostrapped)
1787-
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
1788-
Test / unmanagedSourceDirectories := Seq(baseDirectory.value / "test"),
1783+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
1784+
Compile / unmanagedResourceDirectories := Seq(baseDirectory.value / "resources"),
1785+
Test / unmanagedSourceDirectories := Seq(baseDirectory.value / "test"),
1786+
Test / unmanagedResourceDirectories := Seq(baseDirectory.value / "test-resources"),
17891787
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
17901788
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
17911789
// Make sure that the produced artifacts have the minimum JVM version in the bytecode
@@ -1799,6 +1797,12 @@ object Build {
17991797
Test / publishArtifact := false,
18001798
publish / skip := false,
18011799
libraryDependencies ++= Seq(
1800+
"org.jline" % "jline-reader" % "3.29.0",
1801+
"org.jline" % "jline-terminal" % "3.29.0",
1802+
"org.jline" % "jline-terminal-jni" % "3.29.0",
1803+
"com.lihaoyi" %% "pprint" % "0.9.3",
1804+
"com.lihaoyi" %% "fansi" % "0.5.1",
1805+
"com.lihaoyi" %% "sourcecode" % "0.4.4",
18021806
"com.github.sbt" % "junit-interface" % "0.13.3" % Test,
18031807
),
18041808
// Configure to use the non-bootstrapped compiler
@@ -1839,7 +1843,8 @@ object Build {
18391843
Seq(
18401844
s"-Ddotty.tests.dottyCompilerManagedSources=${managedSrcDir}",
18411845
s"-Ddotty.tests.classes.dottyInterfaces=${(`scala3-interfaces` / Compile / packageBin).value}",
1842-
s"-Ddotty.tests.classes.dottyCompiler=${(ThisProject / Compile / packageBin).value}",
1846+
s"-Ddotty.tests.classes.dottyCompiler=${(`scala3-compiler-bootstrapped-new` / Compile / packageBin).value}",
1847+
s"-Ddotty.tests.classes.dottyRepl=${(ThisProject / Compile / packageBin).value}",
18431848
s"-Ddotty.tests.classes.tastyCore=${(`tasty-core-bootstrapped-new` / Compile / packageBin).value}",
18441849
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
18451850
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-bootstrapped` / Compile / packageBin).value}",
@@ -1852,8 +1857,6 @@ object Build {
18521857
s"-Ddotty.tools.dotc.semanticdb.test=${(ThisBuild / baseDirectory).value/"tests"/"semanticdb"}",
18531858
)
18541859
},
1855-
Test / forkOptions :=
1856-
(Test / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
18571860
)
18581861

18591862
// ==============================================================================================
@@ -2416,9 +2419,6 @@ object Build {
24162419
"com.github.sbt" % "junit-interface" % "0.13.3" % Test,
24172420
"org.scala-lang.modules" % "scala-asm" % "9.8.0-scala-1",
24182421
Dependencies.compilerInterface,
2419-
"org.jline" % "jline-reader" % "3.29.0",
2420-
"org.jline" % "jline-terminal" % "3.29.0",
2421-
"org.jline" % "jline-terminal-jni" % "3.29.0",
24222422
("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
24232423
),
24242424
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
@@ -2462,7 +2462,6 @@ object Build {
24622462

24632463
Seq(file)
24642464
}.taskValue,
2465-
(Compile / sourceGenerators) += ShadedSourceGenerator.task.taskValue,
24662465
// sbt adds all the projects to scala-tool config which breaks building the scalaInstance
24672466
// as a workaround, I build it manually by only adding the compiler
24682467
managedScalaInstance := false,
@@ -2558,8 +2557,6 @@ object Build {
25582557
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
25592558
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-nonbootstrapped` / Compile / packageBin).value}",
25602559
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
2561-
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
2562-
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
25632560
s"-Ddotty.tools.dotc.semanticdb.test=${(ThisBuild / baseDirectory).value/"tests"/"semanticdb"}",
25642561
)
25652562
},
@@ -2589,9 +2586,6 @@ object Build {
25892586
libraryDependencies ++= Seq(
25902587
"org.scala-lang.modules" % "scala-asm" % "9.8.0-scala-1",
25912588
Dependencies.compilerInterface,
2592-
"org.jline" % "jline-reader" % "3.29.0",
2593-
"org.jline" % "jline-terminal" % "3.29.0",
2594-
"org.jline" % "jline-terminal-jni" % "3.29.0",
25952589
"com.github.sbt" % "junit-interface" % "0.13.3" % Test,
25962590
("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
25972591
),
@@ -2704,7 +2698,6 @@ object Build {
27042698
sjsSources
27052699
} (Set(scalaJSIRSourcesJar)).toSeq
27062700
}.taskValue,
2707-
(Compile / sourceGenerators) += ShadedSourceGenerator.task.taskValue,
27082701
Compile / run / forkOptions := (Compile / run / forkOptions).value
27092702
.withWorkingDirectory((ThisBuild / baseDirectory).value),
27102703
// Configuration of the test suite
@@ -2733,8 +2726,6 @@ object Build {
27332726
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-bootstrapped` / Compile / packageBin).value}",
27342727
s"-Ddotty.tests.classes.scalaJSScalalib=${(`scala-library-sjs` / Compile / packageBin).value}",
27352728
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
2736-
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
2737-
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
27382729
s"-Ddotty.tests.classes.dottyStaging=${(LocalProject("scala3-staging-new") / Compile / packageBin).value}",
27392730
s"-Ddotty.tests.classes.dottyTastyInspector=${(LocalProject("scala3-tasty-inspector-new") / Compile / packageBin).value}",
27402731
s"-Ddotty.tools.dotc.semanticdb.test=${(ThisBuild / baseDirectory).value/"tests"/"semanticdb"}",
@@ -3356,8 +3347,6 @@ object Build {
33563347
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
33573348
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-nonbootstrapped` / Compile / packageBin).value}",
33583349
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
3359-
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
3360-
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
33613350
s"-Ddotty.tools.dotc.semanticdb.test=${(ThisBuild / baseDirectory).value/"tests"/"semanticdb"}",
33623351
"-Ddotty.tests.classes.scalaJSScalalib=" + (`scala-library-sjs` / Compile / packageBin).value,
33633352
"-Ddotty.tests.classes.scalaJSJavalib=" + findArtifactPath(externalJSDeps, "scalajs-javalib"),

project/ShadedSourceGenerator.scala

Lines changed: 0 additions & 110 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
scala.tools.repl.ScriptEngine$Factory
1+
dotty.tools.repl.ScriptEngine$Factory

repl/src/dotty/tools/repl/Rendering.scala

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,9 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
2727
var myClassLoader: AbstractFileClassLoader = uninitialized
2828

2929
private def pprintRender(value: Any, width: Int, height: Int, initialOffset: Int)(using Context): String = {
30-
def fallback() =
31-
dotty.shaded.pprint.PPrinter.BlackWhite
32-
.apply(value, width = width, height = height, initialOffset = initialOffset)
33-
.plainText
34-
try
35-
val cl = classLoader()
36-
val pprintCls = Class.forName("dotty.shaded.pprint.PPrinter$BlackWhite$", false, cl)
37-
val fansiStrCls = Class.forName("dotty.shaded.fansi.Str", false, cl)
38-
val BlackWhite = pprintCls.getField("MODULE$").get(null)
39-
val BlackWhite_apply = pprintCls.getMethod("apply",
40-
classOf[Any], // value
41-
classOf[Int], // width
42-
classOf[Int], // height
43-
classOf[Int], // indentation
44-
classOf[Int], // initialOffset
45-
classOf[Boolean], // escape Unicode
46-
classOf[Boolean], // show field names
47-
)
48-
val FansiStr_plainText = fansiStrCls.getMethod("plainText")
49-
val fansiStr = BlackWhite_apply.invoke(
50-
BlackWhite, value, width, height, 2, initialOffset, false, true
51-
)
52-
FansiStr_plainText.invoke(fansiStr).asInstanceOf[String]
53-
catch
54-
case _: ClassNotFoundException => fallback()
55-
case _: NoSuchMethodException => fallback()
30+
pprint.PPrinter.BlackWhite
31+
.apply(value, width = width, height = height, initialOffset = initialOffset)
32+
.plainText
5633
}
5734

5835

0 commit comments

Comments
 (0)