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

This commit is contained in:
Eugene Yokota 2020-10-18 03:15:10 -04:00
parent 3a1463bb7d
commit a44aee9ac1
2 changed files with 11 additions and 3 deletions

View File

@ -312,6 +312,16 @@ 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,9 +187,7 @@ object Instance {
qual.foreach(checkQual)
val vd = util.freshValDef(tpe, qual.pos, functionSym)
inputs ::= new Input(tpe, qual, 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)"
util.refVal(selection, vd)
}
def sub(name: String, tpe: Type, qual: Tree, replace: Tree): Converted[c.type] = {
val tag = c.WeakTypeTag[T](tpe)