{"action":"created","issue":{"url":"https://api.github.com/repos/scala/scala/issues/5099","repository_url":"https://api.github.com/repos/scala/scala","labels_url":"https://api.github.com/repos/scala/scala/issues/5099/labels{/name}","comments_url":"https://api.github.com/repos/scala/scala/issues/5099/comments","events_url":"https://api.github.com/repos/scala/scala/issues/5099/events","html_url":"https://github.com/scala/scala/pull/5099","id":148246614,"number":5099,"title":"SI-9390 Emit local defs that don't capture this as static","user":{"login":"retronym","id":65551,"avatar_url":"https://avatars.githubusercontent.com/u/65551?v=3","gravatar_id":"","url":"https://api.github.com/users/retronym","html_url":"https://github.com/retronym","followers_url":"https://api.github.com/users/retronym/followers","following_url":"https://api.github.com/users/retronym/following{/other_user}","gists_url":"https://api.github.com/users/retronym/gists{/gist_id}","starred_url":"https://api.github.com/users/retronym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/retronym/subscriptions","organizations_url":"https://api.github.com/users/retronym/orgs","repos_url":"https://api.github.com/users/retronym/repos","events_url":"https://api.github.com/users/retronym/events{/privacy}","received_events_url":"https://api.github.com/users/retronym/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scala/scala/labels/release-notes","name":"release-notes","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/scala/scala/milestones/52","html_url":"https://github.com/scala/scala/milestones/2.12.0-M5","labels_url":"https://api.github.com/repos/scala/scala/milestones/52/labels","id":1355301,"number":52,"title":"2.12.0-M5","description":"Merge to 2.12.x. \r\n\r\nBug fixes to stabilize existing features only. Ticket must be created and assigned to M5 milestone on scala/scala-dev: https://github.com/scala/scala-dev/milestones/2.12.0-M5.\r\n\r\nOne potential exception to the no-big-refactorings-rule -- TBD:\r\n  - [ ] fields phase + rework lambdalift to reduce capture? (#5035)\r\n","creator":{"login":"adriaanm","id":91083,"avatar_url":"https://avatars.githubusercontent.com/u/91083?v=3","gravatar_id":"","url":"https://api.github.com/users/adriaanm","html_url":"https://github.com/adriaanm","followers_url":"https://api.github.com/users/adriaanm/followers","following_url":"https://api.github.com/users/adriaanm/following{/other_user}","gists_url":"https://api.github.com/users/adriaanm/gists{/gist_id}","starred_url":"https://api.github.com/users/adriaanm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adriaanm/subscriptions","organizations_url":"https://api.github.com/users/adriaanm/orgs","repos_url":"https://api.github.com/users/adriaanm/repos","events_url":"https://api.github.com/users/adriaanm/events{/privacy}","received_events_url":"https://api.github.com/users/adriaanm/received_events","type":"User","site_admin":false},"open_issues":26,"closed_issues":11,"state":"open","created_at":"2015-10-14T13:06:29Z","updated_at":"2016-04-14T04:05:28Z","due_on":"2016-05-27T07:00:00Z","closed_at":null},"comments":5,"created_at":"2016-04-14T04:05:26Z","updated_at":"2016-04-15T03:11:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scala/scala/pulls/5099","html_url":"https://github.com/scala/scala/pull/5099","diff_url":"https://github.com/scala/scala/pull/5099.diff","patch_url":"https://github.com/scala/scala/pull/5099.patch"},"body":"This avoids unnecessary memory retention, and allows lambdas\r\nthat call the local methods to be serializable, regardless of\r\nwhether or not the enclosing class is serializable.\r\n\r\nThe second point is especially pressing, given that the enclosing\r\nclass for local methods defined in a used to be the (serializable)\r\nanonymous function class, but as of Scala 2.12 will be the enclosing\r\nclass of the lambda.\r\n\r\nThis change is similar in spirit to SI-9408 / 93bee55e."},"comment":{"url":"https://api.github.com/repos/scala/scala/issues/comments/210266446","html_url":"https://github.com/scala/scala/pull/5099#issuecomment-210266446","issue_url":"https://api.github.com/repos/scala/scala/issues/5099","id":210266446,"user":{"login":"retronym","id":65551,"avatar_url":"https://avatars.githubusercontent.com/u/65551?v=3","gravatar_id":"","url":"https://api.github.com/users/retronym","html_url":"https://github.com/retronym","followers_url":"https://api.github.com/users/retronym/followers","following_url":"https://api.github.com/users/retronym/following{/other_user}","gists_url":"https://api.github.com/users/retronym/gists{/gist_id}","starred_url":"https://api.github.com/users/retronym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/retronym/subscriptions","organizations_url":"https://api.github.com/users/retronym/orgs","repos_url":"https://api.github.com/users/retronym/repos","events_url":"https://api.github.com/users/retronym/events{/privacy}","received_events_url":"https://api.github.com/users/retronym/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T03:11:09Z","updated_at":"2016-04-15T03:11:09Z","body":"@JoshRosen That's a tricky one. As of [SI-9408](https://issues.scala-lang.org/browse/SI-9408) / 93bee55, the constructor of the anonymous class no longer stores retains a reference to the enclosing class, but its constructor does still include this:\r\n\r\n```\r\nclass MyClass {\r\n  def test = {\r\n    { (x: Any) => new Object {} }\r\n  }\r\n}\r\n```\r\n\r\n```\r\n  final class anon$1 extends Object {\r\n    def <init>($outer: MyClass): <$anon: Object> = {\r\n      anon$1.super.<init>();\r\n      // $outer is not stored in a field\r\n      ()\r\n    }\r\n  }\r\n```\r\n\r\nThe transform responsible for this keeps the constructor signature intact because in general, another compilation unit might be calling the constructor of an inner class, and we need to have an agreed constructor signature given that client and class might be separately compiled.\r\n\r\nHowever, for local classes like in your example, we could in fact totally remove `$outer` from the constructor signature (we'd need to rewrite calls to the constructor in the same method, of course)."}}