@@ -559,19 +559,19 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
559559
560560 def issueError () = callValueArgss match {
561561 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 _ =>
562+ val message = msgArg.tpe match {
563+ case ConstantType (Constant (msg : String )) => msg
564+ case _ => s " A literal string is expected as an argument to `compiletime.error`. Got ${msgArg.show}"
574565 }
566+ // Usually `error` is called from within a rewrite method. In this
567+ // case we need to report the error at the point of the outermost enclosing inline
568+ // call. This way, a defensively written rewrite methid can always
569+ // report bad inputs at the point of call instead of revealing its internals.
570+ val callToReport = if (enclosingInlineds.nonEmpty) enclosingInlineds.last else call
571+ val ctxToReport = ctx.outersIterator.dropWhile(enclosingInlineds(_).nonEmpty).next
572+ def issueInCtx (implicit ctx : Context ) =
573+ ctx.error(message, callToReport.sourcePos)
574+ issueInCtx(ctxToReport)
575575 case _ =>
576576 }
577577
@@ -1316,4 +1316,3 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
13161316 }
13171317 }.apply(Nil , tree)
13181318}
1319-
0 commit comments