{"action":"closed","issue":{"url":"https://api.github.com/repos/emmalanguage/emma/issues/234","repository_url":"https://api.github.com/repos/emmalanguage/emma","labels_url":"https://api.github.com/repos/emmalanguage/emma/issues/234/labels{/name}","comments_url":"https://api.github.com/repos/emmalanguage/emma/issues/234/comments","events_url":"https://api.github.com/repos/emmalanguage/emma/issues/234/events","html_url":"https://github.com/emmalanguage/emma/issues/234","id":179179952,"number":234,"title":"Inferred references to inaccessible types shouldn't be made explicit","user":{"login":"ggevay","id":11377925,"avatar_url":"https://avatars3.githubusercontent.com/u/11377925?v=3","gravatar_id":"","url":"https://api.github.com/users/ggevay","html_url":"https://github.com/ggevay","followers_url":"https://api.github.com/users/ggevay/followers","following_url":"https://api.github.com/users/ggevay/following{/other_user}","gists_url":"https://api.github.com/users/ggevay/gists{/gist_id}","starred_url":"https://api.github.com/users/ggevay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggevay/subscriptions","organizations_url":"https://api.github.com/users/ggevay/orgs","repos_url":"https://api.github.com/users/ggevay/repos","events_url":"https://api.github.com/users/ggevay/events{/privacy}","received_events_url":"https://api.github.com/users/ggevay/received_events","type":"User","site_admin":false},"labels":[{"id":83812983,"url":"https://api.github.com/repos/emmalanguage/emma/labels/bug","name":"bug","color":"fc2929","default":true},{"id":182725005,"url":"https://api.github.com/repos/emmalanguage/emma/labels/IR","name":"IR","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-26T09:30:19Z","updated_at":"2017-04-28T15:38:35Z","closed_at":"2017-04-28T15:38:35Z","body":"Unfortunately the following code compiles:\n\n```\ncase class A() {\n  protected case class B()\n  val getB = B()\n}\nval a = A()\nval b = a.getB\n```\n\n(Note, that it also compiles with `private[A]` instead of `protected`, but doesn't compile with `private`. Also note that code like this occurs [2] in the Scala standard library. Also see [1].)\n\nThe strange thing here is that even though the type of `b` can be inferred, it cannot be explicitly written out. That is, the following does not compile:\n\n```\nval b: a.B = a.getB\n```\n\nNow the problem is that some of our transformations might want to write that type out. For example, if we have `f(a.getB)`, then ANF used to create a ValDef for `a.getB` and write out the type. This was fixed with b0e40f4b21952c549273ef214155c5b100e33f51 by leaving the type of all ValDefs empty.\n\nHowever, the problem is not that easy to fix in some other situations, where we can't simply omit the type:\n- when `b` is part of the closure of some code that we want to compile separately, then the type of `b` appears as the type of a parameter of the wrapper method\n- when we are processing a lambda that originally didn't have its parameter's type specified, but we pull it into a ValDef where it cannot inferred anymore.\n- probably also when ANF introduces a DefDef\n\nThere are some solution ideas that might work:\n- We could use the singleton type of `b`.\n- We could improvise a construct like C++'s `decltype` [3], and use it on `b`.\n\n[1] https://issues.scala-lang.org/browse/SI-6794\n[2] See `scala.collection.generic.GenericCompanion.Coll`, which escapes when calling for example `zipWithIndex`.\n[3] http://stackoverflow.com/questions/29038214/why-scala-does-not-have-a-decltype\n"}}
{"actor":{"display_login":"joroKr21"}}