Skip to content

Commit

Permalink
Merge pull request scala#4598 from newca12/fix-#4066
Browse files Browse the repository at this point in the history
Fix scala#4066 `./bin/dotr -language:Scala2` fails
  • Loading branch information
liufengyun authored May 31, 2018
2 parents 76363fb + 1a0bb90 commit 3ed7421
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
8 changes: 4 additions & 4 deletions dist/bin/dotc
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ case "$1" in
-no-colors) unset colors && shift ;;
-with-compiler) jvm_cp_args="$PSEP$DOTTY_COMP" && shift ;;

# break out -D and -J options and add them to JAVA_OPTS as well
# so they reach the JVM in time to do some good. The -D options
# break out -D and -J options and add them to java_args so
# they reach the JVM in time to do some good. The -D options
# will be available as system properties.
-D*) addJava "$1" && addScala "$1" && shift ;;
-J*) addJava "${1:2}" && addScala "$1" && shift ;;
-D*) addJava "$1" && shift ;;
-J*) addJava "${1:2}" && shift ;;
*) addResidual "$1" && shift ;;
esac
done
Expand Down
18 changes: 14 additions & 4 deletions dist/bin/dotr
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ addJvmOptions () {
jvm_options+=("$1")
}

addDotcOptions () {
java_options+=("$1")
}

source "$PROG_HOME/bin/common"

declare -a residual_args
Expand All @@ -40,6 +44,12 @@ with_compiler=false
class_path_count=0
CLASS_PATH=""

# Little hack to check if all arguments are options
all_params="$*"
truncated_params="${*#-}"
# options_indicator != 0 if at least one parameter is not an option
options_indicator=$(( ${#all_params} - ${#truncated_params} - $# ))

while [[ $# -gt 0 ]]; do
case "$1" in
-repl)
Expand All @@ -65,7 +75,8 @@ while [[ $# -gt 0 ]]; do
shift
;;
-J*)
addJvmOptions "-${1:2}"
addJvmOptions "${1:2}"
addDotcOptions "${1}"
shift ;;
*)
residual_args+=("$1")
Expand All @@ -74,13 +85,12 @@ while [[ $# -gt 0 ]]; do

esac
done

if [ $execute_repl == true ] || ([ $execute_run == false ] && [ ${#residual_args[@]} -eq 0 ]); then
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ $options_indicator == 0 ]); then
if [ "$CLASS_PATH" ]; then
cp_arg="-classpath \"$CLASS_PATH\""
fi
echo "Starting dotty REPL..."
eval "\"$PROG_HOME/bin/dotc\" $cp_arg -repl ${residual_args[@]}"
eval "\"$PROG_HOME/bin/dotc\" $cp_arg ${java_options[@]} -repl ${residual_args[@]}"
elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then
cp_arg="$DOTTY_LIB$PSEP$SCALA_LIB"
if [ -z "$CLASS_PATH" ]; then
Expand Down

0 comments on commit 3ed7421

Please sign in to comment.