From 0b121d1864a3db1b34e5102e8258984ad0e8fd53 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 27 Aug 2015 10:43:38 +1000 Subject: SI-9450 Fix triple quoted strings in REPL :power mode Some extra synthetic code generated under this mode failed to escape input before adding it to a literal string. It used to get away with this most of the time by triple quoting the literal. This commit reuses Scala string escaping logic buried in `Constant` to do this properly. Actually, the proper approach would be to build the synthetic code with trees and quasiquotes, and avoid the mess of stringly-genererated code. I threw in some defensive hygiene for the reference to `Nil` while I was in the neighbourhood. --- test/files/run/repl-power.check | 3 +++ test/files/run/repl-power.scala | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 2a7b7783d9..4e030bd9fa 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -25,4 +25,7 @@ m: $r.treedsl.global.Literal = 10 scala> typed(m).tpe // typed is in scope res2: $r.treedsl.global.Type = Int(10) +scala> """escaping is hard, m'kah""" +res3: String = escaping is hard, m'kah + scala> :quit diff --git a/test/files/run/repl-power.scala b/test/files/run/repl-power.scala index 4dfeb37885..5ecaad8723 100644 --- a/test/files/run/repl-power.scala +++ b/test/files/run/repl-power.scala @@ -1,7 +1,9 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { - def code = """ + def tripleQuote(s: String) = "\"\"\"" + s + "\"\"\"" + + def code = s""" :power // guarding against "error: reference to global is ambiguous" global.emptyValDef // "it is imported twice in the same scope by ..." @@ -9,5 +11,6 @@ val tp = ArrayClass[scala.util.Random] // magic with tags tp.memberType(Array_apply) // evidence val m = LIT(10) // treedsl typed(m).tpe // typed is in scope +${tripleQuote("escaping is hard, m'kah")} """.trim } -- cgit v1.2.3