Skip to content

Commit 7083976

Browse files
authored
Merge branch 'scala:main' into cc-ex-refactored
2 parents 19e6529 + e2dfea3 commit 7083976

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1495
-357
lines changed

.github/workflows/ci.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ jobs:
141141

142142
- name: Cmd Tests
143143
run: |
144-
./project/scripts/sbt ";dist/pack; scala3-bootstrapped/compile; scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/*; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test"
144+
./project/scripts/buildScalaBinary
145+
./project/scripts/sbt ";scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test"
145146
./project/scripts/cmdTests
146147
./project/scripts/bootstrappedOnlyCmdTests
147148
@@ -230,7 +231,7 @@ jobs:
230231
shell: cmd
231232

232233
- name: build binary
233-
run: sbt "dist/pack" & bash -version
234+
run: sbt "dist-win-x86_64/pack" & bash -version
234235
shell: cmd
235236

236237
- name: cygwin tests
@@ -269,8 +270,12 @@ jobs:
269270
- name: Git Checkout
270271
uses: actions/checkout@v4
271272

273+
- name: build binary
274+
run: sbt "dist-win-x86_64/pack"
275+
shell: cmd
276+
272277
- name: Test
273-
run: sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test"
278+
run: sbt ";scala3-bootstrapped/compile ;scala3-bootstrapped/test"
274279
shell: cmd
275280

276281
- name: Scala.js Test
@@ -596,7 +601,8 @@ jobs:
596601

597602
- name: Test
598603
run: |
599-
./project/scripts/sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/*"
604+
./project/scripts/buildScalaBinary
605+
./project/scripts/sbt ";scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/*"
600606
./project/scripts/cmdTests
601607
./project/scripts/bootstrappedOnlyCmdTests
602608

.github/workflows/launchers.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Test CLI Launchers on all the platforms
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
6+
jobs:
7+
linux-x86_64:
8+
name: Deploy and Test on Linux x64 architecture
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up JDK 17
13+
uses: actions/setup-java@v4
14+
with:
15+
java-version: '17'
16+
distribution: 'temurin'
17+
cache: 'sbt'
18+
- name: Build and test launcher command
19+
run: ./project/scripts/native-integration/bashTests
20+
env:
21+
LAUNCHER_EXPECTED_PROJECT: "dist-linux-x86_64"
22+
23+
linux-aarch64:
24+
name: Deploy and Test on Linux ARM64 architecture
25+
runs-on: macos-latest
26+
if: ${{ false }}
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: '17'
33+
distribution: 'temurin'
34+
cache: 'sbt'
35+
# https://github.com/actions/runner-images/issues/9369
36+
- name: Install sbt
37+
run: brew install sbt
38+
- name: Build and test launcher command
39+
run: ./project/scripts/native-integration/bashTests
40+
env:
41+
LAUNCHER_EXPECTED_PROJECT: "dist-linux-aarch64"
42+
43+
mac-x86_64:
44+
name: Deploy and Test on Mac x64 architecture
45+
runs-on: macos-13
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Set up JDK 17
49+
uses: actions/setup-java@v4
50+
with:
51+
java-version: '17'
52+
distribution: 'temurin'
53+
cache: 'sbt'
54+
# https://github.com/actions/runner-images/issues/9369
55+
- name: Install sbt
56+
run: brew install sbt
57+
- name: Build and test launcher command
58+
run: ./project/scripts/native-integration/bashTests
59+
env:
60+
LAUNCHER_EXPECTED_PROJECT: "dist-mac-x86_64"
61+
62+
mac-aarch64:
63+
name: Deploy and Test on Mac ARM64 architecture
64+
runs-on: macos-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
- name: Set up JDK 17
68+
uses: actions/setup-java@v4
69+
with:
70+
java-version: '17'
71+
distribution: 'temurin'
72+
cache: 'sbt'
73+
# https://github.com/actions/runner-images/issues/9369
74+
- name: Install sbt
75+
run: brew install sbt
76+
- name: Build and test launcher command
77+
run: ./project/scripts/native-integration/bashTests
78+
env:
79+
LAUNCHER_EXPECTED_PROJECT: "dist-mac-aarch64"
80+
81+
win-x86_64:
82+
name: Deploy and Test on Windows x64 architecture
83+
runs-on: windows-latest
84+
steps:
85+
- uses: actions/checkout@v4
86+
- name: Set up JDK 17
87+
uses: actions/setup-java@v4
88+
with:
89+
java-version: '17'
90+
distribution: 'temurin'
91+
cache: 'sbt'
92+
- name: Build the launcher command
93+
run: sbt "dist-win-x86_64/pack"
94+
- name: Run the launcher command tests
95+
run: './project/scripts/native-integration/winTests.bat'
96+
shell: cmd

bin/common

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ target="$1"
99

1010
shift # Mutates $@ by deleting the first element ($1)
1111

12+
# set the $DIST_PROJECT and $DIST_DIR variables
13+
source "$ROOT/bin/common-platform"
14+
1215
# Marker file used to obtain the date of latest call to sbt-back
13-
version="$ROOT/dist/target/pack/VERSION"
16+
version="$ROOT/$DIST_DIR/target/pack/VERSION"
1417

1518
# Create the target if absent or if file changed in ROOT/compiler
1619
new_files="$(find "$ROOT/compiler" \( -iname "*.scala" -o -iname "*.java" \) -newer "$version" 2> /dev/null)"
1720

1821
if [ ! -f "$version" ] || [ ! -z "$new_files" ]; then
1922
echo "Building Dotty..."
20-
(cd $ROOT && sbt "dist/pack")
23+
(cd $ROOT && sbt "$DIST_PROJECT/pack")
2124
fi
2225

23-
"$target" "$@"
26+
"$ROOT/$DIST_DIR/target/pack/bin/$target" "$@"

bin/common-platform

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
unset cygwin mingw msys darwin
4+
5+
# COLUMNS is used together with command line option '-pageWidth'.
6+
if command -v tput >/dev/null 2>&1; then
7+
export COLUMNS="$(tput -Tdumb cols)"
8+
fi
9+
10+
case "`uname`" in
11+
CYGWIN*) cygwin=true
12+
;;
13+
MINGW*) mingw=true
14+
;;
15+
MSYS*) msys=true
16+
;;
17+
Darwin*) darwin=true
18+
;;
19+
esac
20+
21+
unset DIST_PROJECT DIST_DIR
22+
23+
if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
24+
DIST_PROJECT="dist-win-x86_64"
25+
DIST_DIR="dist/win-x86_64"
26+
else
27+
# OS and arch logic taken from https://github.com/VirtusLab/scala-cli/blob/main/scala-cli.sh
28+
unset arch ARCH_NORM
29+
arch=$(uname -m)
30+
if [[ "$arch" == "aarch64" ]] || [[ "$arch" == "x86_64" ]]; then
31+
ARCH_NORM="$arch"
32+
elif [[ "$arch" == "amd64" ]]; then
33+
ARCH_NORM="x86_64"
34+
elif [[ "$arch" == "arm64" ]]; then
35+
ARCH_NORM="aarch64"
36+
else
37+
ARCH_NORM="unknown"
38+
fi
39+
40+
if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "Linux" ]; then
41+
if [[ "$ARCH_NORM" == "unknown" ]]; then
42+
echo >&2 "unknown Linux CPU architecture, defaulting to JVM launcher"
43+
DIST_PROJECT="dist"
44+
DIST_DIR="dist"
45+
else
46+
DIST_PROJECT="dist-linux-$ARCH_NORM"
47+
DIST_DIR="dist/linux-$ARCH_NORM"
48+
fi
49+
elif [ "$(uname)" == "Darwin" ]; then
50+
if [[ "$ARCH_NORM" == "unknown" ]]; then
51+
echo >&2 "unknown Darwin CPU architecture, defaulting to JVM launcher"
52+
DIST_PROJECT="dist"
53+
DIST_DIR="dist"
54+
else
55+
DIST_PROJECT="dist-mac-$ARCH_NORM"
56+
DIST_DIR="dist/mac-$ARCH_NORM"
57+
fi
58+
else
59+
echo >&2 "unknown OS, defaulting to JVM launcher"
60+
DIST_PROJECT="dist"
61+
DIST_DIR="dist"
62+
fi
63+
fi

bin/scala

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,37 @@
22

33
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
44

5-
"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scala" "$@"
5+
scala_args() {
6+
7+
declare -a CLI_ARGS
8+
declare -a SCRIPT_ARGS
9+
declare DISABLE_BLOOP=1
10+
11+
while (( "$#" )); do
12+
case "$1" in
13+
"--")
14+
shift
15+
SCRIPT_ARGS+=("--")
16+
SCRIPT_ARGS+=("$@")
17+
break
18+
;;
19+
"clean" | "version" | "--version" | "-version" | "help" | "--help" | "-help")
20+
CLI_ARGS+=("$1")
21+
DISABLE_BLOOP=0 # clean command should not add --offline --server=false
22+
shift
23+
;;
24+
*)
25+
CLI_ARGS+=("$1")
26+
shift
27+
;;
28+
esac
29+
done
30+
31+
if [ $DISABLE_BLOOP -eq 1 ]; then
32+
CLI_ARGS+=("--offline" "--server=false")
33+
fi
34+
35+
echo "--power ${CLI_ARGS[@]} ${SCRIPT_ARGS[@]}"
36+
}
37+
38+
"$ROOT/bin/common" "scala" $(scala_args "$@")

bin/scalac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
44

5-
"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scalac" "$@"
5+
"$ROOT/bin/common" "scalac" "$@"

bin/scaladoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
44

5-
"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scaladoc" "$@"
5+
"$ROOT/bin/common" "scaladoc" "$@"

bin/test/TestScripts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class TestScripts {
5757
s"bin/scalac script did not run properly. Output:$lineSep$dotcOutput"
5858
)
5959

60-
val (retDotr, dotrOutput) = executeScript("./bin/scala HelloWorld")
60+
val (retDotr, dotrOutput) = executeScript("./bin/scala -M HelloWorld")
6161
assert(
6262
retDotr == 0 && dotrOutput == "hello world\n",
6363
s"Running hello world exited with status: $retDotr and output: $dotrOutput"

build.sbt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ val `scaladoc-js-main` = Build.`scaladoc-js-main`
2828
val `scaladoc-js-contributors` = Build.`scaladoc-js-contributors`
2929
val `scala3-bench-run` = Build.`scala3-bench-run`
3030
val dist = Build.dist
31+
val `dist-mac-x86_64` = Build.`dist-mac-x86_64`
32+
val `dist-mac-aarch64` = Build.`dist-mac-aarch64`
33+
val `dist-win-x86_64` = Build.`dist-win-x86_64`
34+
val `dist-linux-x86_64` = Build.`dist-linux-x86_64`
35+
val `dist-linux-aarch64` = Build.`dist-linux-aarch64`
3136
val `community-build` = Build.`community-build`
3237
val `sbt-community-build` = Build.`sbt-community-build`
3338
val `scala3-presentation-compiler` = Build.`scala3-presentation-compiler`

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,22 @@ object MainGenericRunner {
266266
run(settings.withExecuteMode(ExecuteMode.Run))
267267
else
268268
run(settings.withExecuteMode(ExecuteMode.Repl))
269+
end run
270+
271+
val ranByCoursierBootstrap =
272+
sys.props.isDefinedAt("coursier.mainJar")
273+
|| sys.props.get("bootstrap.mainClass").contains("dotty.tools.MainGenericRunner")
274+
275+
val silenced = sys.props.get("scala.use_legacy_launcher") == Some("true")
276+
277+
if !silenced then
278+
Console.err.println(s"[warning] MainGenericRunner class is deprecated since Scala 3.5.0, and Scala CLI features will not work.")
279+
Console.err.println(s"[warning] Please be sure to update to the Scala CLI launcher to use the new features.")
280+
if ranByCoursierBootstrap then
281+
Console.err.println(s"[warning] It appears that your Coursier-based Scala installation is misconfigured.")
282+
Console.err.println(s"[warning] To update to the new Scala CLI runner, please update (coursier, cs) commands first before re-installing scala.")
283+
Console.err.println(s"[warning] Check the Scala 3.5.0 release notes to troubleshoot your installation.")
284+
269285

270286
run(settings) match
271287
case Some(ex: (StringDriverException | ScriptingException)) => errorFn(ex.getMessage)

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ object Contexts {
477477

478478
/** Is the flexible types option set? */
479479
def flexibleTypes: Boolean = base.settings.YexplicitNulls.value && !base.settings.YnoFlexibleTypes.value
480-
480+
481481
/** Is the best-effort option set? */
482482
def isBestEffort: Boolean = base.settings.YbestEffort.value
483483

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4646,12 +4646,18 @@ object Types extends TypeUtils {
46464646

46474647
override def superType(using Context): Type =
46484648
if ctx.period != validSuper then
4649-
validSuper = if (tycon.isProvisional) Nowhere else ctx.period
4649+
var superIsProvisional = tycon.isProvisional
46504650
cachedSuper = tycon match
46514651
case tycon: HKTypeLambda => defn.AnyType
46524652
case tycon: TypeRef if tycon.symbol.isClass => tycon
4653-
case tycon: TypeProxy => tycon.superType.applyIfParameterized(args)
4653+
case tycon: TypeProxy =>
4654+
superIsProvisional ||= args.exists(_.isProvisional)
4655+
// applyIfParameterized may perform eta-reduction leading to different
4656+
// variance annotations depending on the instantiation of type params
4657+
// see tests/pos/typeclass-encoding3b.scala:348 for an example
4658+
tycon.superType.applyIfParameterized(args)
46544659
case _ => defn.AnyType
4660+
validSuper = if superIsProvisional then Nowhere else ctx.period
46554661
cachedSuper
46564662

46574663
override def translucentSuperType(using Context): Type = tycon match {
@@ -4678,8 +4684,8 @@ object Types extends TypeUtils {
46784684
*/
46794685
override def underlyingMatchType(using Context): Type =
46804686
if ctx.period != validUnderlyingMatch then
4681-
validUnderlyingMatch = if tycon.isProvisional then Nowhere else ctx.period
46824687
cachedUnderlyingMatch = superType.underlyingMatchType
4688+
validUnderlyingMatch = validSuper
46834689
cachedUnderlyingMatch
46844690

46854691
override def tryNormalize(using Context): Type = tycon.stripTypeVar match {

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ trait Implicits:
10771077
trace(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}", implicits, show = true) {
10781078
record("inferImplicit")
10791079
assert(ctx.phase.allowsImplicitSearch,
1080-
if (argument.isEmpty) i"missing implicit parameter of type $pt after typer at phase ${ctx.phase.phaseName}"
1080+
if (argument.isEmpty) i"missing implicit parameter of type $pt after typer at phase ${ctx.phase}"
10811081
else i"type error: ${argument.tpe} does not conform to $pt${err.whyNoMatchStr(argument.tpe, pt)}")
10821082

10831083
val usableForInference = pt.exists && !pt.unusableForInference

0 commit comments

Comments
 (0)