Skip to content

Commit a501815

Browse files
committed
Package Scala 2 library TASTy for scalac and scala commands
Using the Scala 2 library TASTy is still unstable. It can be enabled by using the -Yuse-scala2-library-tasty` on the `scalac` and `scala` commands. Not available on `scalac.bat` and `scala.bat`.
1 parent 65fca39 commit a501815

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

dist/bin/common

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ find_lib () {
150150
DOTTY_COMP=$(find_lib "*scala3-compiler*")
151151
DOTTY_INTF=$(find_lib "*scala3-interfaces*")
152152
DOTTY_LIB=$(find_lib "*scala3-library*")
153+
SCALA2_LIB_TASTY=$(find_lib "*scala2-library-tasty*")
153154
DOTTY_STAGING=$(find_lib "*scala3-staging*")
154155
DOTTY_TASTY_INSPECTOR=$(find_lib "*scala3-tasty-inspector*")
155156
TASTY_CORE=$(find_lib "*tasty-core*")
@@ -167,12 +168,17 @@ compilerJavaClasspathArgs () {
167168
# echo "dotty-compiler: $DOTTY_COMP"
168169
# echo "dotty-interface: $DOTTY_INTF"
169170
# echo "dotty-library: $DOTTY_LIB"
171+
# echo "scala2-library-tasty: $SCALA2_LIB_TASTY"
170172
# echo "tasty-core: $TASTY_CORE"
171173
# echo "scala-asm: $SCALA_ASM"
172174
# echo "scala-lib: $SCALA_LIB"
173175
# echo "sbt-intface: $SBT_INTF"
174176

175177
toolchain=""
178+
if [ "$1" = true ] ; then
179+
toolchain+="$SCALA2_LIB_TASTY$PSEP" # needs to be added before the SCALA_LIB
180+
echo "Warning: Scala 2 library TASTy is still unstable."
181+
fi
176182
toolchain+="$SCALA_LIB$PSEP"
177183
toolchain+="$DOTTY_LIB$PSEP"
178184
toolchain+="$SCALA_ASM$PSEP"

dist/bin/scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fi
2828

2929
source "$PROG_HOME/bin/common"
3030

31+
USE_SCALA2_LIBRARY_TASTY=false
3132
while [[ $# -gt 0 ]]; do
3233
case "$1" in
3334
-D*)
@@ -55,6 +56,10 @@ while [[ $# -gt 0 ]]; do
5556
shift
5657
fi
5758
;;
59+
-Yuse-scala2-library-tasty)
60+
USE_SCALA2_LIBRARY_TASTY=true
61+
shift
62+
;;
5863
*)
5964
addScala "$1"
6065
shift
@@ -63,7 +68,7 @@ while [[ $# -gt 0 ]]; do
6368
done
6469

6570
# exec here would prevent onExit from being called, leaving terminal in unusable state
66-
compilerJavaClasspathArgs
71+
compilerJavaClasspathArgs "$USE_SCALA2_LIBRARY_TASTY"
6772
[ -z "${ConEmuPID-}" -o -n "${cygwin-}" ] && export MSYSTEM= PWD= # workaround for #12405
6873
eval "\"$JAVACMD\"" "${java_args[@]}" "-Dscala.home=\"$PROG_HOME\"" "-classpath \"$jvm_cp_args\"" "dotty.tools.MainGenericRunner" "-classpath \"$jvm_cp_args\"" "${scala_args[@]}"
6974
scala_exit_status=$?

dist/bin/scalac

100644100755
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ source "$PROG_HOME/bin/common"
3030

3131
[ -z "$PROG_NAME" ] && PROG_NAME=$CompilerMain
3232

33+
USE_SCALA2_LIBRARY_TASTY=false
34+
3335
while [[ $# -gt 0 ]]; do
3436
case "$1" in
3537
--)
@@ -69,14 +71,18 @@ while [[ $# -gt 0 ]]; do
6971
shift
7072
fi
7173
;;
74+
-Yuse-scala2-library-tasty)
75+
USE_SCALA2_LIBRARY_TASTY=true
76+
shift
77+
;;
7278
*)
7379
addScala "$1"
7480
shift
7581
;;
7682
esac
7783
done
7884

79-
compilerJavaClasspathArgs
85+
compilerJavaClasspathArgs "$USE_SCALA2_LIBRARY_TASTY"
8086

8187
[ -n "$script_trace" ] && set -x
8288
[ -z "${ConEmuPID-}" -o -n "${cygwin-}" ] && export MSYSTEM= PWD= # workaround for #12405

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ object Build {
22042204
def asDist(implicit mode: Mode): Project = project.
22052205
enablePlugins(PackPlugin).
22062206
withCommonSettings.
2207-
dependsOn(`scala3-interfaces`, dottyCompiler, dottyLibrary, tastyCore, `scala3-staging`, `scala3-tasty-inspector`, scaladoc).
2207+
dependsOn(`scala3-interfaces`, dottyCompiler, dottyLibrary, `scala2-library-tasty`, tastyCore, `scala3-staging`, `scala3-tasty-inspector`, scaladoc).
22082208
settings(commonDistSettings).
22092209
bootstrappedSettings(
22102210
target := baseDirectory.value / "target" // override setting in commonBootstrappedSettings

project/scripts/bootstrappedOnlyCmdTests

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,10 @@ sbt_test_command="++${scala_version}!;clean;prepareSources;compile;copyChanges;c
135135
rm -rf "$sbt_test_dir/target"
136136
rm -rf "$sbt_test_dir/project/target"
137137
rm -f "$sbt_test_dir/src/main/scala/a/zz.scala"
138+
139+
# check that `scalac -use-scala2-library-tasty` compiles and `scala -use-scala2-library-tasty` runs it
140+
echo "testing './bin/scalac -Yuse-scala2-library-tasty' and './bin/scala -Yuse-scala2-library-tasty'"
141+
clear_out "$OUT"
142+
./bin/scalac "$SOURCE" -Yuse-scala2-library-tasty -d "$OUT"
143+
./bin/scala -Yuse-scala2-library-tasty -classpath "$OUT" "$MAIN" > "$tmp"
144+
test "$EXPECTED_OUTPUT" = "$(cat "$tmp")"

0 commit comments

Comments
 (0)