-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested methods capture outer instance when lifted #9390
Comments
@nilskp said: |
@lrytz said (edited on Jul 24, 2015 8:14:42 AM UTC): The class class C {
def methodLift = {
def isPrime(c: Int) = BigInt(c).isProbablePrime(1)
val f: Int => Boolean = isPrime
f(0)
}
} compiles to (with delambdafy:method, indylambda) class C {
def anonfun$1(i: Int) = this.isPrime$1(i)
def isPrime$1(i: Int) = BigInt(c).isProbablePrime(1)
def methodLift = {
// lambda captures `this`, in order to be able to invoke the instance method `anonfun$1`
val f = indyLambda(this, MethodHandle(anonfun$1))
f.apply(0)
}
} |
@lrytz said: |
@nilskp said: |
@lrytz said (edited on Jul 25, 2015 5:45:38 PM UTC): |
@retronym said: |
@retronym said: |
@retronym said: |
@Blaisorblade said: |
In this unit test,
methodLift
fails, whileasFunction
passes.The text was updated successfully, but these errors were encountered: