Skip to content

Commit 9410142

Browse files
committed
Fix #4066 ./bin/dotr -language:Scala2 fails
1 parent 4e5cf82 commit 9410142

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

dist/bin/dotc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ case "$1" in
9595
# break out -D and -J options and add them to JAVA_OPTS as well
9696
# so they reach the JVM in time to do some good. The -D options
9797
# will be available as system properties.
98-
-D*) addJava "$1" && addScala "$1" && shift ;;
99-
-J*) addJava "${1:2}" && addScala "$1" && shift ;;
98+
-D*) addJava "$1" && shift ;;
99+
-J*) addJava "${1:2}" && shift ;;
100100
*) addResidual "$1" && shift ;;
101101
esac
102102
done

dist/bin/dotr

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

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

3640
declare -a residual_args
@@ -40,6 +44,11 @@ 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+
not_only_options=$(( ${#all_params} - ${#truncated_params} - $# ))
51+
4352
while [[ $# -gt 0 ]]; do
4453
case "$1" in
4554
-repl)
@@ -65,7 +74,8 @@ while [[ $# -gt 0 ]]; do
6574
shift
6675
;;
6776
-J*)
68-
addJvmOptions "-${1:2}"
77+
addJvmOptions "${1:2}"
78+
addRawJvmOptions "${1}"
6979
shift ;;
7080
*)
7181
residual_args+=("$1")
@@ -74,13 +84,12 @@ while [[ $# -gt 0 ]]; do
7484

7585
esac
7686
done
77-
78-
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ ${#residual_args[@]} -eq 0 ]); then
87+
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ $not_only_options == 0 ]); then
7988
if [ "$CLASS_PATH" ]; then
8089
cp_arg="-classpath \"$CLASS_PATH\""
8190
fi
8291
echo "Starting dotty REPL..."
83-
eval "\"$PROG_HOME/bin/dotc\" $cp_arg -repl ${residual_args[@]}"
92+
eval "\"$PROG_HOME/bin/dotc\" $cp_arg ${java_options[@]} -repl ${residual_args[@]}"
8493
elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then
8594
cp_arg="$DOTTY_LIB$PSEP$SCALA_LIB"
8695
if [ -z "$CLASS_PATH" ]; then

0 commit comments

Comments
 (0)