From 8ec12f60264fcd4f1203d778866220834e818e34 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 2 Jul 2015 11:53:14 -0700 Subject: 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. --- src/repl/scala/tools/nsc/interpreter/Pasted.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/repl') 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) -- cgit v1.2.3