@@ -108,6 +108,9 @@ end CyclicMsg
108
108
abstract class ReferenceMsg (errorId : ErrorMessageID )(using Context ) extends Message (errorId):
109
109
def kind = MessageKind .Reference
110
110
111
+ abstract class StagingMessage (errorId : ErrorMessageID )(using Context ) extends Message (errorId):
112
+ override final def kind = MessageKind .Staging
113
+
111
114
abstract class EmptyCatchOrFinallyBlock (tryBody : untpd.Tree , errNo : ErrorMessageID )(using Context )
112
115
extends SyntaxMsg (errNo) {
113
116
def explain (using Context ) = {
@@ -3323,3 +3326,20 @@ class NonNamedArgumentInJavaAnnotation(using Context) extends SyntaxMsg(NonNamed
3323
3326
"""
3324
3327
3325
3328
end NonNamedArgumentInJavaAnnotation
3329
+
3330
+ final class QuotedTypeMissing (tpe : Type )(using Context ) extends StagingMessage (QuotedTypeMissingID ):
3331
+
3332
+ private def witness = defn.QuotedTypeClass .typeRef.appliedTo(tpe)
3333
+
3334
+ override protected def msg (using Context ): String =
3335
+ i " Reference to $tpe within quotes requires a given ${witness} in scope "
3336
+
3337
+ override protected def explain (using Context ): String =
3338
+ i """ Referencing ` $tpe` inside a quoted expression requires a ` ${witness}` to be in scope.
3339
+ |Since Scala is subject to erasure at runtime, the type information will be missing during the execution of the code.
3340
+ |` ${witness}` is therefore needed to carry ` $tpe`'s type information into the quoted code.
3341
+ |Without an implicit ` ${witness}`, the type ` $tpe` cannot be properly referenced within the expression.
3342
+ |To resolve this, ensure that a ` ${witness}` is available, either through a context-bound or explicitly.
3343
+ | """
3344
+
3345
+ end QuotedTypeMissing
0 commit comments