@@ -107,6 +107,9 @@ end CyclicMsg
107
107
abstract class ReferenceMsg (errorId : ErrorMessageID )(using Context ) extends Message (errorId):
108
108
def kind = MessageKind .Reference
109
109
110
+ abstract class StagingMessage (errorId : ErrorMessageID )(using Context ) extends Message (errorId):
111
+ override final def kind = MessageKind .Staging
112
+
110
113
abstract class EmptyCatchOrFinallyBlock (tryBody : untpd.Tree , errNo : ErrorMessageID )(using Context )
111
114
extends SyntaxMsg (errNo) {
112
115
def explain (using Context ) = {
@@ -3165,3 +3168,20 @@ object UnusedSymbol {
3165
3168
def privateMembers (using Context ): UnusedSymbol = new UnusedSymbol (i " unused private member " )
3166
3169
def patVars (using Context ): UnusedSymbol = new UnusedSymbol (i " unused pattern variable " )
3167
3170
}
3171
+
3172
+ final class QuotedTypeMissing (tpe : Type )(using Context ) extends StagingMessage (QuotedTypeMissingID ):
3173
+
3174
+ private def witness = defn.QuotedTypeClass .typeRef.appliedTo(tpe)
3175
+
3176
+ override protected def msg (using Context ): String =
3177
+ i " Reference to $tpe within quotes requires a given ${witness} in scope "
3178
+
3179
+ override protected def explain (using Context ): String =
3180
+ i """ Referencing ` $tpe` inside a quoted expression requires a ` ${witness}` to be in scope.
3181
+ |Since Scala is subject to erasure at runtime, the type information will be missing during the execution of the code.
3182
+ |` ${witness}` is therefore needed to carry ` $tpe`'s type information into the quoted code.
3183
+ |Without an implicit ` ${witness}`, the type ` $tpe` cannot be properly referenced within the expression.
3184
+ |To resolve this, ensure that a ` ${witness}` is available, either through a context-bound or explicitly.
3185
+ | """
3186
+
3187
+ end QuotedTypeMissing
0 commit comments