@@ -12,7 +12,7 @@ import Types._, Symbols._, Contexts._
1212import scala .collection .mutable
1313
1414object Errors :
15- sealed trait Error {
15+ sealed trait Error :
1616 def trace : Seq [Tree ]
1717 def show (using Context ): String
1818
@@ -55,7 +55,7 @@ object Errors:
5555 /** Used to underline source positions in the stack trace
5656 * pos.source must exist
5757 */
58- private def positionMarker (pos : SourcePosition ): String = {
58+ private def positionMarker (pos : SourcePosition ): String =
5959 val trimmed = pos.lineContent.takeWhile(c => c.isWhitespace).length
6060 val padding = pos.startColumnPadding.substring(trimmed).nn + " "
6161 val carets =
@@ -64,48 +64,41 @@ object Errors:
6464 else " ^"
6565
6666 s " $padding$carets\n "
67- }
6867
6968 override def toString () = this .getClass.getName.nn
70- }
69+ end Error
7170
7271 /** Access non-initialized field */
73- case class AccessNonInit (field : Symbol , trace : Seq [Tree ]) extends Error {
72+ case class AccessNonInit (field : Symbol , trace : Seq [Tree ]) extends Error :
7473 def source : Tree = trace.last
7574 def show (using Context ): String =
7675 " Access non-initialized " + field.show + " ."
7776
7877 override def pos (using Context ): SourcePosition = field.sourcePos
79- }
8078
8179 /** Promote a value under initialization to fully-initialized */
82- case class PromoteError (msg : String , trace : Seq [Tree ]) extends Error {
80+ case class PromoteError (msg : String , trace : Seq [Tree ]) extends Error :
8381 def show (using Context ): String = msg
84- }
8582
86- case class AccessCold (field : Symbol , trace : Seq [Tree ]) extends Error {
83+ case class AccessCold (field : Symbol , trace : Seq [Tree ]) extends Error :
8784 def show (using Context ): String =
8885 " Access field on a value with an unknown initialization status."
89- }
9086
91- case class CallCold (meth : Symbol , trace : Seq [Tree ]) extends Error {
87+ case class CallCold (meth : Symbol , trace : Seq [Tree ]) extends Error :
9288 def show (using Context ): String =
9389 " Call method on a value with an unknown initialization" + " ."
94- }
9590
96- case class CallUnknown (meth : Symbol , trace : Seq [Tree ]) extends Error {
91+ case class CallUnknown (meth : Symbol , trace : Seq [Tree ]) extends Error :
9792 def show (using Context ): String =
9893 val prefix = if meth.is(Flags .Method ) then " Calling the external method " else " Accessing the external field"
9994 prefix + meth.show + " may cause initialization errors" + " ."
100- }
10195
10296 /** Promote a value under initialization to fully-initialized */
103- case class UnsafePromotion (msg : String , trace : Seq [Tree ], error : Error ) extends Error {
97+ case class UnsafePromotion (msg : String , trace : Seq [Tree ], error : Error ) extends Error :
10498 override def issue (using Context ): Unit =
10599 report.warning(show, this .pos)
106100
107101 def show (using Context ): String =
108102 msg + stacktrace + " \n " +
109103 " Promoting the value to fully initialized failed due to the following problem:\n " +
110104 error.show + error.stacktrace
111- }
0 commit comments