{"action":"created","issue":{"url":"https://api.github.com/repos/scala/scala/issues/4704","labels_url":"https://api.github.com/repos/scala/scala/issues/4704/labels{/name}","comments_url":"https://api.github.com/repos/scala/scala/issues/4704/comments","events_url":"https://api.github.com/repos/scala/scala/issues/4704/events","html_url":"https://github.com/scala/scala/pull/4704","id":102580237,"number":4704,"title":"SI-9442 Fix the uncurry-erasure types","user":{"login":"VladUreche","id":428706,"avatar_url":"https://avatars.githubusercontent.com/u/428706?v=3","gravatar_id":"","url":"https://api.github.com/users/VladUreche","html_url":"https://github.com/VladUreche","followers_url":"https://api.github.com/users/VladUreche/followers","following_url":"https://api.github.com/users/VladUreche/following{/other_user}","gists_url":"https://api.github.com/users/VladUreche/gists{/gist_id}","starred_url":"https://api.github.com/users/VladUreche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladUreche/subscriptions","organizations_url":"https://api.github.com/users/VladUreche/orgs","repos_url":"https://api.github.com/users/VladUreche/repos","events_url":"https://api.github.com/users/VladUreche/events{/privacy}","received_events_url":"https://api.github.com/users/VladUreche/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/scala/scala/milestones/49","html_url":"https://github.com/scala/scala/milestones/2.11.8","labels_url":"https://api.github.com/repos/scala/scala/milestones/49/labels","id":1169165,"number":49,"title":"2.11.8","description":"Merge to 2.11.x.\r\n","creator":{"login":"SethTisue","id":161079,"avatar_url":"https://avatars.githubusercontent.com/u/161079?v=3","gravatar_id":"","url":"https://api.github.com/users/SethTisue","html_url":"https://github.com/SethTisue","followers_url":"https://api.github.com/users/SethTisue/followers","following_url":"https://api.github.com/users/SethTisue/following{/other_user}","gists_url":"https://api.github.com/users/SethTisue/gists{/gist_id}","starred_url":"https://api.github.com/users/SethTisue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SethTisue/subscriptions","organizations_url":"https://api.github.com/users/SethTisue/orgs","repos_url":"https://api.github.com/users/SethTisue/repos","events_url":"https://api.github.com/users/SethTisue/events{/privacy}","received_events_url":"https://api.github.com/users/SethTisue/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":69,"state":"open","created_at":"2015-06-17T19:08:28Z","updated_at":"2015-08-23T10:33:16Z","due_on":"2015-09-21T07:00:00Z","closed_at":null},"comments":7,"created_at":"2015-08-23T02:00:28Z","updated_at":"2015-08-23T12:04:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scala/scala/pulls/4704","html_url":"https://github.com/scala/scala/pull/4704","diff_url":"https://github.com/scala/scala/pull/4704.diff","patch_url":"https://github.com/scala/scala/pull/4704.patch"},"body":"Using the \"uncurry-erased\" type (the one after the uncurry phase) can lead to incorrect tree transformations, such as:\r\n```\r\n  def foo(c: Ctx)(l: c.Tree): Unit = {\r\n    val l2: c.Tree = l\r\n  }\r\n```\r\nwhich gets transformed into:\r\n```\r\n  def foo(c: Ctx, l: Ctx#Tree): Unit = {\r\n    val l$1: Ctx#Tree = l.asInstanceOf[Ctx#Tree]\r\n    val l2: c.Tree = l$1 // no, not really, it's not.\r\n  }\r\n```\r\nSo what we need to do is to take the pre-uncurry type when forming `l$1`,\r\nwhich is `c.Tree` and is correct. Now, there are two additional problems:\r\n  1. the type needs to be normalized, since `gen.mkCast` checks this (no\r\n     HK here, just aliases have to be expanded before handing the type\r\n     to `gen.mkAttributedCast`, which calls `gen.mkCast`)\r\n  2. when varargs and byname params are involved, use the post-uncurry\r\n     type, since uncurry transforms these types into Sequences (Scala\r\n     varargs), Arrays (Java varargs) or Function0 (by name params)"},"comment":{"url":"https://api.github.com/repos/scala/scala/issues/comments/133822349","html_url":"https://github.com/scala/scala/pull/4704#issuecomment-133822349","issue_url":"https://api.github.com/repos/scala/scala/issues/4704","id":133822349,"user":{"login":"VladUreche","id":428706,"avatar_url":"https://avatars.githubusercontent.com/u/428706?v=3","gravatar_id":"","url":"https://api.github.com/users/VladUreche","html_url":"https://github.com/VladUreche","followers_url":"https://api.github.com/users/VladUreche/followers","following_url":"https://api.github.com/users/VladUreche/following{/other_user}","gists_url":"https://api.github.com/users/VladUreche/gists{/gist_id}","starred_url":"https://api.github.com/users/VladUreche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladUreche/subscriptions","organizations_url":"https://api.github.com/users/VladUreche/orgs","repos_url":"https://api.github.com/users/VladUreche/repos","events_url":"https://api.github.com/users/VladUreche/events{/privacy}","received_events_url":"https://api.github.com/users/VladUreche/received_events","type":"User","site_admin":false},"created_at":"2015-08-23T12:04:40Z","updated_at":"2015-08-23T12:04:40Z","body":"> Could you please rename the test file to tXXXX.scala?\r\n\r\nDone, will commit as soon as the local test suite gives me the okay.\r\n\r\n>  Your patch implements what I had tried (but failed) to implement. Not sure how I didn't see that :frowning:\r\n\r\nI wouldn't worry so much about not noticing the issue, but `-Ycheck` should have found it. I guess a good thing for humanity (erm, for ourselves) would be to see why it didn't catch this error if and fix that. \r\n\r\n> I'd like to discuss the special cases a bit more. These two examples currently fail in the same way as your test case, but I suspect they won't be fixed by this patch.\r\n>\r\n>```\r\n  def bar(c: Ctx)(l: Lst[c.Tree]*) = l.head zip l.head\r\n  def baz(c: Ctx)(l: => Lst[c.Tree]) = l zip l\r\n```\r\n\r\nThanks for pointing that out. I just pushed a patch that fixes these cases as well :+1:.\r\n\r\n> I might have asked @odersky this before, but I wonder why parameter list uncurrying isn't just done as part of `erasure`.\r\n\r\nIMHO, erasure is already a baroque mix of too many unrelated transformations. I'm sure performance is good reason for this (at least in Scala where we don't have @DarkDimius' phase fusion), but adding more work there is probably not a good idea on the long run."}}