Skip to content
Draft
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
35 changes: 35 additions & 0 deletions .github/workflows/stdlib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,24 @@ jobs:
- name: Compile `scala3-library` for Scala.js
run: ./project/scripts/sbt scala3-library-sjs/compile

repl:
runs-on: ubuntu-latest
needs: [scala3-compiler-bootstrapped]
steps:
- name: Git Checkout
uses: actions/checkout@v5

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
cache: 'sbt'
- uses: sbt/setup-sbt@v1

- name: Compile REPL
run: ./project/scripts/sbt scala3-repl/compile

scaladoc:
runs-on: ubuntu-latest
needs: [scala3-compiler-bootstrapped, scala3-tasty-inspector]
Expand Down Expand Up @@ -548,6 +566,23 @@ jobs:
run: ./project/scripts/sbt ";sjsJUnitTests/clean ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToLatestESVersion ;set Global/enableWebAssembly := true; sjsJUnitTests/test"
# TODO Scala.js on Windows

test-repl:
runs-on: ubuntu-latest
needs: [repl]
steps:
- name: Git Checkout
uses: actions/checkout@v5

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- name: Test REPL
run: ./project/scripts/sbt scala3-repl/test

scripted-tests:
runs-on: ubuntu-latest
needs: [scala3-compiler-bootstrapped, tasty-core-bootstrapped, scala3-staging, scala3-tasty-inspector, scala-library-sjs, scaladoc]
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ val `scala3-compiler` = Build.`scala3-compiler`
val `scala3-compiler-nonbootstrapped` = Build.`scala3-compiler-nonbootstrapped`
val `scala3-compiler-bootstrapped-new` = Build.`scala3-compiler-bootstrapped-new`
val `scala3-compiler-bootstrapped` = Build.`scala3-compiler-bootstrapped`
val `scala3-repl` = Build.`scala3-repl`
val `scala-library-sjs` = Build.`scala-library-sjs`
val `scala3-library-sjs` = Build.`scala3-library-sjs`
val `scala-library-nonbootstrapped` = Build.`scala-library-nonbootstrapped`
Expand Down
10 changes: 3 additions & 7 deletions compiler/src/dotty/tools/dotc/quoted/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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.io.AbstractFileClassLoader
import dotty.tools.dotc.core.CyclicReference

/** Tree interpreter for metaprogramming constructs */
Expand All @@ -35,7 +35,7 @@ class Interpreter(pos: SrcPos, classLoader0: ClassLoader)(using Context):

val classLoader =
if ctx.owner.topLevelClass.name.startsWith(str.REPL_SESSION_LINE) then
new AbstractFileClassLoader(ctx.settings.outputDir.value, classLoader0, "false")
new AbstractFileClassLoader(ctx.settings.outputDir.value, classLoader0)
else classLoader0

/** Local variable environment */
Expand Down Expand Up @@ -204,11 +204,7 @@ class Interpreter(pos: SrcPos, classLoader0: ClassLoader)(using Context):
}

private def loadReplLineClass(moduleClass: Symbol): Class[?] = {
val lineClassloader = new AbstractFileClassLoader(
ctx.settings.outputDir.value,
classLoader,
"false"
)
val lineClassloader = new AbstractFileClassLoader(ctx.settings.outputDir.value, classLoader)
lineClassloader.loadClass(moduleClass.name.firstPart.toString)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/Splicer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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
61 changes: 61 additions & 0 deletions compiler/src/dotty/tools/io/AbstractFileClassLoader.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/

package dotty.tools
package io

import scala.language.unsafeNulls

import dotty.tools.io.AbstractFile

import java.net.{URL, URLConnection, URLStreamHandler}
import java.util.Collections

class AbstractFileClassLoader(val root: AbstractFile, parent: ClassLoader) extends ClassLoader(parent):
private def findAbstractFile(name: String) = root.lookupPath(name.split('/').toIndexedSeq, directory = false)

// on JDK 20 the URL constructor we're using is deprecated,
// but the recommended replacement, URL.of, doesn't exist on JDK 8
@annotation.nowarn("cat=deprecation")
override protected def findResource(name: String): URL | Null =
findAbstractFile(name) match
case null => null
case file => new URL(null, s"memory:${file.path}", new URLStreamHandler {
override def openConnection(url: URL): URLConnection = new URLConnection(url) {
override def connect() = ()
override def getInputStream = file.input
}
})
override protected def findResources(name: String): java.util.Enumeration[URL] =
findResource(name) match
case null => Collections.enumeration(Collections.emptyList[URL]) //Collections.emptyEnumeration[URL]
case url => Collections.enumeration(Collections.singleton(url))

override def findClass(name: String): Class[?] = {
var file: AbstractFile | Null = root
val pathParts = name.split("[./]").toList
for (dirPart <- pathParts.init) {
file = file.lookupName(dirPart, true)
if (file == null) {
throw new ClassNotFoundException(name)
}
}
file = file.lookupName(pathParts.last+".class", false)
if (file == null) {
throw new ClassNotFoundException(name)
}
val bytes = file.toByteArray
defineClass(name, bytes, 0, bytes.length)
}

override def loadClass(name: String): Class[?] = try findClass(name) catch case _: ClassNotFoundException => super.loadClass(name)
end AbstractFileClassLoader
10 changes: 0 additions & 10 deletions compiler/src/dotty/tools/repl/package.scala

This file was deleted.

13 changes: 0 additions & 13 deletions compiler/test-resources/repl/jar-command

This file was deleted.

11 changes: 0 additions & 11 deletions compiler/test-resources/repl/jar-errors

This file was deleted.

3 changes: 3 additions & 0 deletions compiler/test/dotty/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ object Properties {
/** dotty-compiler jar */
def dottyCompiler: String = sys.props("dotty.tests.classes.dottyCompiler")

/** dotty-repl jar */
def dottyRepl: String = sys.props("dotty.tests.classes.dottyRepl")

/** dotty-staging jar */
def dottyStaging: String = sys.props("dotty.tests.classes.dottyStaging")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,17 @@ class BootstrappedOnlyCompilationTests {

@Test def picklingWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("testPicklingWithCompiler")
// Exclude this file from the test as it contains some changes that require scala 2.13.17
// This filter can be dropped once we drop the dependency to Scala 2 (in 3.8.0)
val rlibscala3 = FileFilter.exclude(List("ScalaRunTime.scala"))

aggregateTests(
compileDir("compiler/src/dotty/tools", picklingWithCompilerOptions, recursive = false),
compileDir("compiler/src/dotty/tools/dotc", picklingWithCompilerOptions, recursive = false),
compileDir("library/src/scala/runtime/function", picklingWithCompilerOptions),
compileFilesInDir("library/src/scala/runtime", picklingWithCompilerOptions, rlibscala3),
compileFilesInDir("library/src/scala/runtime", picklingWithCompilerOptions),
compileFilesInDir("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/rewrites", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/transform", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/typer", picklingWithCompilerOptions),
Expand Down
20 changes: 0 additions & 20 deletions compiler/test/dotty/tools/repl/ScriptedTests.scala

This file was deleted.

14 changes: 12 additions & 2 deletions compiler/test/dotty/tools/vulpix/TestConfiguration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ object TestConfiguration {
val withCompilerClasspath = mkClasspath(List(
Properties.scalaLibrary,
Properties.scalaAsm,
Properties.jlineTerminal,
Properties.jlineReader,
Properties.compilerInterface,
Properties.dottyInterfaces,
Properties.tastyCore,
Expand All @@ -54,6 +52,16 @@ object TestConfiguration {
Properties.scalaJSLibrary,
))

lazy val replClassPath =
withCompilerClasspath + File.pathSeparator + mkClasspath(List(
Properties.dottyRepl,
Properties.jlineTerminal,
Properties.jlineReader,
))

lazy val replWithStagingClasspath =
replClassPath + File.pathSeparator + mkClasspath(List(Properties.dottyStaging))

def mkClasspath(classpaths: List[String]): String =
classpaths.map({ p =>
val file = new java.io.File(p)
Expand All @@ -71,6 +79,8 @@ object TestConfiguration {
val unindentOptions = TestFlags(basicClasspath, Array("-no-indent") ++ checkOptions ++ noCheckOptions ++ yCheckOptions)
val withCompilerOptions =
defaultOptions.withClasspath(withCompilerClasspath).withRunClasspath(withCompilerClasspath)
lazy val withReplOptions =
defaultOptions.withRunClasspath(replClassPath)
lazy val withStagingOptions =
defaultOptions.withClasspath(withStagingClasspath).withRunClasspath(withStagingClasspath)
lazy val withTastyInspectorOptions =
Expand Down
Loading
Loading