Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sbt-1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SethTisue committed Oct 24, 2024
2 parents 508b1bd + 31e7359 commit b5af67c
Show file tree
Hide file tree
Showing 105 changed files with 1,914 additions and 339 deletions.
3 changes: 2 additions & 1 deletion .github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ RUN apt-get update && \
openjdk-17-jdk-headless \
openjdk-21-jdk-headless && \
(curl -fsSL https://deb.nodesource.com/setup_18.x | bash -) && \
apt-get install -y nodejs
apt-get install -y nodejs && \
apt-get install -y zip unzip


# Install sbt
Expand Down
320 changes: 221 additions & 99 deletions .github/workflows/ci.yaml

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions .github/workflows/test-msi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
###################################################################################################
### THIS IS A REUSABLE WORKFLOW TO TEST SCALA WITH MSI RUNNER ###
### HOW TO USE: ###
### Provide optional `version` to test if installed binaries are installed with ###
### correct Scala version. ###
### NOTE: Requires `scala.msi` artifact uploaded within the same run ###
### ###
###################################################################################################

name: Test 'scala' MSI Package
run-name: Test 'scala' (${{ inputs.version }}) MSI Package

on:
workflow_call:
inputs:
version:
required: true
type: string
java-version:
required: true
type : string

jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ inputs.java-version }}
- name: Download MSI artifact
uses: actions/download-artifact@v4
with:
name: scala.msi
path: .

# Run the MSI installer
# During normal installation msiexec would modify the PATH automatically.
# However, it seems not to work in GH Actions. Append the PATH manually instead.
- name: Install Scala Runner
shell: pwsh
run: |
Start-Process 'msiexec.exe' -ArgumentList '/I "scala.msi" /L*V "install.log" /qb' -Wait
Get-Content 'install.log'
Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\scala\bin"
# Run tests to ensure the Scala Runner was installed and works
- name: Test Scala Runner
shell: pwsh
run: |
scala --version
if (-not (scala --version | Select-String "Scala version \(default\): ${{ inputs.version }}")) {
Write-Host "Invalid Scala version of MSI installed runner, expected ${{ inputs.version }}"
Exit 1
}
- name : Test the `scalac` command
shell: pwsh
run: |
scalac --version
if (-not (scalac --version | Select-String "Scala compiler version ${{ inputs.version }}")) {
Write-Host "Invalid scalac version of MSI installed runner, expected ${{ inputs.version }}"
Exit 1
}
- name : Test the `scaladoc` command
shell: pwsh
run: |
scaladoc --version
if (-not (scaladoc --version | Select-String "Scaladoc version ${{ inputs.version }}")) {
Write-Host "Invalid scaladoc version of MSI installed runner, expected ${{ inputs.version }}"
Exit 1
}
- name : Uninstall the `scala` package
shell: pwsh
run: |
Start-Process 'msiexec.exe' -ArgumentList '/X "scala.msi" /L*V "uninstall.log" /qb' -Wait
Get-Content 'uninstall.log'
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ object CommunityBuildRunner:
* and avoid network overhead. See https://github.com/lampepfl/dotty-drone
* for more infrastructural details.
*/
extension (self: CommunityProject) def run()(using suite: CommunityBuildRunner): Unit =
if self.requiresExperimental && !compilerSupportExperimental then
log(s"Skipping ${self.project} - it needs experimental features unsupported in this build.")
return
self.dependencies.foreach(_.publish())
self.testOnlyDependencies().foreach(_.publish())
suite.runProject(self)
extension (self: CommunityProject)
def run()(using suite: CommunityBuildRunner): Unit =
self.dependencies.foreach(_.publish())
self.testOnlyDependencies().foreach(_.publish())
suite.runProject(self)
end extension

trait CommunityBuildRunner:

Expand Down
5 changes: 1 addition & 4 deletions community-build/src/scala/dotty/communitybuild/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ object Main:
Seq("rm", "-rf", destStr).!
Files.createDirectory(dest)
val (toRun, ignored) =
allProjects.partition( p =>
p.docCommand != null
&& (!p.requiresExperimental || compilerSupportExperimental)
)
allProjects.partition(_.docCommand != null)

val paths = toRun.map { project =>
val name = project.project
Expand Down
21 changes: 4 additions & 17 deletions community-build/src/scala/dotty/communitybuild/projects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ lazy val compilerVersion: String =
val file = communitybuildDir.resolve("scala3-bootstrapped.version")
new String(Files.readAllBytes(file), UTF_8)

lazy val compilerSupportExperimental: Boolean =
compilerVersion.contains("SNAPSHOT") || compilerVersion.contains("NIGHTLY")

lazy val sbtPluginFilePath: String =
// Workaround for https://github.com/sbt/sbt/issues/4395
new File(sys.props("user.home") + "/.sbt/1.0/plugins").mkdirs()
Expand Down Expand Up @@ -43,7 +40,6 @@ sealed trait CommunityProject:
val testOnlyDependencies: () => List[CommunityProject]
val binaryName: String
val runCommandsArgs: List[String] = Nil
val requiresExperimental: Boolean
val environment: Map[String, String] = Map.empty

final val projectDir = communitybuildDir.resolve("community-projects").resolve(project)
Expand All @@ -53,7 +49,6 @@ sealed trait CommunityProject:

/** Publish this project to the local Maven repository */
final def publish(): Unit =
// TODO what should this do with .requiresExperimental?
if !published then
publishDependencies()
log(s"Publishing $project")
Expand All @@ -65,11 +60,6 @@ sealed trait CommunityProject:
published = true

final def doc(): Unit =
if this.requiresExperimental && !compilerSupportExperimental then
log(
s"Skipping ${this.project} - it needs experimental features unsupported in this build."
)
return
publishDependencies()
log(s"Documenting $project")
if docCommand eq null then
Expand All @@ -89,8 +79,7 @@ final case class MillCommunityProject(
baseCommand: String,
dependencies: List[CommunityProject] = Nil,
testOnlyDependencies: () => List[CommunityProject] = () => Nil,
ignoreDocs: Boolean = false,
requiresExperimental: Boolean = false,
ignoreDocs: Boolean = false
) extends CommunityProject:
override val binaryName: String = "./mill"
override val testCommand = s"$baseCommand.test"
Expand All @@ -109,8 +98,7 @@ final case class SbtCommunityProject(
testOnlyDependencies: () => List[CommunityProject] = () => Nil,
sbtPublishCommand: String = null,
sbtDocCommand: String = null,
scalacOptions: List[String] = SbtCommunityProject.scalacOptions,
requiresExperimental: Boolean = false,
scalacOptions: List[String] = SbtCommunityProject.scalacOptions
) extends CommunityProject:
override val binaryName: String = "sbt"

Expand Down Expand Up @@ -260,7 +248,6 @@ object projects:
project = "intent",
sbtTestCommand = "test",
sbtDocCommand = "doc",
requiresExperimental = true,
)

lazy val scalacheck = SbtCommunityProject(
Expand Down Expand Up @@ -489,8 +476,8 @@ object projects:

lazy val scalaCollectionCompat = SbtCommunityProject(
project = "scala-collection-compat",
sbtTestCommand = "compat30/test",
sbtPublishCommand = "compat30/publishLocal",
sbtTestCommand = "compat3/test",
sbtPublishCommand = "compat3/publishLocal",
)

lazy val scalaJava8Compat = SbtCommunityProject(
Expand Down
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,13 @@ trait BCodeSkelBuilder extends BCodeHelpers {
}

if (emitLines && tree.span.exists && !tree.hasAttachment(SyntheticUnit)) {
val nr = ctx.source.offsetToLine(tree.span.point) + 1
val nr =
val sourcePos = tree.sourcePos
(
if sourcePos.exists then sourcePos.source.positionInUltimateSource(sourcePos).line
else ctx.source.offsetToLine(tree.span.point) // fallback
) + 1

if (nr != lastEmittedLineNr) {
lastEmittedLineNr = nr
getNonLabelNode(lastInsn) match {
Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import dotty.tools.dotc.transform.{Erasure, ValueClasses}
import dotty.tools.dotc.util.SourcePosition
import dotty.tools.dotc.report

import org.scalajs.ir
import org.scalajs.ir.{ClassKind, Position, Names => jsNames, Trees => js, Types => jstpe}
import org.scalajs.ir.Names.{ClassName, MethodName, SimpleMethodName}
import org.scalajs.ir.OriginalName
import org.scalajs.ir.OriginalName.NoOriginalName
import org.scalajs.ir.Trees.OptimizerHints
import org.scalajs.ir.Version.Unversioned
import dotty.tools.sjs.ir
import dotty.tools.sjs.ir.{ClassKind, Position, Names => jsNames, Trees => js, Types => jstpe}
import dotty.tools.sjs.ir.Names.{ClassName, MethodName, SimpleMethodName}
import dotty.tools.sjs.ir.OriginalName
import dotty.tools.sjs.ir.OriginalName.NoOriginalName
import dotty.tools.sjs.ir.Trees.OptimizerHints
import dotty.tools.sjs.ir.Version.Unversioned

import dotty.tools.dotc.transform.sjs.JSSymUtils.*

Expand Down
12 changes: 6 additions & 6 deletions compiler/src/dotty/tools/backend/sjs/JSEncoding.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import StdNames.*

import dotty.tools.dotc.transform.sjs.JSSymUtils.*

import org.scalajs.ir
import org.scalajs.ir.{Trees => js, Types => jstpe}
import org.scalajs.ir.Names.{LocalName, LabelName, SimpleFieldName, FieldName, SimpleMethodName, MethodName, ClassName}
import org.scalajs.ir.OriginalName
import org.scalajs.ir.OriginalName.NoOriginalName
import org.scalajs.ir.UTF8String
import dotty.tools.sjs.ir
import dotty.tools.sjs.ir.{Trees => js, Types => jstpe}
import dotty.tools.sjs.ir.Names.{LocalName, LabelName, SimpleFieldName, FieldName, SimpleMethodName, MethodName, ClassName}
import dotty.tools.sjs.ir.OriginalName
import dotty.tools.sjs.ir.OriginalName.NoOriginalName
import dotty.tools.sjs.ir.UTF8String

import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions

Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import TypeErasure.ErasedValueType
import dotty.tools.dotc.util.{SourcePosition, SrcPos}
import dotty.tools.dotc.report

import org.scalajs.ir.{Position, Names => jsNames, Trees => js, Types => jstpe}
import org.scalajs.ir.Names.DefaultModuleID
import org.scalajs.ir.OriginalName.NoOriginalName
import org.scalajs.ir.Position.NoPosition
import org.scalajs.ir.Trees.OptimizerHints
import org.scalajs.ir.Version.Unversioned
import dotty.tools.sjs.ir.{Position, Names => jsNames, Trees => js, Types => jstpe}
import dotty.tools.sjs.ir.Names.DefaultModuleID
import dotty.tools.sjs.ir.OriginalName.NoOriginalName
import dotty.tools.sjs.ir.Position.NoPosition
import dotty.tools.sjs.ir.Trees.OptimizerHints
import dotty.tools.sjs.ir.Version.Unversioned

import dotty.tools.dotc.transform.sjs.JSExportUtils.*
import dotty.tools.dotc.transform.sjs.JSSymUtils.*
Expand Down Expand Up @@ -932,7 +932,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
InstanceOfTypeTest(tpe.tycon.typeSymbol.typeRef)

case _ =>
import org.scalajs.ir.Names
import dotty.tools.sjs.ir.Names

(toIRType(tpe): @unchecked) match {
case jstpe.AnyType => NoTypeTest
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/sjs/JSPositions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import dotty.tools.dotc.report
import dotty.tools.dotc.util.{SourceFile, SourcePosition}
import dotty.tools.dotc.util.Spans.Span

import org.scalajs.ir
import dotty.tools.sjs.ir

/** Conversion utilities from dotty Positions to IR Positions. */
class JSPositions()(using Context) {
Expand Down
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class Compiler {
new ElimStaticThis, // Replace `this` references to static objects by global identifiers
new CountOuterAccesses) :: // Identify outer accessors that can be dropped
List(new DropOuterAccessors, // Drop unused outer accessors
new DropParentRefinements, // Drop parent refinements from a template
new CheckNoSuperThis, // Check that supercalls don't contain references to `this`
new Flatten, // Lift all inner classes to package scope
new TransformWildcards, // Replace wildcards with default values
Expand All @@ -151,7 +152,10 @@ class Compiler {
List(new GenBCode) :: // Generate JVM bytecode
Nil

var runId: Int = 1
// TODO: Initially 0, so that the first nextRunId call would return InitialRunId == 1
// Changing the initial runId from 1 to 0 makes the scala2-library-bootstrap fail to compile,
// when the underlying issue is fixed, please update dotc.profiler.RealProfiler.chromeTrace logic
private var runId: Int = 1
def nextRunId: Int = {
runId += 1; runId
}
Expand Down
7 changes: 3 additions & 4 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,9 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
if phaseWillRun then
Stats.trackTime(s"phase time ms/$phase") {
val start = System.currentTimeMillis
val profileBefore = profiler.beforePhase(phase)
try units = phase.runOn(units)
catch case _: InterruptedException => cancelInterrupted()
profiler.afterPhase(phase, profileBefore)
profiler.onPhase(phase):
try units = phase.runOn(units)
catch case _: InterruptedException => cancelInterrupted()
if (ctx.settings.Xprint.value.containsPhase(phase))
for (unit <- units)
def printCtx(unit: CompilationUnit) = phase.printingContext(
Expand Down
7 changes: 4 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1605,9 +1605,10 @@ object desugar {

/** Translate tuple expressions
*
* () ==> ()
* (t) ==> t
* (t1, ..., tN) ==> TupleN(t1, ..., tN)
* () ==> ()
* (t) ==> t
* (t1, ..., tN) ==> TupleN(t1, ..., tN)
* (n1 = t1, ..., nN = tN) ==> NamedTuple.build[(n1, ..., nN)]()(TupleN(t1, ..., tN))
*/
def tuple(tree: Tuple, pt: Type)(using Context): Tree =
var elems = checkWellFormedTupleElems(tree.trees)
Expand Down
10 changes: 4 additions & 6 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,10 @@ private sealed trait YSettings:
val YlegacyLazyVals: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylegacy-lazy-vals", "Use legacy (pre 3.3.0) implementation of lazy vals.")
val YcompileScala2Library: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycompile-scala2-library", "Used when compiling the Scala 2 standard library.")
val YprofileEnabled: Setting[Boolean] = BooleanSetting(ForkSetting, "Yprofile-enabled", "Enable profiling.")
val YprofileDestination: Setting[String] = StringSetting(ForkSetting, "Yprofile-destination", "file", "Where to send profiling output - specify a file, default is to the console.", "")
//.withPostSetHook( _ => YprofileEnabled.value = true )
val YprofileExternalTool: Setting[List[String]] = PhasesSetting(ForkSetting, "Yprofile-external-tool", "Enable profiling for a phase using an external tool hook. Generally only useful for a single phase.", "typer")
//.withPostSetHook( _ => YprofileEnabled.value = true )
val YprofileRunGcBetweenPhases: Setting[List[String]] = PhasesSetting(ForkSetting, "Yprofile-run-gc", "Run a GC between phases - this allows heap size to be accurate at the expense of more time. Specify a list of phases, or *", "_")
//.withPostSetHook( _ => YprofileEnabled.value = true )
val YprofileDestination: Setting[String] = StringSetting(ForkSetting, "Yprofile-destination", "file", "Where to send profiling output - specify a file, default is to the console.", "", depends = List(YprofileEnabled -> true))
val YprofileExternalTool: Setting[List[String]] = PhasesSetting(ForkSetting, "Yprofile-external-tool", "Enable profiling for a phase using an external tool hook. Generally only useful for a single phase.", "typer", depends = List(YprofileEnabled -> true))
val YprofileRunGcBetweenPhases: Setting[List[String]] = PhasesSetting(ForkSetting, "Yprofile-run-gc", "Run a GC between phases - this allows heap size to be accurate at the expense of more time. Specify a list of phases, or *", "_", depends = List(YprofileEnabled -> true))
val YprofileTrace: Setting[String] = StringSetting(ForkSetting, "Yprofile-trace", "file", s"Capture trace of compilation in JSON Chrome Trace format to the specified file. This option requires ${YprofileEnabled.name}. The output file can be visualized using https://ui.perfetto.dev/.", "", depends = List(YprofileEnabled -> true))

val YbestEffort: Setting[Boolean] = BooleanSetting(ForkSetting, "Ybest-effort", "Enable best-effort compilation attempting to produce betasty to the META-INF/best-effort directory, regardless of errors, as part of the pickler phase.")
val YwithBestEffortTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Ywith-best-effort-tasty", "Allow to compile using best-effort tasty files. If such file is used, the compiler will stop after the pickler phase.")
Expand Down
Loading

0 comments on commit b5af67c

Please sign in to comment.