@@ -17,6 +17,7 @@ object Errors {
17
17
sealed trait Error {
18
18
def trace : Vector [Tree ]
19
19
def report (implicit ctx : Context ): Unit
20
+ def message (implicit ctx : Context ): String
20
21
21
22
def stacktrace (implicit ctx : Context ): String = {
22
23
var indentCount = 0
@@ -41,21 +42,55 @@ object Errors {
41
42
42
43
/** Access non-initialized field */
43
44
case class AccessNonInit (field : Symbol , trace : Vector [Tree ]) extends Error {
45
+ def message (implicit ctx : Context ): String =
46
+ " Access non-initialized field " + field.show + " . Calling trace:\n " + stacktrace
47
+
44
48
def report (implicit ctx : Context ): Unit = ???
45
49
}
46
50
47
51
/** Promote `this` under initialization to fully-initialized */
48
- case class PromoteThis (pot : ThisRef , trace : Vector [Tree ]) extends Error {
52
+ case class PromoteThis (pot : ThisRef , source : Tree , trace : Vector [Tree ]) extends Error {
53
+ def message (implicit ctx : Context ): String = " Promote `this` to be initialized while it is not. Calling trace:\n " + stacktrace
49
54
def report (implicit ctx : Context ): Unit = ???
50
55
}
51
56
52
57
/** Promote a cold value under initialization to fully-initialized */
53
- case class PromoteCold (trace : Vector [Tree ]) extends Error {
58
+ case class PromoteCold (source : Tree , trace : Vector [Tree ]) extends Error {
59
+ def message (implicit ctx : Context ): String =
60
+ " Promoting the value " + source.show + " to be initialized while it is under initialization" +
61
+ " . Calling trace:\n " + stacktrace
62
+
63
+ def report (implicit ctx : Context ): Unit = ???
64
+ }
65
+
66
+ case class AccessCold (field : Symbol , source : Tree , trace : Vector [Tree ]) extends Error {
67
+ def message (implicit ctx : Context ): String =
68
+ " Access field " + source.show + " on a value under unknown initialization status" +
69
+ " . Calling trace:\n " + stacktrace
70
+
71
+ def report (implicit ctx : Context ): Unit = ???
72
+ }
73
+
74
+ case class CallCold (meth : Symbol , source : Tree , trace : Vector [Tree ]) extends Error {
75
+ def message (implicit ctx : Context ): String =
76
+ " Call method " + source.show + " on a value under unknown initialization" +
77
+ " . Calling trace:\n " + stacktrace
78
+
79
+ def report (implicit ctx : Context ): Unit = ???
80
+ }
81
+
82
+ case class CallUnknown (meth : Symbol , source : Tree , trace : Vector [Tree ]) extends Error {
83
+ def message (implicit ctx : Context ): String =
84
+ " Calling the external method " + meth.show +
85
+ " may cause initialization errors" + " . Calling trace:\n " + stacktrace
86
+
54
87
def report (implicit ctx : Context ): Unit = ???
55
88
}
56
89
57
90
/** Promote a value under initialization to fully-initialized */
58
- case class UnsafePromotion (pot : Potential , trace : Vector [Tree ], errors : Set [Error ]) extends Error {
91
+ case class UnsafePromotion (pot : Potential , source : Tree , trace : Vector [Tree ], errors : Set [Error ]) extends Error {
92
+ def message (implicit ctx : Context ): String = ???
93
+
59
94
def report (implicit ctx : Context ): Unit = ???
60
95
}
61
96
}
0 commit comments