scala-dev icon indicating copy to clipboard operation
scala-dev copied to clipboard

Identify more statically resolved (effectively final) methods

Open lrytz opened this issue 10 years ago • 1 comments
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

lrytz avatar Sep 23 '15 15:09 lrytz

relatedly https://github.com/scala/scala/pull/10629 for tailrec

som-snytt avatar Mar 10 '24 00:03 som-snytt