Skip to content

Commit a1f412c

Browse files
committed
Move exception definitions outside the Toolbox
1 parent 318f27a commit a1f412c

File tree

7 files changed

+11
-9
lines changed

7 files changed

+11
-9
lines changed

compiler/src/dotty/tools/dotc/quoted/ToolboxImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object ToolboxImpl {
2222
def run[T](exprBuilder: QuoteContext => Expr[T]): T = synchronized {
2323
try {
2424
if (running) // detected nested run
25-
throw new scala.quoted.staging.Toolbox.RunScopeException()
25+
throw new scala.quoted.staging.RunScopeException()
2626
running = true
2727
driver.run(exprBuilder, settings)
2828
} finally {
@@ -35,7 +35,7 @@ object ToolboxImpl {
3535

3636
private[dotty] def checkScopeId(id: ScopeId) given Context: Unit = {
3737
if (id != scopeId)
38-
throw new staging.Toolbox.RunScopeException
38+
throw new scala.quoted.staging.RunScopeException
3939
}
4040

4141
// TODO Explore more fine grained scope ids.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package scala.quoted.staging
2+
3+
class RunScopeException extends Exception("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`")

library/src/scala/quoted/staging/Toolbox.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,4 @@ object Toolbox {
5656
new Settings(outDir, showRawTree, compilerArgs)
5757
}
5858

59-
class ToolboxNotFoundException(msg: String, cause: ClassNotFoundException) extends Exception(msg, cause)
60-
61-
class RunScopeException extends Exception("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`")
62-
6359
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package scala.quoted.staging
2+
3+
class ToolboxNotFoundException(msg: String, cause: ClassNotFoundException) extends Exception(msg, cause)

tests/run-macros/i6992/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object macros {
1717
case '{$x: Foo} => run(x).x.toExpr
1818
}
1919
} catch {
20-
case _: scala.quoted.staging.Toolbox.RunScopeException =>
20+
case _: scala.quoted.staging.RunScopeException =>
2121
'{"OK"}
2222
}
2323
}

tests/run-with-compiler/i4730.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Test {
1414
run(ret).apply(10)
1515
throw new Exception
1616
} catch {
17-
case ex: scala.quoted.staging.Toolbox.RunScopeException =>
17+
case ex: scala.quoted.staging.RunScopeException =>
1818
// ok
1919
}
2020
}

tests/run-with-compiler/i6754.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Test {
1616
throw new Exception
1717
} catch {
1818
case ex: java.lang.reflect.InvocationTargetException =>
19-
assert(ex.getTargetException.isInstanceOf[scala.quoted.staging.Toolbox.RunScopeException])
19+
assert(ex.getTargetException.isInstanceOf[scala.quoted.staging.RunScopeException])
2020
}
2121
}
2222
}

0 commit comments

Comments
 (0)