Skip to content

Commit ceb2517

Browse files
committed
Refactor error reporting
1 parent 2abda6e commit ceb2517

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,13 +1315,7 @@ class Objects(using Context @constructorOnly):
13151315
Bottom
13161316

13171317
else if ref.isObjectRef && ref.klass.hasSource then
1318-
if State.isQuotaExhausted(ref.asObjectRef) then
1319-
if !BestEffort then
1320-
report.warning("Access uninitialized field of quota exhausted object " + field.show + ". " + Trace.show, Trace.position)
1321-
1322-
else
1323-
report.warning("Access uninitialized field " + field.show + ". " + Trace.show, Trace.position)
1324-
1318+
errorReadUninitializedField(ref.asObjectRef, field)
13251319
Bottom
13261320

13271321
else
@@ -1332,7 +1326,7 @@ class Objects(using Context @constructorOnly):
13321326
ref.valValue(target)
13331327

13341328
else if ref.isObjectRef && ref.klass.hasSource then
1335-
report.warning("Access uninitialized field " + field.show + ". " + Trace.show, Trace.position)
1329+
errorReadUninitializedField(ref.asObjectRef, field)
13361330
Bottom
13371331

13381332
else
@@ -2324,3 +2318,10 @@ class Objects(using Context @constructorOnly):
23242318
printTraceWhenMultiple(scope_trace)
23252319

23262320
report.warning(msg, Trace.position)
2321+
2322+
def errorReadUninitializedField(obj: ObjectRef, field: Symbol)(using State.Data, Trace, Context): Unit =
2323+
if State.isQuotaExhausted(obj) then
2324+
if !BestEffort then
2325+
report.warning("Access uninitialized field of quota exhausted object " + field.show + ". " + Trace.show, Trace.position)
2326+
else
2327+
report.warning("Access uninitialized field " + field.show + ". " + Trace.show, Trace.position)

0 commit comments

Comments
 (0)