From 0152dbe969520914ce1730c4a81597bc362c9c5b Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Tue, 15 May 2012 09:40:23 +0200 Subject: Fixed SI-5603. Early definitions now get transparent positions. This includes a fix for a minor problem described in #594 - ensureNonOverlapping still focuses on default position when outside of early defs. Review by @dragos, @odersky. --- test/files/run/t5603.check | 29 +++++++++++++++++++++++++++++ test/files/run/t5603.scala | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 test/files/run/t5603.check create mode 100644 test/files/run/t5603.scala (limited to 'test/files/run') diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check new file mode 100644 index 0000000000..5127d3c1c7 --- /dev/null +++ b/test/files/run/t5603.check @@ -0,0 +1,29 @@ +[[syntax trees at end of parser]] // newSource1 +[0:241]package [0:0] { + [0:82]abstract trait Greeting extends [15:82][83]scala.AnyRef { + [15]def $init$() = [15]{ + [15]() + }; + [23:39]val name: [33:39]String; + [46:76]val msg = [56:76][56:72][56:71]"How are you, ".$plus([72:76]name) + }; + [87:209]class C extends [94:209][151:159]Greeting { + [119:139]val nameElse = _; + [95:101] private[this] val i: [98:101]Int = _; + <119:139>def ([95]i: [98]Int) = <119:139>{ + <119:139>val nameElse = <134:139>"Bob"; + [94][94][94]super.(); + [94]() + }; + [168:184]val name = [179:184]"avc"; + [191:203][191:198]println([199:202]msg) + }; + [215:241]object Test extends [227:241][235:238]App { + [227]def () = [227]{ + [227][227][227]super.(); + [227]() + }; + [NoPosition] + } +} + diff --git a/test/files/run/t5603.scala b/test/files/run/t5603.scala new file mode 100644 index 0000000000..60dfd01fee --- /dev/null +++ b/test/files/run/t5603.scala @@ -0,0 +1,42 @@ +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 = """ + trait Greeting { + val name: String + val msg = "How are you, "+name + } + class C(i: Int) extends { + val nameElse = "Bob" + } with Greeting { + val name = "avc" + println(msg) + } + + object Test extends App {} + """.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 + } +} -- cgit v1.2.3