File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -238,9 +238,10 @@ object Inliner {
238
238
class Reposition extends TreeMap (cpyWithNewSource) {
239
239
240
240
override def transform (tree : Tree )(using Context ): Tree = {
241
+ def fixSpan [T <: untpd.Tree ](copied : T ): T =
242
+ copied.withSpan(if tree.source == curSource then tree.span else callSpan)
241
243
def finalize (copied : untpd.Tree ) =
242
- val span = if tree.source == curSource then tree.span else callSpan
243
- copied.withSpan(span).withAttachmentsFrom(tree).withTypeUnchecked(tree.tpe)
244
+ fixSpan(copied).withAttachmentsFrom(tree).withTypeUnchecked(tree.tpe)
244
245
245
246
inContext(ctx.withSource(curSource)) {
246
247
tree match
@@ -252,7 +253,8 @@ object Inliner {
252
253
case tree : Bind => finalize(untpd.Bind (tree.name, transform(tree.body))(curSource))
253
254
case tree : TypeTree => finalize(tpd.TypeTree (tree.tpe))
254
255
case tree : DefTree => super .transform(tree).setDefTree
255
- case _ => super .transform(tree)
256
+ case EmptyTree => tree
257
+ case _ => fixSpan(super .transform(tree))
256
258
}
257
259
}
258
260
}
Original file line number Diff line number Diff line change
1
+ scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
2
+ Test$.main(assert-stack.scala:7)
3
+
4
+ scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
5
+ Test$.main(assert-stack.scala:12)
6
+
Original file line number Diff line number Diff line change
1
+
2
+
3
+ object Test {
4
+
5
+ def main (args : Array [String ]): Unit = {
6
+ try
7
+ assert(false , " my message" )
8
+ catch
9
+ case ae : AssertionError => printStack(ae)
10
+
11
+ try
12
+ assert(false )
13
+ catch
14
+ case ae : AssertionError => printStack(ae)
15
+ }
16
+
17
+ def printStack (ae : AssertionError ): Unit =
18
+ for elem <- ae.getStackTrace().iterator.takeWhile(x => ! (x.getMethodName == " main" && x.getLineNumber == - 1 )) do
19
+ println(elem)
20
+ println()
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments