Skip to content

Commit f7ea0d0

Browse files
committed
Add failing tests
1 parent 31751b9 commit f7ea0d0

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ class TastyPrinter(bytes: Array[Byte]) {
152152
sb.append(treeStr("%10d".format(addr.index)))
153153
sb.append(s": ${offsetToInt(pos.start)} .. ${pos.end}\n")
154154
}
155+
156+
val sources = posUnpickler.sourcePaths
157+
sb.append(s"\n source paths:\n")
158+
val sortedPath = sources.toSeq.sortBy(_._1.index)
159+
for ((addr, path) <- sortedPath) {
160+
sb.append(treeStr("%10d: ".format(addr.index)))
161+
sb.append(path)
162+
sb.append("\n")
163+
}
164+
155165
sb.result
156166
}
157167
}

project/scripts/cmdTests

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ clear_out "$OUT"
3333
"$SBT" ";scalac -d $OUT/out.jar $SOURCE; scalac -decompile -color:never $OUT/out.jar" > "$tmp"
3434
grep -qe "def main(args: scala.Array\[scala.Predef.String\]): scala.Unit =" "$tmp"
3535

36+
3637
echo "testing that paths SourceFile annotations are relativized"
3738
clear_out "$OUT"
38-
"$SBT" ";scalac -d $OUT/out.jar $(pwd)/$SOURCE; scalac -decompile -color:never $OUT/out.jar" > "$tmp"
39-
grep -qe "SourceFile(\"$SOURCE\")" "$tmp"
39+
"$SBT" "scalac -d $OUT/out.jar -sourceroot tests/pos $(pwd)/tests/pos/i10430/lib.scala $(pwd)/tests/pos/i10430/app.scala"
40+
"$SBT" "scalac -decompile -color:never $OUT/out.jar" > "$tmp"
41+
grep -qe ": lib.scala" "$tmp"
42+
grep -qe ": app.scala" "$tmp"
43+
grep -qe "[lib.scala]" "$tmp"
44+
grep -qe "[app.scala]" "$tmp"
45+
grep -v "tests/pos/i10430/lib.scala" "$tmp"
46+
grep -v "tests/pos/i10430/app.scala" "$tmp"
47+
4048

4149
echo "testing sbt scalac with suspension"
4250
clear_out "$OUT"

tests/pos/i10430/app.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object App {
2+
val y = lib.double(5)
3+
println(y)
4+
}

tests/pos/i10430/lib.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object lib {
2+
inline def double(x: Int): Int = x * x
3+
}

0 commit comments

Comments
 (0)