Skip to content

Commit 2c1d1ad

Browse files
committed
Merge pull request scala#5115 from lrytz/merge-2.11-to-2.12-apr-22
Merge 2.11 to 2.12 apr 22
2 parents cdc011f + 6eef42e commit 2c1d1ad

File tree

16 files changed

+193
-35
lines changed

16 files changed

+193
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Here, `<milestone>` is the milestone targeted by the PR (e.g., 2.11.6), and `<sh
131131

132132
## IDE Setup
133133
### Eclipse
134-
See `src/eclipse/README.md`.
134+
See [src/eclipse/README.md](src/eclipse/README.md).
135135

136136
### IntelliJ 15
137137
See [src/intellij/README.md](src/intellij/README.md).

src/eclipse/README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ The following points describe how to build Scala using Eclipse.
77

88
0. Download the [Scala IDE bundle](http://scala-ide.org/download/sdk.html). It comes preconfigured for optimal performance.
99

10-
0. Run `ant init` to download some necessary jars.
11-
12-
0. Import the project (in `src/eclipse`) via `File``Import Existing Projects` and navigate to `scala/src/eclipse`. Check all projects and click ok.
13-
14-
0. You need to define a `path variable` inside Eclipse. Define `SCALA_BASEDIR` in
15-
`Preferences/General/Workspace/Linked Resources`. The value should be the absolute
16-
path to your Scala checkout. All paths in the project files are relative to this one,
17-
so nothing will work before you do so.
18-
19-
The same `SCALA_BASEDIR` variable needs to be defined as a `classpath variable` in
10+
0. Run `ant build` to download some necessary jars and see a successful build.
11+
12+
0. You need to define a `path variable` and a `classpath variable` inside Eclipse, both pointing to the Scala checkout directory:
13+
- (experimental): run `./update-workspace.sh scala_checkout_dir [workspace_dir]`. This should update your workspace settings
14+
(restart Eclipse if it was running). For example:
15+
```
16+
./update-workspace.sh $HOME/git/scala ~/Documents/workspace-scalac
17+
```
18+
- If the above didn't work, you can perform these steps manually: Define `SCALA_BASEDIR` in `Preferences/General/Workspace/Linked Resources`. The value should be the absolute
19+
path to your Scala checkout. All paths in the project files are relative to this one, so nothing will work before you do so.
20+
The same `SCALA_BASEDIR` variable needs to be defined **also** as a `classpath variable` in
2021
`Java/Build Path/Classpath Variables`.
2122

22-
Additionally, we start using Maven dependencies (e.g. `JUnit`) so you need to define another
23-
`classpath variable` inside Eclipse. Define `M2_REPO` in `Java/Build Path/Classpath Variables`
24-
to point to your local Maven repository (e.g. `$HOME/.m2/repository`).
23+
0. Import the project (in `src/eclipse`) via `File``Import Existing Projects` and navigate to `scala/src/eclipse`. Check all projects and click ok.
2524

2625
Lastly, the JRE used by Eclipse needs to know the path to the `JLine` library, which is used by the REPL.
2726
To set the JAR file, navigate to `Java/Installed JREs`, select the default JRE, press `Edit/Add External JARs...`

src/eclipse/interactive/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentry kind="src" path="interactive"/>
4+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
45
<classpathentry combineaccessrules="false" kind="src" path="/scaladoc"/>
56
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
67
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
78
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
8-
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
99
<classpathentry kind="output" path="build-quick-interactive"/>
1010
</classpath>

src/eclipse/partest/.classpath

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentry kind="src" path="partest-extras"/>
4+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
45
<classpathentry combineaccessrules="false" kind="src" path="/repl"/>
5-
<classpathentry kind="var" path="M2_REPO/com/googlecode/java-diff-utils/diffutils/1.3.0/diffutils-1.3.0.jar"/>
6-
<classpathentry kind="var" path="M2_REPO/org/scala-sbt/test-interface/1.0/test-interface-1.0.jar"/>
7-
<classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.12.0-M2/1.0.9/scala-partest_2.12.0-M2-1.0.9.jar"/>
6+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/partest/diffutils-1.3.0.jar"/>
7+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/partest/test-interface-1.0.jar"/>
88
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
99
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
1010
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
1111
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
12-
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
12+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/partest/scala-partest_2.12.0_M4-1.0.13.jar"/>
1313
<classpathentry kind="output" path="build-quick-partest-extras"/>
1414
</classpath>

src/eclipse/reflect/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
<classpathentry kind="src" path="reflect"/>
44
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
55
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6+
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
67
<classpathentry kind="output" path="build-quick-reflect"/>
78
</classpath>

src/eclipse/repl/.classpath

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentry kind="src" path="repl"/>
4-
<classpathentry kind="var" path="M2_REPO/jline/jline/2.12.1/jline-2.12.1.jar"/>
4+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
5+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/repl/jline-2.12.1.jar"/>
56
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
67
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
78
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
8-
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
9+
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
10+
<classpathentry combineaccessrules="false" kind="src" path="/interactive"/>
911
<classpathentry kind="output" path="build-quick-repl"/>
1012
</classpath>

src/eclipse/scala-compiler/.classpath

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/reflect"/>
55
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scala-library"/>
66
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
7-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
87
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
8+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
9+
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
910
<classpathentry kind="output" path="build-quick-compiler"/>
1011
</classpath>

src/eclipse/scaladoc/.classpath

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
<classpath>
33
<classpathentry kind="src" path="scaladoc"/>
44
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
5+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
56
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
67
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
78
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
8-
<classpathentry combineaccessrules="false" kind="src" path="/partest-extras"/>
9-
<classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.12.0-M2/1.0.5/scala-xml_2.12.0-M2-1.0.5.jar"/>
10-
<classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-parser-combinators_2.12.0-M2/1.0.4/scala-parser-combinators_2.12.0-M2-1.0.4.jar"/>
11-
<classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.12.0-M2/1.0.9/scala-partest_2.12.0-M2-1.0.9.jar"/>
12-
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
9+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/scaladoc/scala-xml_2.12.0_M4-1.0.5.jar"/>
10+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/scaladoc/scala-parser-combinators_2.12.0_M4-1.0.4.jar"/>
11+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/partest/scala-partest_2.12.0_M4-1.0.13.jar"/>
1312
<classpathentry kind="output" path="build-quick-scaladoc"/>
1413
</classpath>

src/eclipse/test-junit/.classpath

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentry kind="src" path="test-junit"/>
4+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
45
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
5-
<classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/reflect"/>
77
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
88
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
99
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
1010
<classpathentry combineaccessrules="false" kind="src" path="/repl"/>
11-
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/asm/scala-asm-5.0.4-scala-3.jar"/>
1211
<classpathentry combineaccessrules="false" kind="src" path="/partest-extras"/>
1312
<classpathentry combineaccessrules="false" kind="src" path="/scaladoc"/>
14-
<classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.12.0-M2/1.0.5/scala-xml_2.12.0-M2-1.0.5.jar"/>
13+
<classpathentry kind="var" path="SCALA_BASEDIR/build/deps/scaladoc/scala-xml_2.12.0_M4-1.0.5.jar"/>
14+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
1515
<classpathentry kind="output" path="build-test-junit"/>
1616
</classpath>

src/eclipse/update-workspace.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
function usage() {
4+
echo "$0 scala_checkout_dir [workspace_dir]"
5+
echo "\n Add necessary path variables to Eclipse workspace settings for Scalac to build"
6+
}
7+
8+
METADATA_DIR=`pwd`/.metadata
9+
10+
if [ $# -lt 1 ]; then
11+
echo "Need the Scala directory checkout as argument"
12+
exit 1
13+
fi
14+
15+
SCALA_DIR=$1
16+
17+
if [ ! -z $2 ]; then
18+
METADATA_DIR=$2/.metadata
19+
fi
20+
21+
if [ ! -d $METADATA_DIR ]; then
22+
echo "$METADATA_DIR is not a directory"
23+
exit 1
24+
fi
25+
26+
echo "Using metadata directory $METADATA_DIR and Scala checkout $SCALA_DIR"
27+
28+
CORE_PREFS=$METADATA_DIR/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs
29+
if [ ! -f $CORE_PREFS ]; then
30+
echo "Couldn't find $CORE_PREFS. Is $METADATA_DIR an Eclipse workspace?"
31+
exit 1
32+
fi
33+
echo -e "Workspace preferences:\t$CORE_PREFS"
34+
35+
JDT_PREFS=$METADATA_DIR/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs
36+
if [ ! -f $JDT_PREFS ]; then
37+
echo "Couldn't find $JDT_PREFS. Creating fresh file."
38+
touch $JDT_PREFS
39+
fi
40+
echo -e "JDT preferences:\t$JDT_PREFS"
41+
42+
# $1 - preference file (will be backed-up before writing)
43+
# $2 - preference key
44+
# $3 - preference value
45+
function updatePref() {
46+
mv $1 ${1}_backup
47+
48+
awk -v key=$2 -v value=$3 '
49+
BEGIN {
50+
FS="=";
51+
OFS="=";
52+
prev=""
53+
}
54+
{
55+
if ($1 == key) {
56+
prev=$2
57+
$2=value
58+
}
59+
print
60+
}
61+
END {
62+
if (prev) {
63+
printf "Updated existing value from %s to %s\n", prev, value > "/dev/stderr"
64+
} else {
65+
print key,value
66+
}
67+
}
68+
' ${1}_backup >$1
69+
}
70+
71+
updatePref $CORE_PREFS "pathvariable.SCALA_BASEDIR" $SCALA_DIR
72+
updatePref $JDT_PREFS "org.eclipse.jdt.core.classpathVariable.SCALA_BASEDIR" $SCALA_DIR

src/repl/scala/tools/nsc/interpreter/Imports.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ trait Imports {
183183
case _ =>
184184
val valName = req.lineRep.packageName + req.lineRep.readName
185185
if (!tempValLines.contains(req.lineRep.lineId)) {
186-
code.append(s"val $valName = $objName\n")
186+
code.append(s"val $valName: ${objName}.type = $objName\n")
187187
tempValLines += req.lineRep.lineId
188188
}
189189
code.append(s"import $valName${req.accessPath}.`$imv`;\n")

src/repl/scala/tools/nsc/interpreter/ReplStrings.scala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ import scala.reflect.internal.Chars
1111
trait ReplStrings {
1212
/** Convert a string into code that can recreate the string.
1313
* This requires replacing all special characters by escape
14-
* codes. It does not add the surrounding " marks. */
14+
* codes. It does not add the surrounding " marks.
15+
*/
1516
def string2code(str: String): String = {
1617
val res = new StringBuilder
1718
for (c <- str) c match {
18-
case '"' | '\'' | '\\' => res += '\\' ; res += c
19-
case _ if c.isControl => res ++= Chars.char2uescape(c)
20-
case _ => res += c
19+
case '"' => res ++= """\""""
20+
case '\'' => res ++= """\'"""
21+
case '\\' => res ++= """\\"""
22+
case '\b' => res ++= """\b"""
23+
case '\t' => res ++= """\t"""
24+
case '\n' => res ++= """\n"""
25+
case '\f' => res ++= """\f"""
26+
case '\r' => res ++= """\r"""
27+
case _ if c.isControl => res ++= Chars.char2uescape(c)
28+
case _ => res += c
2129
}
2230
res.toString
2331
}

test/files/run/repl-no-uescape.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
scala> object A
3+
defined object A
4+
5+
scala> :quit

test/files/run/repl-no-uescape.scala

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import scala.tools.partest.ReplTest
2+
import scala.tools.nsc.Settings
3+
4+
/*
5+
scala> object A
6+
<console>:10: error: invalid escape character
7+
+ "defined object " + "A" + "\u000A"
8+
9+
Under -Dscala.color=true control chars are common
10+
$eval.this.$print = {
11+
$line2.$read.$iw.$iw;
12+
"\033[1m\033[34mres1\033[0m: \033[1m\033[32mInt\033[0m = ".+(scala.runtime.ScalaRunTime.replStringOf($line2.$read.$iw.$iw.res1, 1000))
13+
};
14+
15+
$ skala -Dscala.color=true -Xno-uescape
16+
Welcome to Scala 2.11.9-20160323-163638-1fcfdd8c8b (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_60).
17+
Type in expressions for evaluation. Or try :help.
18+
19+
scala> 42
20+
<console>:10: error: invalid escape character
21+
+ "\u001B[1m\u001B[34mres0\u001B[0m: \u001B[1m\u001B[32mInt\u001B[0m = " + scala.runtime.ScalaRunTime.replStringOf(res0, 1000)
22+
*/
23+
object Test extends ReplTest {
24+
override def transformSettings(settings: Settings): Settings = {
25+
settings.nouescape.value = true
26+
settings
27+
}
28+
def code = """
29+
object A
30+
"""
31+
}

test/files/run/repl-paste-6.check

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
scala> :paste < EOF
3+
// Entering paste mode (EOF to finish)
4+
5+
case class C(i: Int)
6+
val c = C(42)
7+
EOF
8+
9+
// Exiting paste mode, now interpreting.
10+
11+
defined class C
12+
c: C = C(42)
13+
14+
scala> val d: C = c // shew
15+
d: C = C(42)
16+
17+
scala> :quit

test/files/run/repl-paste-6.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import scala.tools.partest.ReplTest
3+
import scala.tools.nsc.Settings
4+
5+
6+
/*
7+
* Add // show to witness:
8+
* val $line3$read: $line3.$read.INSTANCE.type = $line3.$read.INSTANCE;
9+
*/
10+
object Test extends ReplTest {
11+
override def transformSettings(settings: Settings): Settings = {
12+
settings.Yreplclassbased.value = true
13+
settings
14+
}
15+
def code =
16+
"""
17+
:paste < EOF
18+
case class C(i: Int)
19+
val c = C(42)
20+
EOF
21+
val d: C = c // shew
22+
"""
23+
}

0 commit comments

Comments
 (0)