Skip to content

Commit 1752724

Browse files
Implement API for errors
1 parent 6337a93 commit 1752724

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

library/src/scala/compiletime/testing/package.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ import scala.quoted._
44

55
package object testing {
66

7+
case class Error(message: String, lineContent: String, column: Int, kind: ErrorKind)
8+
object Error
9+
given Liftable[Error]
10+
def toExpr(e: Error) =
11+
'{Error(${Expr(e.message)}, ${Expr(e.lineContent)}, ${Expr(e.column)}, ${Expr(e.kind)})}
12+
13+
enum ErrorKind
14+
case Parse, Compile
15+
16+
object ErrorKind
17+
given Liftable[ErrorKind]
18+
import ErrorKind._
19+
def toExpr(e: ErrorKind) = e match
20+
case Parse => '{Parse}
21+
case Compile => '{Compile}
22+
723
/** Whether the code type checks in the current context?
824
*
925
* @param code The code to be type checked

0 commit comments

Comments
 (0)