Help understanding local class definitions

def f1(n: Int): Class[_ <: Int=>Int] = {
  def f2(m: Int): Int = n+m

  (f2 _).getClass
}

f1(1) eq f1(2) // true

Runtime classes are way less powerful than compile time types. If you’re going to use runtime reflection that’s something you have to live with. And unfortunately you also have to be aware that runtime type tests (x.isInstanceOf[Y] or case x: Y =>) work with the erased runtime class. Most of the time you’ll get a warning when you do a type test that is unsafe—like on a parameterized type—but not always.