From a9155a398e590c738b51fa36c710732e849b4984 Mon Sep 17 00:00:00 2001 From: Jon Pretty Date: Mon, 16 Oct 2023 10:15:03 +0200 Subject: [PATCH] Use new convention for unsafe methods --- src/core/kaleidoscope.scala | 6 +++--- src/core/regex.scala | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/kaleidoscope.scala b/src/core/kaleidoscope.scala index d6c101b..95b70b2 100644 --- a/src/core/kaleidoscope.scala +++ b/src/core/kaleidoscope.scala @@ -32,13 +32,13 @@ extension (inline ctx: StringContext) transparent inline def g: Any = ${Kaleidoscope.glob('ctx)} class NoExtraction(pattern: String): - inline def apply(): Regex = Regex.unsafeParse(List(pattern)) + inline def apply(): Regex = Regex.make(List(pattern))(using Unsafe) def unapply(scrutinee: Text): Boolean = - Regex.unsafeParse(List(pattern)).matches(scrutinee) + Regex.make(List(pattern))(using Unsafe).matches(scrutinee) class Extractor[ResultType](parts: Seq[String]): def unapply(scrutinee: Text): ResultType = - val result = Regex.unsafeParse(parts).matchGroups(scrutinee) + val result = Regex.make(parts)(using Unsafe).matchGroups(scrutinee) if parts.length == 2 then result.map(_.head).asInstanceOf[ResultType] else result.map(Tuple.fromIArray(_)).asInstanceOf[ResultType] diff --git a/src/core/regex.scala b/src/core/regex.scala index f7a01d7..273fee4 100644 --- a/src/core/regex.scala +++ b/src/core/regex.scala @@ -104,7 +104,7 @@ object Regex: if quantifier.unitary then (index2, Text(s"($groupName$subpattern)")) else (index2, Text(s"($groupName($subpattern)${quantifier.serialize}${greed.serialize})")) - def unsafeParse(parts: Seq[String]): Regex = + def make(parts: Seq[String])(using Unsafe.type): Regex = import errorHandlers.throwUnsafely parse(parts.to(List).map(Text(_)))