@@ -558,20 +558,26 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
558
558
val expansion = inliner.transform(rhsToInline)
559
559
560
560
def issueError () = callValueArgss match {
561
+
562
+
561
563
case (msgArg :: Nil ) :: Nil =>
562
- msgArg.tpe match {
563
- case ConstantType (Constant (msg : String )) =>
564
- // Usually `error` is called from within a rewrite method. In this
565
- // case we need to report the error at the point of the outermost enclosing inline
566
- // call. This way, a defensively written rewrite methid can always
567
- // report bad inputs at the point of call instead of revealing its internals.
568
- val callToReport = if (enclosingInlineds.nonEmpty) enclosingInlineds.last else call
569
- val ctxToReport = ctx.outersIterator.dropWhile(enclosingInlineds(_).nonEmpty).next
570
- def issueInCtx (implicit ctx : Context ) =
571
- ctx.error(msg, callToReport.sourcePos)
572
- issueInCtx(ctxToReport)
573
- case _ =>
564
+
565
+ val message = msgArg.tpe match {
566
+ case ConstantType (Constant (msg : String )) => msg
567
+ case _ => s " A literal string is expected as an argument to `compiletime.error`. Got ${msgArg.show}"
574
568
}
569
+
570
+ // Usually `error` is called from within a rewrite method. In this
571
+ // case we need to report the error at the point of the outermost enclosing inline
572
+ // call. This way, a defensively written rewrite methid can always
573
+ // report bad inputs at the point of call instead of revealing its internals.
574
+ val callToReport = if (enclosingInlineds.nonEmpty) enclosingInlineds.last else call
575
+ val ctxToReport = ctx.outersIterator.dropWhile(enclosingInlineds(_).nonEmpty).next
576
+ def issueInCtx (implicit ctx : Context ) =
577
+ ctx.error(message, callToReport.sourcePos)
578
+ issueInCtx(ctxToReport)
579
+
580
+
575
581
case _ =>
576
582
}
577
583
@@ -1316,4 +1322,3 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
1316
1322
}
1317
1323
}.apply(Nil , tree)
1318
1324
}
1319
-
0 commit comments