Skip to content
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

Subtle change in outer capture under -Ydelambdafy:method #9408

Closed
scabug opened this issue Jul 18, 2015 · 6 comments
Closed

Subtle change in outer capture under -Ydelambdafy:method #9408

scabug opened this issue Jul 18, 2015 · 6 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Jul 18, 2015

// test.scala
class C {
  def test {
    println({() => class D; classOf[D].getDeclaredFields.mkString(",")}.apply())
  }
}

object Test {
  def main(args: Array[String]): Unit = {
    new C().test
  }

}
% scalac-hash v2.11.7 test.scala  && scala-hash v2.11.7 Test
public final C$$anonfun$test$1 C$$anonfun$test$1$D$1.$outer

% scalac-hash v2.11.7 -Ydelambdafy:method test.scala  && scala-hash v2.11.7 -Ydelambdafy:method Test
public final C C$D$1.$outer

This difference is observable via a change in memory retention, or a change in the serializability of D (as seen in the wild in Shapeless: milessabin/shapeless@ac12155)

I'm not really sure why we need an outer pointer at all for a local class such as D.

@scabug
Copy link
Author

scabug commented Jul 18, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9408?orig=1
Reporter: @retronym
Affected Versions: 2.11.7
See #4440, #1419

@scabug
Copy link
Author

scabug commented Jul 18, 2015

@retronym said:
See also the discussion bewteen me and @milessabin on on the shapeless commit: milessabin/shapeless@ac12155

@scabug
Copy link
Author

scabug commented Jul 19, 2015

@milessabin said (edited on Jul 19, 2015 10:39:25 AM UTC):
See eventual fix in shapeless here.

@scabug
Copy link
Author

scabug commented Jul 22, 2015

@retronym said:
Here's an attempt to infer the finality of local classes with respect to the outer pointer elision optimization: scala/scala@2.12.x...retronym:ticket/9408

@scabug
Copy link
Author

scabug commented Jul 22, 2015

@retronym said:
scala/scala#4652

@scabug
Copy link
Author

scabug commented Jul 22, 2015

@milessabin said:
Awesome ... thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants