summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeoffrey Washburn <geoffrey.washburn@epfl.ch>2008-02-08 14:46:32 +0000
committerGeoffrey Washburn <geoffrey.washburn@epfl.ch>2008-02-08 14:46:32 +0000
commitf45ea36183741823c69ee47ef252a68b9dce5dd7 (patch)
tree1c6dfcf0e7679bd36a8308ebdc8da66edebf4cb4 /src
parentbaa83f11ee666ff98ddf20dd10a0e8c5a86ee220 (diff)
downloadscala-f45ea36183741823c69ee47ef252a68b9dce5dd7.tar.gz
scala-f45ea36183741823c69ee47ef252a68b9dce5dd7.tar.bz2
scala-f45ea36183741823c69ee47ef252a68b9dce5dd7.zip
Fixed #368:
- added assertions to cause failure earlier - added test case - use BatchSourceFile length (characters) rather than file length (bytes)
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/ScriptRunner.scala6
-rw-r--r--src/compiler/scala/tools/nsc/util/SourceFile.scala6
2 files changed, 9 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala
index 78a63b2b23..d8ea282122 100644
--- a/src/compiler/scala/tools/nsc/ScriptRunner.scala
+++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala
@@ -188,10 +188,12 @@ object ScriptRunner {
val middle = {
val f = new File(filename)
+ val bsf = getSourceFile(new PlainFile(f)).asInstanceOf[BatchSourceFile]
new SourceFileFragment(
- getSourceFile(new PlainFile(f)).asInstanceOf[BatchSourceFile],
+ bsf,
headerLength(filename),
- f.length.asInstanceOf[Int])
+ bsf.length)
+// f.length.asInstanceOf[Int])
}
val end = new BatchSourceFile("<script trailer>", "\n} }\n".toCharArray)
diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala
index e32cde800e..b4cf891a44 100644
--- a/src/compiler/scala/tools/nsc/util/SourceFile.scala
+++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala
@@ -214,7 +214,11 @@ extends BatchSourceFile(name, contents) {
underlyingFile,
start,
stop,
- underlyingFile.content.slice(start, stop).toArray)
+ { assert(start >= 0)
+ assert(start <= stop)
+ assert(start <= underlyingFile.length)
+ assert(stop <= underlyingFile.length)
+ underlyingFile.content.slice(start, stop).toArray })
def this(underlyingFile: BatchSourceFile, start: Int, stop: Int) =
this(