From 06baf4b862662eedf7db33025d81be17a61a00fd Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Wed, 2 Jun 2021 01:36:35 +0200 Subject: [PATCH] Make 'wrong focus shape' error display readable code --- .../scala-3/com/softwaremill/quicklens/QuicklensMacros.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quicklens/src/main/scala-3/com/softwaremill/quicklens/QuicklensMacros.scala b/quicklens/src/main/scala-3/com/softwaremill/quicklens/QuicklensMacros.scala index 0a87eb8..1c39616 100644 --- a/quicklens/src/main/scala-3/com/softwaremill/quicklens/QuicklensMacros.scala +++ b/quicklens/src/main/scala-3/com/softwaremill/quicklens/QuicklensMacros.scala @@ -39,7 +39,7 @@ object QuicklensMacros { def modifyImpl[S, A](obj: Expr[S], focus: Expr[S => A])(using Quotes, Type[S], Type[A]): Expr[PathModify[S, A]] = { import quotes.reflect.* - def unsupportedShapeInfo(tree: Tree) = s"Unsupported path element. Path must have shape: _.field1.field2.each.field3.(...), got: $tree" + def unsupportedShapeInfo(tree: Tree) = s"Unsupported path element. Path must have shape: _.field1.field2.each.field3.(...), got: ${tree.show}" def methodSupported(method: String) = Seq("at", "each", "eachWhere", "eachRight", "eachLeft", "atOrElse", "index", "when").contains(method) @@ -69,7 +69,7 @@ object QuicklensMacros { case i: Ident if i.name.startsWith("_") => Seq.empty case _ => - report.throwError(unsupportedShapeInfo(tree)) + report.throwError(unsupportedShapeInfo(focus.asTerm)) } }