Revert "Strip out raw Ident(_) in blocks if it's synthetic"

This reverts commit a44aee9ac1.
This commit is contained in:
Eugene Yokota 2020-11-22 15:29:16 -05:00
parent 903a155faf
commit 07f347b0f4
2 changed files with 3 additions and 11 deletions

View File

@ -312,16 +312,6 @@ final class ContextUtil[C <: blackbox.Context](val ctx: C) {
case Converted.Failure(p, m) => ctx.abort(p, m)
case _: Converted.NotApplicable[_] => super.transform(tree)
}
// try to workaround https://github.com/scala/bug/issues/12112 by removing raw Ident(_) in blocks
case Block(stats0, expr0) =>
val stats = stats0 flatMap { stat0 =>
val stat = super.transform(stat0)
stat match {
case Typed(ident @ Ident(_), _) if ident.symbol.isSynthetic => None
case _ => Some(stat)
}
}
Block(stats, super.transform(expr0))
case _ => super.transform(tree)
}
}

View File

@ -187,7 +187,9 @@ object Instance {
qual.foreach(checkQual)
val vd = util.freshValDef(tpe, qual.pos, functionSym)
inputs ::= new Input(tpe, qual, vd)
util.refVal(selection, vd)
// try to workaround https://github.com/scala/bug/issues/12112 by calling Predef.identity(...)
val rv = util.refVal(selection, vd)
q"scala.Predef.identity[$tpe]($rv: $tpe)"
}
def sub(name: String, tpe: Type, qual: Tree, replace: Tree): Converted[c.type] = {
val tag = c.WeakTypeTag[T](tpe)