diff options
-rw-r--r-- | build.xml | 81 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/Main.scala | 13 | ||||
-rwxr-xr-x | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 2 | ||||
-rwxr-xr-x | src/compiler/scala/tools/nsc/interactive/Global.scala | 25 | ||||
-rwxr-xr-x | src/compiler/scala/tools/nsc/interactive/RangePositions.scala | 8 | ||||
-rw-r--r-- | test/files/positions/Anon.scala | 9 | ||||
-rw-r--r-- | test/files/positions/Enclosing1.scala | 5 | ||||
-rw-r--r-- | test/files/positions/Enclosing2.scala | 5 | ||||
-rw-r--r-- | test/files/positions/Enclosing3.scala | 1 | ||||
-rw-r--r-- | test/files/positions/Overlap1.scala | 5 | ||||
-rw-r--r-- | test/files/positions/Overlap2.scala | 3 | ||||
-rw-r--r-- | test/files/positions/SyntheticNonSynthetic1.scala | 3 | ||||
-rw-r--r-- | test/files/positions/SyntheticNonSynthetic2.scala | 3 | ||||
-rw-r--r-- | test/files/positions/Unpositioned1.scala | 3 |
14 files changed, 138 insertions, 28 deletions
@@ -1739,9 +1739,88 @@ FORWARDED TARGETS FOR NIGHTLY BUILDS </target> <!-- =========================================================================== -MISCELLANEOUS +POSITIONS ============================================================================ --> + <target name="test.positions" depends="pack.done"> + <antcall target="test.positions.sub" inheritRefs="true"> + <param name="test.srcs" value="${src.dir}/compiler"/> + </antcall> + <antcall target="test.positions.sub" inheritRefs="true"> + <param name="test.srcs" value="${src.dir}/library"/> + </antcall> + <antcall target="test.positions.sub" inheritRefs="true"> + <param name="test.srcs" value="${src.dir}/actors"/> + </antcall> + <antcall target="test.positions.sub" inheritRefs="true"> + <param name="test.srcs" value="${src.dir}/dbc"/> + </antcall> + <antcall target="test.positions.sub" inheritRefs="true"> + <param name="test.srcs" value="${src.dir}/swing"/> + </antcall> + <antcall target="test.positions.sub" inheritRefs="true"> + <param name="test.srcs" value="${src.dir}/partest"/> + </antcall> + <antcall target="test.positions.sub" inheritRefs="true"> + <param name="test.srcs" value="${src.dir}/scalap"/> + </antcall> + <antcall target="test.positions.tests.sub" inheritRefs="true"> + <param name="test.tests.srcs" value="${test.dir}/files/positions"/> + </antcall> + <antcall target="test.positions.tests.sub" inheritRefs="true"> + <param name="test.tests.srcs" value="${test.dir}/files/pos"/> + </antcall> + <antcall target="test.positions.tests.sub" inheritRefs="true"> + <param name="test.tests.srcs" value="${test.dir}/files/run"/> + </antcall> + <antcall target="test.positions.tests.sub" inheritRefs="true"> + <param name="test.tests.srcs" value="${test.dir}/files/neg"/> + </antcall> + </target> + + <target name="test.positions.sub"> + <echo message="Validating positions for: ${test.srcs}"/> + <if> + <isfileselected file="${test.srcs}"> + <type type="dir"/> + </isfileselected> + <then> + <property name="srcdir" value="${test.srcs}"/> + <property name="srcs" value="**/*.scala"/> + </then> + <else> + <dirname property="srcdir" file="${test.srcs}"/> + <basename property="srcs" file="${test.srcs}"/> + </else> + </if> + <scalacfork + destdir="" + compilerpathref="pack.classpath" + srcdir="${srcdir}" + params="-Xprint-pos -Yide-debug" + jvmargs="${scalacfork.jvmargs}"> + <include name="${srcs}"/> + </scalacfork> + </target> + + <target name="test.positions.tests.sub"> + <foreach target="test.positions.sub" + inheritAll="true" + inheritRefs="true" + param="test.srcs"> + <path> + <fileset dir="${test.tests.srcs}" includes="*.scala"/> + <dirset dir="${test.tests.srcs}"> + <include name="*"/> + </dirset> + </path> + </foreach> + </target> + + <!-- =========================================================================== + MISCELLANEOUS + ============================================================================ --> + <target name="graph.init"> <taskdef name="vizant" classname="vizant.Vizant" classpath="${lib-ant.dir}/vizant.jar"/> </target> diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index 8a26fb2626..f46ab29e37 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -49,22 +49,17 @@ object Main extends AnyRef with EvalLoop { if (command.settings.version.value) reporter.info(null, versionMsg, true) else if (command.settings.Yidedebug.value) { - command.settings.Xprintpos.value = true val compiler = new interactive.Global(command.settings, reporter) - import compiler._ + import compiler.{ reporter => _, _ } val sfs = command.files.map(getSourceFile(_)) val reloaded = new SyncVar[Either[Unit, Throwable]] askReload(sfs, reloaded) reloaded.get.right.toOption match { - case Some(thr) => logError("Failure in presentation compiler", thr) - case _ => - } - for (sf <- sfs) { - val cu = unitOf(sf) - val tree = cu.body - treePrinters.create(System.out).print(tree) + case Some(ex) => reporter.cancelled = true // Causes exit code to be non-0 + case None => reporter.reset // Causes other compiler errors to be ignored } + askShutdown } else { if (command.settings.target.value == "msil") { diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index f18ac77ed4..129e974e76 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2183,8 +2183,8 @@ self => val savedViews = implicitClassViews val implicitViewBuf = new ListBuffer[Tree] val tparams = typeParamClauseOpt(name, implicitViewBuf) - val tstart = in.offset implicitClassViews = implicitViewBuf.toList + val tstart = (in.offset::implicitClassViews.map(_.pos.start)).min if (!implicitClassViews.isEmpty && mods.hasFlag(Flags.TRAIT)) { syntaxError("traits cannot have type parameters with <% bounds", false) implicitClassViews = List() diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 04f3e63ef9..2f74e1635f 100755 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -26,8 +26,6 @@ self => override def onlyPresentation = true - settings.Xprintpos.value = true - /** A list indicating in which order some units should be typechecked. * All units in firsts are typechecked before any unit not in this list * Modified by askToDoFirst, reload, typeAtTree. @@ -122,14 +120,14 @@ self => case Some(action) => try { acting = true - println("picked up work item: "+action) + //println("picked up work item: "+action) action() - println("done with work item: "+action) + //println("done with work item: "+action) } catch { case ex: CancelActionReq => - println("cancelled work item: "+action) + //println("cancelled work item: "+action) } finally { - println("quitting work item: "+action) + //println("quitting work item: "+action) acting = false } case None => @@ -197,10 +195,12 @@ self => case ex: ShutdownReq => ; case ex => - ex.printStackTrace() outOfDate = false - inform("Fatal Error: "+ex) compileRunner = newRunnerThread + ex match { + case _ : ValidateError => // This will have been reported elsewhere + case _ => inform("Fatal Error: "+ex) + } } } start() @@ -209,13 +209,13 @@ self => /** Compile all given units */ private def backgroundCompile() { - inform("Starting new presentation compiler type checking pass") + //inform("Starting new presentation compiler type checking pass") reporter.reset firsts = firsts filter (s => unitOfFile contains (s.file)) val prefix = firsts map unitOf val units = prefix ::: (unitOfFile.values.toList diff prefix) recompile(units) - inform("Everything is now up to date") + //inform("Everything is now up to date") } /** Reset unit to just-parsed state */ @@ -244,11 +244,11 @@ self => def recompile(units: List[RichCompilationUnit]) { for (unit <- units) { reset(unit) - inform("parsing: "+unit) + //inform("parsing: "+unit) parse(unit) } for (unit <- units) { - inform("type checking: "+unit) + //inform("type checking: "+unit) activeLocks = 0 currentTyperRun.typeCheck(unit) unit.status = currentRunId @@ -277,7 +277,6 @@ self => val unit = new RichCompilationUnit(source) unitOfFile(source.file) = unit parse(unit) - if (settings.Xprintpos.value) treePrinter.print(unit) } moveToFront(sources) } diff --git a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala index d195e1c157..527efae4b5 100755 --- a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala +++ b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala @@ -145,12 +145,12 @@ self: scala.tools.nsc.Global => } else { val splitNode = if (conflicting.size == 1 && (conflicting.head.pos includes tree.pos)) { - println("*** splitting \n"+conflicting.head+"\n--- because it conflicts with ---\n"+tree) - println(tree.id) + //println("*** splitting \n"+conflicting.head+"\n--- because it conflicts with ---\n"+tree) + //println(tree.id) conflicting.head } else { - println("*** splitting \n"+tree+"\n--- because it conflicts with trees in ---\n"+conflicting) - println(tree.id) + //println("*** splitting \n"+tree+"\n--- because it conflicts with trees in ---\n"+conflicting) + //println(tree.id) tree } //throw new Error()//debug diff --git a/test/files/positions/Anon.scala b/test/files/positions/Anon.scala new file mode 100644 index 0000000000..940fff035a --- /dev/null +++ b/test/files/positions/Anon.scala @@ -0,0 +1,9 @@ +object Anon { + trait Foo { + val bar : Int + } + + def foo = new Foo { + override val bar = 23 + } +} diff --git a/test/files/positions/Enclosing1.scala b/test/files/positions/Enclosing1.scala new file mode 100644 index 0000000000..e170187d60 --- /dev/null +++ b/test/files/positions/Enclosing1.scala @@ -0,0 +1,5 @@ +object Enclosing1 { + do { + + } while (true) +} diff --git a/test/files/positions/Enclosing2.scala b/test/files/positions/Enclosing2.scala new file mode 100644 index 0000000000..502df5dc97 --- /dev/null +++ b/test/files/positions/Enclosing2.scala @@ -0,0 +1,5 @@ +object Enclosing2 { + + class C + trait T { this : C => } +} diff --git a/test/files/positions/Enclosing3.scala b/test/files/positions/Enclosing3.scala new file mode 100644 index 0000000000..a6fbd4bb20 --- /dev/null +++ b/test/files/positions/Enclosing3.scala @@ -0,0 +1 @@ +class Enclosing3[T <% String] {} diff --git a/test/files/positions/Overlap1.scala b/test/files/positions/Overlap1.scala new file mode 100644 index 0000000000..6fda17d861 --- /dev/null +++ b/test/files/positions/Overlap1.scala @@ -0,0 +1,5 @@ +object Overlap1 { + val l = List("foo") + val p = true + for(e <- l if p) yield e.length +} diff --git a/test/files/positions/Overlap2.scala b/test/files/positions/Overlap2.scala new file mode 100644 index 0000000000..4b77d04972 --- /dev/null +++ b/test/files/positions/Overlap2.scala @@ -0,0 +1,3 @@ +object Overlap2 { + for(a <- Some("foo") ; (b, c) = (1, 2)) {} +} diff --git a/test/files/positions/SyntheticNonSynthetic1.scala b/test/files/positions/SyntheticNonSynthetic1.scala new file mode 100644 index 0000000000..0d87c8ae79 --- /dev/null +++ b/test/files/positions/SyntheticNonSynthetic1.scala @@ -0,0 +1,3 @@ +object SyntheticNonSynthetic1 { + val foo : List[Class[_ <: Throwable]] = Nil +} diff --git a/test/files/positions/SyntheticNonSynthetic2.scala b/test/files/positions/SyntheticNonSynthetic2.scala new file mode 100644 index 0000000000..ba53186f84 --- /dev/null +++ b/test/files/positions/SyntheticNonSynthetic2.scala @@ -0,0 +1,3 @@ +object SyntheticNonSynthetic2 { + def foo[A >: Exception] (a : A) {} +} diff --git a/test/files/positions/Unpositioned1.scala b/test/files/positions/Unpositioned1.scala new file mode 100644 index 0000000000..7fc520e93c --- /dev/null +++ b/test/files/positions/Unpositioned1.scala @@ -0,0 +1,3 @@ +object Unpositioned1 { + for (a <- Some("foo") ; val b = true) {} +} |