@lrytz said (edited on Jul 24, 2015 8:14:42 AM UTC):
This is actually not a bug. The reason is that the lambda body of the eta-expansion of isPrime invokes the isPrime method, which is an instance method, so the lambda needs to capture the C instance.
defanonfun$1(i: Int) =this.isPrime$1(i)
defisPrime$1(i: Int) =BigInt(c).isProbablePrime(1)
// lambda captures `this`, in order to be able to invoke the instance method `anonfun$1`valf= indyLambda(this, MethodHandle(anonfun$1))
@lrytz said (edited on Jul 25, 2015 5:45:38 PM UTC):
at the optimizer phase, where inlining is performed, the outer reference is already there. so even if the method is inlined, we need an additional optimization to eliminate unused outer references, which is not implemented, neither in the 2.11 optimizer nor in the new one for 2.12.
The Delambdafy phase already implements a similar virtual -> static translation for lambda implementation methods, perhaps we can generalize that to do the same thing for lambda-lifted local defs.