Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit 8ec12f6

Browse files
committed
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 scala#4564.
1 parent 4fe9fdc commit 8ec12f6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ abstract class Pasted {
2121
def PromptString: String
2222
def AltPromptString: String = "scala> "
2323

24-
private val testBoth = PromptString != AltPromptString
24+
/* `testBoth` cannot be a val, as `Pasted` is inherited by `object paste` in ILoop,
25+
which would cause `val testBoth` to be initialized before `val PromptString` was.
26+
27+
object paste extends Pasted {
28+
val PromptString = prompt.lines.toList.last
29+
*/
30+
private def testBoth = PromptString != AltPromptString
2531
private val spacey = " \t".toSet
2632

2733
def matchesPrompt(line: String) = matchesString(line, PromptString) || testBoth && matchesString(line, AltPromptString)

0 commit comments

Comments
 (0)