{"action":"created","issue":{"url":"https://api.github.com/repos/scala/scala/issues/5294","repository_url":"https://api.github.com/repos/scala/scala","labels_url":"https://api.github.com/repos/scala/scala/issues/5294/labels{/name}","comments_url":"https://api.github.com/repos/scala/scala/issues/5294/comments","events_url":"https://api.github.com/repos/scala/scala/issues/5294/events","html_url":"https://github.com/scala/scala/pull/5294","id":166706819,"number":5294,"title":"Fields: expand lazy vals during fields, like modules [ci: last-only]","user":{"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},"labels":[],"state":"open","locked":false,"assignee":{"login":"lrytz","id":119636,"avatar_url":"https://avatars.githubusercontent.com/u/119636?v=3","gravatar_id":"","url":"https://api.github.com/users/lrytz","html_url":"https://github.com/lrytz","followers_url":"https://api.github.com/users/lrytz/followers","following_url":"https://api.github.com/users/lrytz/following{/other_user}","gists_url":"https://api.github.com/users/lrytz/gists{/gist_id}","starred_url":"https://api.github.com/users/lrytz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrytz/subscriptions","organizations_url":"https://api.github.com/users/lrytz/orgs","repos_url":"https://api.github.com/users/lrytz/repos","events_url":"https://api.github.com/users/lrytz/events{/privacy}","received_events_url":"https://api.github.com/users/lrytz/received_events","type":"User","site_admin":false},"assignees":[{"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},{"login":"lrytz","id":119636,"avatar_url":"https://avatars.githubusercontent.com/u/119636?v=3","gravatar_id":"","url":"https://api.github.com/users/lrytz","html_url":"https://github.com/lrytz","followers_url":"https://api.github.com/users/lrytz/followers","following_url":"https://api.github.com/users/lrytz/following{/other_user}","gists_url":"https://api.github.com/users/lrytz/gists{/gist_id}","starred_url":"https://api.github.com/users/lrytz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrytz/subscriptions","organizations_url":"https://api.github.com/users/lrytz/orgs","repos_url":"https://api.github.com/users/lrytz/repos","events_url":"https://api.github.com/users/lrytz/events{/privacy}","received_events_url":"https://api.github.com/users/lrytz/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/scala/scala/milestones/47","html_url":"https://github.com/scala/scala/milestones/2.12.0-RC1","labels_url":"https://api.github.com/repos/scala/scala/milestones/47/labels","id":977200,"number":47,"title":"2.12.0-RC1","description":"The PR queue for RC1 is now closed. We'll release as soon as the all PRs have been reviewed and merged. Once RC1 is out, we'll branch for 2.12.0.  [Discussion](https://groups.google.com/d/msg/scala-internals/hxDjZfm1h3c/Y5OkHdatAAAJ)\r\n\r\n2.12.1 development will continue on the 2.12.x branch during the RC cycle.\r\n\r\nLead: @adriaanm\r\n\r\nMerge to 2.12.0.","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":3,"closed_issues":89,"state":"open","created_at":"2015-02-12T17:53:06Z","updated_at":"2016-08-30T11:11:06Z","due_on":"2016-08-29T00:00:00Z","closed_at":null},"comments":58,"created_at":"2016-07-20T23:38:43Z","updated_at":"2016-08-30T11:13:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scala/scala/pulls/5294","html_url":"https://github.com/scala/scala/pull/5294","diff_url":"https://github.com/scala/scala/pull/5294.diff","patch_url":"https://github.com/scala/scala/pull/5294.patch"},"body":"(follow up for #5141 )\r\n\r\n# Fields phase fully expands lazy vals and modules\r\n\r\nMixins is relieved of its bitmap emission duties.\r\n\r\n## Important changes\r\n\r\n - the locking scope of a local lazy val is now tied to the lazy val, following Dotty's encoding\r\n - specialized lazy vals work because the full expansion happens before specialization\r\n\r\n## Internal details\r\n\r\nLazy vals remain `ValDef`s (with a method symbol for its accessor) until the fields phase, along with deferred vals and all trait vals. Code that previously only considered `DefDef`s when looking for accessors will need to widen this search to `ValOrDefDef`. Also, `accessed` will not lead to a field in these cases (ultimately, we should delay all field creation until fields.)\r\n\r\nLazy val accessors, fields and bitmaps are now mixed in during the fields phase, which means erasure and specialization get a better look at them. Should we also move mixins before erasure? \r\n\r\n@lrytz did the bulk of the work in moving our encoding of local lazy vals to the scheme used by Dotty, based on a suggestion by @DarkDimius. Locking is now down on the holder of the lazy val's value / init bit, instead of on the enclosing class (which had widened from the closure class to the owner of the method, making this more prone to deadlocks).\r\n\r\nAll lazy vals and modules use double-checked locking, but modules no longer spin off their initialization to a compute method (it's short enough not to interfere with the inlining of the lazy accessor).\r\n\r\n## Notes from the implementation lab journal\r\n\r\n- remove lazy accessor logic\r\n  now that we have a single ValDef for lazy vals,\r\n  with the underlying machinery being hidden until the fields phase\r\n  leave a `@deprecated def lazyAccessor` for scala-refactoring\r\n\r\n- don't skolemize in purely synthetic getters,\r\n  but *do* skolemize in lazy accessor during typers\r\n\r\n  Lazy accessors have arbitrary user code, so have to skolemize.\r\n  We exempt the purely synthetic accessors (`isSyntheticAccessor`)\r\n  for strict vals, and lazy accessors emitted by the fields phase\r\n  to avoid spurious type mismatches due to issues with existentials\r\n  (That bug is tracked as scala/scala-dev#165)\r\n\r\n  When we're past typer, lazy accessors are synthetic,\r\n  but before they are user-defined to make this hack less hacky,\r\n  we could rework our flag usage to allow for\r\n  requiring both the ACCESSOR and the SYNTHETIC bits\r\n  to identify synthetic accessors and trigger the exemption.\r\n\r\n  see also scala/scala-dev#165\r\n\r\n  ok 7 - pos/existentials-harmful.scala\r\n  ok 8 - pos/t2435.scala\r\n  ok 9 - pos/existentials.scala\r\n\r\n  previous attempt: skolemize type of val inside the private[this] val\r\n\r\n  because its type is only observed from inside the\r\n  accessor methods (inside the method scope its existentials are skolemized)\r\n\r\n- bean accessors have regular method types, not nullary method types\r\n- must re-infer type for param accessor\r\n  some weirdness with scoping of param accessor vals and defs?\r\n- tailcalls detect lazy vals, which are defdefs after fields\r\n- can inline constant lazy val from trait\r\n- don't mix in fields etc for an overridden lazy val\r\n- need try-lift in lazy vals: the assign is not seen in uncurry\r\n  because fields does the transform (see run/t2333.scala)\r\n- ensure field members end up final in bytecode\r\n- implicit class companion method: annot filter in completer\r\n- update check: previous error message was tangled up with unrelated\r\n  field definitions (`var s` and `val s_scope`),\r\n  now it behaves consistently whether those are val/vars or defs\r\n- analyzer plugin check update seems benign, but no way to know...\r\n- error message gen: there is no underlying symbol for a deferred var;  look for missing getter/setter instead\r\n- avoid retypechecking valdefs while duplicating for specialize --  see pos/spec-private\r\n- Scaladoc uniformly looks to field/accessor symbol\r\n- test updates to innerClassAttribute by Lukas\r\n\r\n## TODO:\r\n### tests / review follow up\r\n  - [x] https://github.com/scala/scala/pull/5141#discussion_r74368912\r\n  - [x] scalacheck/quasiquotes         \r\n  - [x] presentation/t5708             \r\n  - [x] presentation/t8459             \r\n  - [x] run/t7767.scala                \r\n  - [x] scalacheck/HtmlFactoryTest.scala\r\n  - [x] SI-8873 `@volatile` var cannot be defined in case class with confusing error message\r\n  - [x] neg/t712.scala\r\n  - [x] run/existential-rangepos.scala\r\n  - [x] run/idempotency-case-classes.scala\r\n  - [x] run/reify_ann3.scala\r\n  - [x] run/reify_ann5.scala\r\n  - [x] run/repl-colon-type.scala\r\n  - [x] run/trait-fields-override-lazy.scala\r\n  - [x] run/analyzerPlugins.scala\r\n  - [x] neg/abstract-vars.scala  update users of `analyzer.underlyingSymbol` to reflect abstract val/vars don't have a field\r\n  - [x] pos/spec-private.scala\r\n  - [x] run/t8549.scala  (check bytecode of scala/collection/mutable/DoubleLinkedList.scala)\r\n  - [X] jvm/innerClassAttribute -- understand bytecode changes in jvm/innerClassAttribute/Classes_1.scala  https://gist.github.com/adriaanm/833837b204141a130abaaa6a62ed8596 (thanks, Lukas!) \r\n  - [x] -Xcheckinit\r\n  - [x] look at bootstrapped bytecode diff\r\n\r\n### community build\r\n  - [x] bring back lazyAccessor for scala-refactoring\r\n  - [x] scalaz (missing sig for implicit val at position after use site)\r\n  - [x] scala-js ExportsTest fail (valdefs may also contribute exported methods: deferred val/trait val/lazy val)\r\n  - [x] akka (existential in lazy val accessor)\r\n\r\n### follow ups after RC1:\r\n  - failing test in macro-paradise\r\n  - rangepos\r\n"},"comment":{"url":"https://api.github.com/repos/scala/scala/issues/comments/243407440","html_url":"https://github.com/scala/scala/pull/5294#issuecomment-243407440","issue_url":"https://api.github.com/repos/scala/scala/issues/5294","id":243407440,"user":{"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},"created_at":"2016-08-30T11:13:39Z","updated_at":"2016-08-30T11:13:39Z","body":"Ok, great! Could you port the change from cleanups in my commit here to the suitable spot in scala-js, please? "}}
{"actor":{"display_login":"adriaanm"}}