Skip to content

Commit 73e64a7

Browse files
committed
Fix missing stacktrace item
1 parent a4c78a4 commit 73e64a7

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

compiler/src/dotty/tools/dotc/transform/init/Errors.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ object Errors:
2121
def issue(using Context): Unit =
2222
report.warning(show + stacktrace, this.pos)
2323

24-
private def isTraceInformative(using Context): Boolean =
25-
trace.size > 1 || trace.size == 1 && trace.head.sourcePos.ne(pos)
26-
27-
def stacktrace(using Context): String = if !isTraceInformative then "" else " Calling trace:\n" + {
24+
def stacktrace(using Context): String = if trace.isEmpty then "" else " Calling trace:\n" + {
2825
var lastLineNum = -1
2926
var lines: mutable.ArrayBuffer[String] = new mutable.ArrayBuffer
3027
trace.foreach { tree =>
@@ -107,10 +104,8 @@ object Errors:
107104
override def issue(using Context): Unit =
108105
report.warning(show, this.pos)
109106

110-
def show(using Context): String = {
111-
var index = 0
107+
def show(using Context): String =
112108
msg + stacktrace + "\n" +
113109
"Promoting the value to fully initialized failed due to the following problem:\n" +
114110
error.show + error.stacktrace
115-
}
116111
}

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ object Semantic {
11451145

11461146
case id @ Ident(name) if !id.symbol.is(Flags.Method) =>
11471147
assert(name.isTermName, "type trees should not reach here")
1148-
cases(expr.tpe, thisV, klass)
1148+
withTrace(trace2) { cases(expr.tpe, thisV, klass) }
11491149

11501150
case NewExpr(tref, New(tpt), ctor, argss) =>
11511151
// check args

tests/init/neg/t3273.check

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
| ^^^^^^^^^^^^^^^
99
|
1010
| Promoting the value to fully initialized failed due to the following problem:
11-
| Access non-initialized value num1.
11+
| Access non-initialized value num1. Calling trace:
12+
| -> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
13+
| ^^^^
1214
-- Error: tests/init/neg/t3273.scala:5:61 ------------------------------------------------------------------------------
1315
5 | val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error
1416
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -19,4 +21,6 @@
1921
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2022
|
2123
| Promoting the value to fully initialized failed due to the following problem:
22-
| Access non-initialized value num2.
24+
| Access non-initialized value num2. Calling trace:
25+
| -> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]
26+
| ^^^^

0 commit comments

Comments
 (0)