diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-07-02 11:53:14 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-07-02 11:54:56 -0700 |
commit | 8ec12f60264fcd4f1203d778866220834e818e34 (patch) | |
tree | d3da8e1a7caa4c5937e5eb86f043d0010e5fd855 /src | |
parent | 4fe9fdc4cfde60e02805f4079cf74682c4550de6 (diff) | |
download | scala-8ec12f60264fcd4f1203d778866220834e818e34.tar.gz scala-8ec12f60264fcd4f1203d778866220834e818e34.tar.bz2 scala-8ec12f60264fcd4f1203d778866220834e818e34.zip |
Correct init order between Pasted and ILoop#pasted
`testBoth` cannot be a val in `Pasted`, as `Pasted` is inherited
by `object paste` in ILoop, which would cause `val testBoth` to
be initialized before `val PromptString` was:
```
object paste extends Pasted {
val PromptString = prompt.lines.toList.last
```
See https://scala-webapps.epfl.ch/jenkins/job/scala-nightly-checkinit-2.11.x/417.
Introduced by #4564.
Diffstat (limited to 'src')
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/Pasted.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/Pasted.scala b/src/repl/scala/tools/nsc/interpreter/Pasted.scala index 5f388eb15b..f8d8c2ddb1 100644 --- a/src/repl/scala/tools/nsc/interpreter/Pasted.scala +++ b/src/repl/scala/tools/nsc/interpreter/Pasted.scala @@ -21,7 +21,13 @@ abstract class Pasted { def PromptString: String def AltPromptString: String = "scala> " - private val testBoth = PromptString != AltPromptString + /* `testBoth` cannot be a val, as `Pasted` is inherited by `object paste` in ILoop, + which would cause `val testBoth` to be initialized before `val PromptString` was. + + object paste extends Pasted { + val PromptString = prompt.lines.toList.last + */ + private def testBoth = PromptString != AltPromptString private val spacey = " \t".toSet def matchesPrompt(line: String) = matchesString(line, PromptString) || testBoth && matchesString(line, AltPromptString) |