Skip to content

Commit b9ea4a6

Browse files
committed
Workaround #4198
1 parent 96629a0 commit b9ea4a6

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ object PickledQuotes {
3232
}
3333

3434
/** Transform the expression into its fully spliced Tree */
35-
def quotedExprToTree(expr: quoted.Expr[_])(implicit ctx: Context): Tree = expr match {
35+
def quotedExprToTree[T](expr: quoted.Expr[T])(implicit ctx: Context): Tree = expr match {
3636
case expr: TastyExpr[_] => unpickleExpr(expr)
37-
case expr: LiftedExpr[_] =>
38-
if (expr.value.isInstanceOf[Class[_]]) // Should be a pattern match after #4198 is fixed
39-
ref(defn.Predef_classOf).appliedToType(classToType(expr.value.asInstanceOf[Class[_]]))
40-
else Literal(Constant(expr.value))
37+
case expr: LiftedExpr[T] =>
38+
expr.value match {
39+
case value: Class[_] => ref(defn.Predef_classOf).appliedToType(classToType(value))
40+
case value=> Literal(Constant(value))
41+
}
4142
case expr: TreeExpr[Tree] @unchecked => expr.tree
4243
case expr: FunctionAppliedTo[_, _] =>
4344
functionAppliedTo(quotedExprToTree(expr.f), quotedExprToTree(expr.x))

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ object Splicer {
7575
liftArgs(call.symbol.info, allArgs(call, Nil))
7676
}
7777

78-
private def evaluateLambda(lambda: Seq[Any] => Object, args: Seq[Any], pos: Position)(implicit ctx: Context): Option[scala.quoted.Expr[_]] = {
79-
try Some(lambda(args).asInstanceOf[scala.quoted.Expr[_]])
78+
private def evaluateLambda(lambda: Seq[Any] => Object, args: Seq[Any], pos: Position)(implicit ctx: Context): Option[scala.quoted.Expr[Nothing]] = {
79+
try Some(lambda(args).asInstanceOf[scala.quoted.Expr[Nothing]])
8080
catch {
8181
case ex: scala.quoted.QuoteError =>
8282
ctx.error(ex.getMessage, pos)

0 commit comments

Comments
 (0)