Partial functions give rise to synthetic anonymous classes, and anonymous classes have known issues with typecheck-reset-retypechecking: https://issues.scala-lang.org/browse/SI-6187
17:04 ~/Projects/Kepler_macrosnippet00/sandbox (topic/macrosnippet00)$ scalac -Ymacro-debug-lite Test.scala
performing macro expansion Macros.lift[ActionId](ActionId.apply()) at source-/Users/xeno_by/Projects/Kepler_macrosnippet00/sandbox/Test.scala,line-11,offset=449
((implicit state) => ActionId.apply())
Function(List(ValDef(Modifiers(IMPLICIT | PARAM), newTermName("state"), TypeTree(), EmptyTree)), Apply(Select(Ident(ActionId), newTermName("apply")), List()))
performing macro expansion Macros.lift[AndNext](ActionId.apply().andNext(({
@SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractPartialFunction[Int,Int => Action] with Serializable {
def <init>(): anonymous class $anonfun = {
$anonfun.super.<init>();
()
};
final override def applyOrElse[A1 >: Nothing <: Int, B1 >: Int => Action <: Any](x$1: A1, default: A1 => B1): B1 = (x$1: A1 @unchecked) match {
case _ => ((implicit state: Int) => ActionId.apply())
};
final def isDefinedAt(x$1: Int): Boolean = (x$1: Int @unchecked) match {
case _ => true
}
};
new anonymous class $anonfun() // an anonymous class created for a partial function
}: PartialFunction[Int,Int => Action]))) at source-/Users/xeno_by/Projects/Kepler_macrosnippet00/sandbox/Test.scala,line-11,offset=421
((implicit state) => ActionId.apply().andNext(({
final <synthetic> class $anonfun extends scala.runtime.AbstractPartialFunction[Int,Int => Action] with Serializable {
def <init>() = {
super.<init>();
()
};
final override def applyOrElse[A1 <: Int, B1 >: Int => Action](x$1, default) = (x$1: <type ?>) match {
case _ => ((implicit state: Int) => ActionId.apply())
};
final def isDefinedAt(x$1: Int): Boolean = (x$1: Int @unchecked) match {
case _ => true
}
};
new <type ?>() // <= the problem is here: the type has been irreversibly erased by resetLocalAttrs
}: PartialFunction[Int,Int => Action])))