Skip to content

Commit 0734d59

Browse files
committed
Make internal error more explicit in the message
1 parent f19faeb commit 0734d59

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

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

+13-12
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ object Semantic:
591591
Hot
592592

593593
case fun: Fun =>
594-
report.error("unexpected tree in selecting a function, fun = " + fun.expr.show, fun.expr)
594+
report.error("[Internal error] unexpected tree in selecting a function, fun = " + fun.expr.show, fun.expr)
595595
Hot
596596

597597
case RefSet(refs) =>
@@ -839,7 +839,7 @@ object Semantic:
839839
warm
840840

841841
case Fun(body, thisV, klass) =>
842-
report.error("unexpected tree in instantiating a function, fun = " + body.show, trace.toVector.last)
842+
report.error("[Internal error] unexpected tree in instantiating a function, fun = " + body.show, trace.toVector.last)
843843
Hot
844844

845845
case RefSet(refs) =>
@@ -859,7 +859,7 @@ object Semantic:
859859
case Hot => Hot
860860
case ref: Ref => ref.objekt.field(sym)
861861
case _ =>
862-
report.error("unexpected this value accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show, trace.toVector.last)
862+
report.error("[Internal error] unexpected this value accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show, trace.toVector.last)
863863
Hot
864864
else if sym.is(Flags.Param) then
865865
Hot
@@ -877,7 +877,7 @@ object Semantic:
877877
case ref: Ref => eval(vdef.rhs, ref, enclosingClass)
878878

879879
case _ =>
880-
report.error("unexpected this value when accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show, trace.toVector.last)
880+
report.error("[Internal error] unexpected this value when accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show, trace.toVector.last)
881881
Hot
882882
end match
883883

@@ -1318,8 +1318,8 @@ object Semantic:
13181318
Hot
13191319

13201320
case _ =>
1321-
throw new Exception("unexpected tree: " + expr.show)
1322-
1321+
report.error("[Internal error] unexpected tree", expr)
1322+
Hot
13231323

13241324
/** Handle semantics of leaf nodes */
13251325
def cases(tp: Type, thisV: Ref, klass: ClassSymbol): Contextual[Value] = log("evaluating " + tp.show, printer, (_: Value).show) {
@@ -1347,7 +1347,8 @@ object Semantic:
13471347
Hot
13481348

13491349
case _ =>
1350-
throw new Exception("unexpected type: " + tp)
1350+
report.error("[Internal error] unexpected type " + tp, trace.toVector.last)
1351+
Hot
13511352
}
13521353

13531354
/** Resolve C.this that appear in `klass` */
@@ -1361,15 +1362,15 @@ object Semantic:
13611362
val obj = ref.objekt
13621363
val outerCls = klass.owner.lexicallyEnclosingClass.asClass
13631364
if !obj.hasOuter(klass) then
1364-
val error = PromoteError("outer not yet initialized, target = " + target + ", klass = " + klass + ", object = " + obj, trace.toVector)
1365-
report.error(error.show + error.stacktrace, trace.toVector.last)
1365+
val error = PromoteError("[Internal error] outer not yet initialized, target = " + target + ", klass = " + klass + ", object = " + obj, trace.toVector)
1366+
report.error(error.show, trace.toVector.last)
13661367
Hot
13671368
else
13681369
resolveThis(target, obj.outer(klass), outerCls)
13691370
case RefSet(refs) =>
13701371
refs.map(ref => resolveThis(target, ref, klass)).join
13711372
case fun: Fun =>
1372-
report.warning("unexpected thisV = " + thisV + ", target = " + target.show + ", klass = " + klass.show, trace.toVector.last)
1373+
report.error("[Internal error] unexpected thisV = " + thisV + ", target = " + target.show + ", klass = " + klass.show, trace.toVector.last)
13731374
Cold
13741375
case Cold => Cold
13751376

@@ -1397,14 +1398,14 @@ object Semantic:
13971398
resolveThis(target, thisV, cur)
13981399

13991400
case None =>
1400-
report.warning("unexpected outerSelect, thisV = " + thisV + ", target = " + target.show + ", hops = " + hops, trace.toVector.last.srcPos)
1401+
report.error("[Internal error] unexpected outerSelect, thisV = " + thisV + ", target = " + target.show + ", hops = " + hops, trace.toVector.last.srcPos)
14011402
Cold
14021403

14031404
case RefSet(refs) =>
14041405
refs.map(ref => resolveOuterSelect(target, ref, hops)).join
14051406

14061407
case fun: Fun =>
1407-
report.warning("unexpected thisV = " + thisV + ", target = " + target.show + ", hops = " + hops, trace.toVector.last.srcPos)
1408+
report.error("[Internal error] unexpected thisV = " + thisV + ", target = " + target.show + ", hops = " + hops, trace.toVector.last.srcPos)
14081409
Cold
14091410

14101411
case Cold => Cold

0 commit comments

Comments
 (0)