Skip to content

Commit f1d02ae

Browse files
committed
Use warning instead of error for error state of init check
1 parent b4b02b4 commit f1d02ae

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ object Objects:
512512
returnData.values.addOne(value)
513513

514514
case None =>
515-
report.error("[Internal error] Unhandled return for method " + meth + " in " + meth.owner.show + ". Trace:\n" + Trace.show, Trace.position)
515+
report.warning("[Internal error] Unhandled return for method " + meth + " in " + meth.owner.show + ". Trace:\n" + Trace.show, Trace.position)
516516

517517
type Contextual[T] = (Context, State.Data, Env.Data, Cache.Data, Heap.MutableData, Regions.Data, Returns.Data, Trace) ?=> T
518518

@@ -636,7 +636,7 @@ object Objects:
636636
select(ref, target, receiver, needResolve = false)
637637
else
638638
if ref.klass.isSubClass(receiver.widenSingleton.classSymbol) then
639-
report.error("[Internal error] Unexpected resolution failure: ref.klass = " + ref.klass.show + ", meth = " + meth.show + Trace.show, Trace.position)
639+
report.warning("[Internal error] Unexpected resolution failure: ref.klass = " + ref.klass.show + ", meth = " + meth.show + Trace.show, Trace.position)
640640
Bottom
641641
else
642642
// This is possible due to incorrect type cast.
@@ -688,7 +688,7 @@ object Objects:
688688
Bottom
689689

690690
case _ =>
691-
report.error("[Internal error] unexpected constructor call, meth = " + ctor + ", this = " + thisV + Trace.show, Trace.position)
691+
report.warning("[Internal error] unexpected constructor call, meth = " + ctor + ", this = " + thisV + Trace.show, Trace.position)
692692
Bottom
693693
}
694694

@@ -737,15 +737,15 @@ object Objects:
737737

738738
else
739739
if ref.klass.isSubClass(receiver.widenSingleton.classSymbol) then
740-
report.error("[Internal error] Unexpected resolution failure: ref.klass = " + ref.klass.show + ", field = " + field.show + Trace.show, Trace.position)
740+
report.warning("[Internal error] Unexpected resolution failure: ref.klass = " + ref.klass.show + ", field = " + field.show + Trace.show, Trace.position)
741741
Bottom
742742
else
743743
// This is possible due to incorrect type cast.
744744
// See tests/init/pos/Type.scala
745745
Bottom
746746

747747
case fun: Fun =>
748-
report.error("[Internal error] unexpected tree in selecting a function, fun = " + fun.code.show + Trace.show, fun.code)
748+
report.warning("[Internal error] unexpected tree in selecting a function, fun = " + fun.code.show + Trace.show, fun.code)
749749
Bottom
750750

751751
case Bottom =>
@@ -766,7 +766,7 @@ object Objects:
766766
def assign(lhs: Value, field: Symbol, rhs: Value, rhsTyp: Type): Contextual[Value] = log("Assign" + field.show + " of " + lhs.show + ", rhs = " + rhs.show, printer, (_: Value).show) {
767767
lhs match
768768
case fun: Fun =>
769-
report.error("[Internal error] unexpected tree in assignment, fun = " + fun.code.show + Trace.show, Trace.position)
769+
report.warning("[Internal error] unexpected tree in assignment, fun = " + fun.code.show + Trace.show, Trace.position)
770770

771771
case Cold =>
772772
report.warning("Assigning to cold aliases is forbidden", Trace.position)
@@ -801,7 +801,7 @@ object Objects:
801801
outer match
802802

803803
case _ : Fun | _: OfArray =>
804-
report.error("[Internal error] unexpected outer in instantiating a class, outer = " + outer.show + ", class = " + klass.show + ", " + Trace.show, Trace.position)
804+
report.warning("[Internal error] unexpected outer in instantiating a class, outer = " + outer.show + ", class = " + klass.show + ", " + Trace.show, Trace.position)
805805
Bottom
806806

807807
case value: (Bottom.type | ObjectRef | OfClass | Cold.type) =>
@@ -1161,7 +1161,7 @@ object Objects:
11611161
init(tpl, thisV.asInstanceOf[Ref], klass)
11621162

11631163
case _ =>
1164-
report.error("[Internal error] unexpected tree: " + expr + "\n" + Trace.show, expr)
1164+
report.warning("[Internal error] unexpected tree: " + expr + "\n" + Trace.show, expr)
11651165
Bottom
11661166
}
11671167

@@ -1243,12 +1243,12 @@ object Objects:
12431243
case arg @ Literal(c: Constants.Constant) =>
12441244
val height = c.intValue
12451245
if height < 0 then
1246-
report.error("The argument should be positive", arg)
1246+
report.warning("The argument should be positive", arg)
12471247
res.widen(1)
12481248
else
12491249
res.widen(c.intValue)
12501250
case arg =>
1251-
report.error("The argument should be a constant integer value", arg)
1251+
report.warning("The argument should be a constant integer value", arg)
12521252
res.widen(1)
12531253
case _ =>
12541254
res.widen(1)
@@ -1410,14 +1410,14 @@ object Objects:
14101410
val outerCls = klass.owner.lexicallyEnclosingClass.asClass
14111411
if !ref.hasOuter(klass) then
14121412
val error = "[Internal error] outer not yet initialized, target = " + target + ", klass = " + klass + Trace.show
1413-
report.error(error, Trace.position)
1413+
report.warning(error, Trace.position)
14141414
Bottom
14151415
else
14161416
resolveThis(target, ref.outerValue(klass), outerCls)
14171417
case RefSet(refs) =>
14181418
refs.map(ref => resolveThis(target, ref, klass)).join
14191419
case fun: Fun =>
1420-
report.error("[Internal error] unexpected thisV = " + thisV + ", target = " + target.show + ", klass = " + klass.show + Trace.show, Trace.position)
1420+
report.warning("[Internal error] unexpected thisV = " + thisV + ", target = " + target.show + ", klass = " + klass.show + Trace.show, Trace.position)
14211421
Bottom
14221422
}
14231423

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -589,15 +589,15 @@ object Semantic:
589589
Hot
590590
else
591591
if ref.klass.isSubClass(receiver.widenSingleton.classSymbol) then
592-
report.error("[Internal error] Unexpected resolution failure: ref.klass = " + ref.klass.show + ", field = " + field.show + Trace.show, Trace.position)
592+
report.warning("[Internal error] Unexpected resolution failure: ref.klass = " + ref.klass.show + ", field = " + field.show + Trace.show, Trace.position)
593593
Hot
594594
else
595595
// This is possible due to incorrect type cast.
596596
// See tests/init/pos/Type.scala
597597
Hot
598598

599599
case fun: Fun =>
600-
report.error("[Internal error] unexpected tree in selecting a function, fun = " + fun.expr.show + Trace.show, fun.expr)
600+
report.warning("[Internal error] unexpected tree in selecting a function, fun = " + fun.expr.show + Trace.show, fun.expr)
601601
Hot
602602

603603
case RefSet(refs) =>
@@ -725,7 +725,7 @@ object Semantic:
725725
value.select(target, receiver, needResolve = false)
726726
else
727727
if ref.klass.isSubClass(receiver.widenSingleton.classSymbol) then
728-
report.error("[Internal error] Unexpected resolution failure: ref.klass = " + ref.klass.show + ", meth = " + meth.show + Trace.show, Trace.position)
728+
report.warning("[Internal error] Unexpected resolution failure: ref.klass = " + ref.klass.show + ", meth = " + meth.show + Trace.show, Trace.position)
729729
Hot
730730
else
731731
// This is possible due to incorrect type cast.
@@ -755,7 +755,7 @@ object Semantic:
755755

756756
value match {
757757
case Hot | Cold | _: RefSet | _: Fun =>
758-
report.error("[Internal error] unexpected constructor call, meth = " + ctor + ", value = " + value + Trace.show, Trace.position)
758+
report.warning("[Internal error] unexpected constructor call, meth = " + ctor + ", value = " + value + Trace.show, Trace.position)
759759
Hot
760760

761761
case ref: Warm if ref.isPopulatingParams =>
@@ -862,7 +862,7 @@ object Semantic:
862862
warm
863863

864864
case Fun(body, thisV, klass) =>
865-
report.error("[Internal error] unexpected tree in instantiating a function, fun = " + body.show + Trace.show, Trace.position)
865+
report.warning("[Internal error] unexpected tree in instantiating a function, fun = " + body.show + Trace.show, Trace.position)
866866
Hot
867867

868868
case RefSet(refs) =>
@@ -882,7 +882,7 @@ object Semantic:
882882
case Hot => Hot
883883
case ref: Ref => ref.objekt.field(sym)
884884
case _ =>
885-
report.error("[Internal error] unexpected this value accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show + Trace.show, Trace.position)
885+
report.warning("[Internal error] unexpected this value accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show + Trace.show, Trace.position)
886886
Hot
887887
else if sym.is(Flags.Param) then
888888
Hot
@@ -900,7 +900,7 @@ object Semantic:
900900
case ref: Ref => eval(vdef.rhs, ref, enclosingClass, cacheResult = sym.is(Flags.Lazy))
901901

902902
case _ =>
903-
report.error("[Internal error] unexpected this value when accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show + Trace.show, Trace.position)
903+
report.warning("[Internal error] unexpected this value when accessing local variable, sym = " + sym.show + ", thisValue = " + thisValue2.show + Trace.show, Trace.position)
904904
Hot
905905
end match
906906

@@ -1040,7 +1040,7 @@ object Semantic:
10401040
//
10411041
// This invariant holds because of the Scala/Java/JVM restriction that we cannot use `this` in super constructor calls.
10421042
if subClassSegmentHot && !isHotSegment then
1043-
report.error("[Internal error] Expect current segment to be transitively initialized (Hot) in promotion, current klass = " + klass.show +
1043+
report.warning("[Internal error] Expect current segment to be transitively initialized (Hot) in promotion, current klass = " + klass.show +
10441044
", subclass = " + subClass.show + Trace.show, Trace.position)
10451045

10461046
// If the outer and parameters of a class are all hot, then accessing fields and methods of the current
@@ -1374,7 +1374,7 @@ object Semantic:
13741374
Hot
13751375

13761376
case _ =>
1377-
report.error("[Internal error] unexpected tree" + Trace.show, expr)
1377+
report.warning("[Internal error] unexpected tree" + Trace.show, expr)
13781378
Hot
13791379

13801380
/** Handle semantics of leaf nodes
@@ -1418,7 +1418,7 @@ object Semantic:
14181418
Hot
14191419

14201420
case _ =>
1421-
report.error("[Internal error] unexpected type " + tp + Trace.show, Trace.position)
1421+
report.warning("[Internal error] unexpected type " + tp + Trace.show, Trace.position)
14221422
Hot
14231423
}
14241424

@@ -1439,14 +1439,14 @@ object Semantic:
14391439
val outerCls = klass.owner.lexicallyEnclosingClass.asClass
14401440
if !obj.hasOuter(klass) then
14411441
val error = "[Internal error] outer not yet initialized, target = " + target + ", klass = " + klass + ", object = " + obj + Trace.show
1442-
report.error(error, Trace.position)
1442+
report.warning(error, Trace.position)
14431443
Hot
14441444
else
14451445
resolveThis(target, obj.outer(klass), outerCls)
14461446
case RefSet(refs) =>
14471447
refs.map(ref => resolveThis(target, ref, klass)).join
14481448
case fun: Fun =>
1449-
report.error("[Internal error] unexpected thisV = " + thisV + ", target = " + target.show + ", klass = " + klass.show + Trace.show, Trace.position)
1449+
report.warning("[Internal error] unexpected thisV = " + thisV + ", target = " + target.show + ", klass = " + klass.show + Trace.show, Trace.position)
14501450
Cold
14511451
case Cold => Cold
14521452

0 commit comments

Comments
 (0)