Skip to content

Commit 3ed7421

Browse files
authored
Merge pull request #4598 from newca12/fix-#4066
Fix #4066 `./bin/dotr -language:Scala2` fails
2 parents 76363fb + 1a0bb90 commit 3ed7421

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

dist/bin/dotc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ case "$1" in
9393
-no-colors) unset colors && shift ;;
9494
-with-compiler) jvm_cp_args="$PSEP$DOTTY_COMP" && shift ;;
9595

96-
# break out -D and -J options and add them to JAVA_OPTS as well
97-
# so they reach the JVM in time to do some good. The -D options
96+
# break out -D and -J options and add them to java_args so
97+
# they reach the JVM in time to do some good. The -D options
9898
# will be available as system properties.
99-
-D*) addJava "$1" && addScala "$1" && shift ;;
100-
-J*) addJava "${1:2}" && addScala "$1" && shift ;;
99+
-D*) addJava "$1" && shift ;;
100+
-J*) addJava "${1:2}" && shift ;;
101101
*) addResidual "$1" && shift ;;
102102
esac
103103
done

dist/bin/dotr

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ addJvmOptions () {
3131
jvm_options+=("$1")
3232
}
3333

34+
addDotcOptions () {
35+
java_options+=("$1")
36+
}
37+
3438
source "$PROG_HOME/bin/common"
3539

3640
declare -a residual_args
@@ -40,6 +44,12 @@ with_compiler=false
4044
class_path_count=0
4145
CLASS_PATH=""
4246

47+
# Little hack to check if all arguments are options
48+
all_params="$*"
49+
truncated_params="${*#-}"
50+
# options_indicator != 0 if at least one parameter is not an option
51+
options_indicator=$(( ${#all_params} - ${#truncated_params} - $# ))
52+
4353
while [[ $# -gt 0 ]]; do
4454
case "$1" in
4555
-repl)
@@ -65,7 +75,8 @@ while [[ $# -gt 0 ]]; do
6575
shift
6676
;;
6777
-J*)
68-
addJvmOptions "-${1:2}"
78+
addJvmOptions "${1:2}"
79+
addDotcOptions "${1}"
6980
shift ;;
7081
*)
7182
residual_args+=("$1")
@@ -74,13 +85,12 @@ while [[ $# -gt 0 ]]; do
7485

7586
esac
7687
done
77-
78-
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ ${#residual_args[@]} -eq 0 ]); then
88+
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ $options_indicator == 0 ]); then
7989
if [ "$CLASS_PATH" ]; then
8090
cp_arg="-classpath \"$CLASS_PATH\""
8191
fi
8292
echo "Starting dotty REPL..."
83-
eval "\"$PROG_HOME/bin/dotc\" $cp_arg -repl ${residual_args[@]}"
93+
eval "\"$PROG_HOME/bin/dotc\" $cp_arg ${java_options[@]} -repl ${residual_args[@]}"
8494
elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then
8595
cp_arg="$DOTTY_LIB$PSEP$SCALA_LIB"
8696
if [ -z "$CLASS_PATH" ]; then

0 commit comments

Comments
 (0)