scala-dev
scala-dev copied to clipboard
Identify more statically resolved (effectively final) methods
trafficstars
trait TravLike { def map = ... }
sealed trait List extends TravLike { ... } // map is not overridden
final case class ::
final case object Nil
(l: List).map // can be inlined
we need to know that
- the recevier is sealed
- what are the children of the receiver
- all children are final
- none of the children overrides map
https://github.com/scala/scala/blob/2.12.x/src/compiler/scala/tools/nsc/backend/jvm/opt/CallGraph.scala#L293
relatedly https://github.com/scala/scala/pull/10629 for tailrec