Skip to content

Commit 473e765

Browse files
committed
Show more context for warnings
1 parent 8e9b194 commit 473e765

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ object Objects:
569569
def call(value: Value, meth: Symbol, args: List[ArgInfo], receiver: Type, superType: Type, needResolve: Boolean = true): Contextual[Value] = log("call " + meth.show + ", args = " + args.map(_.value.show), printer, (_: Value).show) {
570570
value match
571571
case Cold =>
572-
report.warning("Using cold alias", Trace.position)
572+
report.warning("Using cold alias. Calling trace:\n" + Trace.show, Trace.position)
573573
Bottom
574574

575575
case Bottom =>
@@ -769,7 +769,7 @@ object Objects:
769769
report.warning("[Internal error] unexpected tree in assignment, fun = " + fun.code.show + Trace.show, Trace.position)
770770

771771
case Cold =>
772-
report.warning("Assigning to cold aliases is forbidden", Trace.position)
772+
report.warning("Assigning to cold aliases is forbidden. Calling trace:\n" + Trace.show, Trace.position)
773773

774774
case Bottom =>
775775

@@ -784,7 +784,7 @@ object Objects:
784784
else
785785
Heap.write(addr, rhs)
786786
else
787-
report.warning("Mutating a field before its initialization: " + field.show, Trace.position)
787+
report.warning("Mutating a field before its initialization: " + field.show + ". Calling trace:\n" + Trace.show, Trace.position)
788788
end match
789789

790790
Bottom
@@ -915,7 +915,7 @@ object Objects:
915915
Heap.write(addr, value)
916916

917917
case _ =>
918-
report.warning("Assigning to variables in outer scope", Trace.position)
918+
report.warning("Assigning to variables in outer scope. Calling trace:\n" + Trace.show, Trace.position)
919919

920920
Bottom
921921
}
@@ -1002,7 +1002,7 @@ object Objects:
10021002
case Apply(ref, arg :: Nil) if ref.symbol == defn.InitRegionMethod =>
10031003
val regions2 = Regions.extend(expr.sourcePos)
10041004
if Regions.exists(expr.sourcePos) then
1005-
report.warning("Cyclic region detected. Trace: " + Trace.show, expr)
1005+
report.warning("Cyclic region detected. Trace:\n" + Trace.show, expr)
10061006
Bottom
10071007
else
10081008
given Regions.Data = regions2

0 commit comments

Comments
 (0)