diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-03-20 16:09:04 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-04-27 15:33:20 +0200 |
commit | a8edefcef8905ed3487c7293056f6d0946e79dd7 (patch) | |
tree | 2bcf87b30a70492f4586d2e1dbb98a11bc626223 /test/files/run | |
parent | 403ba8938f115215700e677523d91710c20b6be4 (diff) | |
download | scala-a8edefcef8905ed3487c7293056f6d0946e79dd7.tar.gz scala-a8edefcef8905ed3487c7293056f6d0946e79dd7.tar.bz2 scala-a8edefcef8905ed3487c7293056f6d0946e79dd7.zip |
SI-7271 fixes positions of string interpolation parts
Positions of static parts are now set explicitly during parsing rather
than filled in wholesale during subsequent atPos after parsing.
I also had to change the offsets that scanner uses for initial static
parts of string interpolations so that they no longer point to the
opening double quote, but rather to the actual beginning of the part.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/t7271.check | 12 | ||||
-rw-r--r-- | test/files/run/t7271.scala | 34 |
2 files changed, 46 insertions, 0 deletions
diff --git a/test/files/run/t7271.check b/test/files/run/t7271.check new file mode 100644 index 0000000000..01632eca2c --- /dev/null +++ b/test/files/run/t7271.check @@ -0,0 +1,12 @@ +[[syntax trees at end of parser]] // newSource1 +[0:91]package [0:0]<empty> { + [0:91]class C extends [8:91][91]scala.AnyRef { + [8]def <init>() = [8]{ + [8][8][8]super.<init>(); + [8]() + }; + [16:44]def quote = [28:44]<28:44><28:44>[28]StringContext([30:34]"foo", [40:44]"baz").s([35:39]this); + [51:85]def tripleQuote = [69:85]<69:85><69:85>[69]StringContext([71:75]"foo", [81:85]"baz").s([76:80]this) + } +} + diff --git a/test/files/run/t7271.scala b/test/files/run/t7271.scala new file mode 100644 index 0000000000..6fccf14d20 --- /dev/null +++ b/test/files/run/t7271.scala @@ -0,0 +1,34 @@ +import scala.tools.partest._ +import java.io._ +import scala.tools.nsc._ +import scala.tools.nsc.util.CommandLineParser +import scala.tools.nsc.{Global, Settings, CompilerCommand} +import scala.tools.nsc.reporters.ConsoleReporter + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:parser -Ystop-after:parser -d " + testOutput.path + + override def code = """ + class C { + def quote = s"foo${this}baz" + def tripleQuote = s"foo${this}baz" + } + """.trim + + override def show(): Unit = { + // redirect err to out, for logging + val prevErr = System.err + System.setErr(System.out) + compile() + System.setErr(prevErr) + } + + override def newCompiler(args: String*): Global = { + + val settings = new Settings() + settings.Xprintpos.value = true + val command = new CompilerCommand((CommandLineParser tokenize extraSettings) ++ args.toList, settings) + new Global(command.settings, new ConsoleReporter(settings)) with interactive.RangePositions + } +} |