Skip to content

Commit f2d546c

Browse files
Merge pull request #10229 from dotty-staging/remove-Expr-cast-exception
Remove internal.quoted.{ExprCastError, ScopeException}
2 parents ab42870 + 27f7925 commit f2d546c

File tree

9 files changed

+9
-17
lines changed

9 files changed

+9
-17
lines changed

library/src-bootstrapped/scala/internal/quoted/Expr.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class Expr[Tree](val tree: Tree, val scopeId: Int) extends scala.quoted.Ex
2424

2525
def checkScopeId(expectedScopeId: Int): Unit =
2626
if expectedScopeId != scopeId then
27-
throw new scala.internal.quoted.ScopeException("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`")
27+
throw new Exception("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`")
2828

2929
override def hashCode: Int = tree.hashCode
3030
override def toString: String = "'{ ... }"

library/src-bootstrapped/scala/internal/quoted/Type.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class Type[Tree](val typeTree: Tree, val scopeId: Int) extends scala.quote
1919

2020
def checkScopeId(expectedScopeId: Int): Unit =
2121
if expectedScopeId != scopeId then
22-
throw new scala.internal.quoted.ScopeException("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`")
22+
throw new Exception("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`")
2323

2424
override def hashCode: Int = typeTree.hashCode
2525
override def toString: String = "'[ ... ]"

library/src-bootstrapped/scala/quoted/Expr.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ abstract class Expr[+T] private[scala] {
3232
if isExprOf[X] then
3333
this.asInstanceOf[scala.quoted.Expr[X]]
3434
else
35-
throw new scala.internal.quoted.ExprCastError(
36-
s"""Expr: ${this.show}
35+
throw Exception(
36+
s"""Expr cast exception: ${this.show}
3737
|of type: ${this.unseal.tpe.show}
3838
|did not conform to type: ${tp.unseal.tpe.show}
3939
|""".stripMargin

library/src/scala/internal/quoted/ExprCastError.scala

Lines changed: 0 additions & 4 deletions
This file was deleted.

library/src/scala/internal/quoted/ScopeException.scala

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Toolbox:
3131
def run[T](exprBuilder: QuoteContext => Expr[T]): T = synchronized {
3232
try
3333
if (running) // detected nested run
34-
throw new scala.internal.quoted.ScopeException("Cannot call `scala.quoted.staging.run(...)` within a another `run(...)`")
34+
throw new Exception("Cannot call `scala.quoted.staging.run(...)` within a another `run(...)`")
3535
running = true
3636
driver.run(exprBuilder, settings)
3737
finally

tests/run-staging/i4730.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Test {
55
given Toolbox = Toolbox.make(getClass.getClassLoader)
66
def ret(using QuoteContext): Expr[Int => Int] = '{ (x: Int) =>
77
${
8-
val z = run('{x + 1}) // throws a RunScopeException
8+
val z = run('{x + 1}) // throws Exception("Cannot call `scala.quoted.staging.run(...)` within a another `run(...)`")
99
Expr(z)
1010
}
1111
}
@@ -21,7 +21,7 @@ package scala {
2121
run(Test.ret).apply(10)
2222
throw new Exception
2323
} catch {
24-
case ex: scala.internal.quoted.ScopeException =>
24+
case ex: Exception if ex.getMessage == "Cannot call `scala.quoted.staging.run(...)` within a another `run(...)`" =>
2525
// ok
2626
}
2727
}

tests/run-staging/i6754.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package scala {
2222
throw new Exception
2323
} catch {
2424
case ex: java.lang.reflect.InvocationTargetException =>
25-
assert(ex.getTargetException.isInstanceOf[scala.internal.quoted.ScopeException])
25+
assert(ex.getTargetException.getMessage == "Cannot call `scala.quoted.staging.run(...)` within a another `run(...)`")
2626
}
2727
}
2828
}

tests/run-staging/i6992/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ package scala {
2525
case '{$x: Foo} => Expr(run(x).x)
2626
}
2727
} catch {
28-
case ex: scala.internal.quoted.ScopeException =>
28+
case ex: Exception if ex.getMessage == "Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`" =>
2929
'{"OK"}
3030
}
3131
}

0 commit comments

Comments
 (0)