{"action":"created","comment":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/comments/197099434","pull_request_review_id":130774285,"id":197099434,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzA5OTQzNA==","diff_hunk":"@@ -0,0 +1,68 @@\n+package dotty.tools.dotc\n+package transform\n+\n+import ast.{Trees, tpd}\n+import core._, core.Decorators._\n+import MegaPhase._, Phases.Phase\n+import Types._, Contexts._, Constants._, Names._, NameOps._, Flags._, DenotTransformers._\n+import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Scopes._, Denotations._\n+import TypeErasure.ErasedValueType, ValueClasses._\n+\n+/** This phase rewrite PolyFunction subclasses to FunctionN subclasses\n+ *\n+ *      class Foo extends PolyFunction {\n+ *          def apply(x_1: P_1, ..., x_N: P_N): R = rhs\n+ *      }\n+ *   becomes:\n+ *      class Foo extends FunctionN {\n+ *          def apply(x_1: P_1, ..., x_N: P_N): R = rhs\n+ *      }","path":"compiler/src/dotty/tools/dotc/transform/ElimPolyFunction.scala","position":19,"original_position":19,"commit_id":"86a7a5af88fa1b57e111fc4e360c9b22f65485e1","original_commit_id":"86a7a5af88fa1b57e111fc4e360c9b22f65485e1","user":{"login":"LPTK","id":2545083,"node_id":"MDQ6VXNlcjI1NDUwODM=","avatar_url":"https://avatars3.githubusercontent.com/u/2545083?v=4","gravatar_id":"","url":"https://api.github.com/users/LPTK","html_url":"https://github.com/LPTK","followers_url":"https://api.github.com/users/LPTK/followers","following_url":"https://api.github.com/users/LPTK/following{/other_user}","gists_url":"https://api.github.com/users/LPTK/gists{/gist_id}","starred_url":"https://api.github.com/users/LPTK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LPTK/subscriptions","organizations_url":"https://api.github.com/users/LPTK/orgs","repos_url":"https://api.github.com/users/LPTK/repos","events_url":"https://api.github.com/users/LPTK/events{/privacy}","received_events_url":"https://api.github.com/users/LPTK/received_events","type":"User","site_admin":false},"body":"Note that it can be really useful being able to extend/implement a polymorphic function type; it's one of the use cases I mention in https://github.com/lampepfl/dotty/issues/4670#issuecomment-397819801 – making polymorphic type classes extend the corresponding polymorphic function type.","created_at":"2018-06-21T11:30:09Z","updated_at":"2018-06-21T11:30:09Z","html_url":"https://github.com/lampepfl/dotty/pull/4672#discussion_r197099434","pull_request_url":"https://api.github.com/repos/lampepfl/dotty/pulls/4672","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/comments/197099434"},"html":{"href":"https://github.com/lampepfl/dotty/pull/4672#discussion_r197099434"},"pull_request":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/4672"}},"in_reply_to_id":197078013},"pull_request":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/4672","id":195253378,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1MjUzMzc4","html_url":"https://github.com/lampepfl/dotty/pull/4672","diff_url":"https://github.com/lampepfl/dotty/pull/4672.diff","patch_url":"https://github.com/lampepfl/dotty/pull/4672.patch","issue_url":"https://api.github.com/repos/lampepfl/dotty/issues/4672","number":4672,"state":"open","locked":false,"title":"[Proof of concept] Polymorphic function types","user":{"login":"smarter","id":63430,"node_id":"MDQ6VXNlcjYzNDMw","avatar_url":"https://avatars2.githubusercontent.com/u/63430?v=4","gravatar_id":"","url":"https://api.github.com/users/smarter","html_url":"https://github.com/smarter","followers_url":"https://api.github.com/users/smarter/followers","following_url":"https://api.github.com/users/smarter/following{/other_user}","gists_url":"https://api.github.com/users/smarter/gists{/gist_id}","starred_url":"https://api.github.com/users/smarter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarter/subscriptions","organizations_url":"https://api.github.com/users/smarter/orgs","repos_url":"https://api.github.com/users/smarter/repos","events_url":"https://api.github.com/users/smarter/events{/privacy}","received_events_url":"https://api.github.com/users/smarter/received_events","type":"User","site_admin":false},"body":"This is a sketch of how polymorphic function types could be implemented in Dotty, this PR adds types that look like:\r\n```scala\r\n[T <: AnyVal] -> List[T] => List[(T, T)]\r\n```\r\nand a way of writing values of these types:\r\n```scala\r\nval f = [T <: AnyVal] -> (x: List[T]) => x.map(e => (e, e))\r\n```\r\nJust like `P => R` has a method `def apply(x: A): B`, `[T] => P => R` has a method `def apply[T](x: P): R` (in fact, it doesn't have any other method). Behind the scene, this is erased to a regular `scala.FunctionN`, see the commit messages for more details.\r\n\r\nThis PR isn't complete, this is just a quick experiment done in a few hours. In particular, I haven't tried to work out how this interact with implicit/erased/dependent function types and SAM types. I also haven't tried to implement polymorphic eta-expansion yet, e.g. given:\r\n```scala\r\ndef foo(x: [T] -> T => Option[T]): Unit\r\n```\r\nwe'd like to be able to write:\r\n```scala\r\nfoo(Some)\r\n```\r\nbut for now you'll have to write:\r\n```scala\r\nfoo([T] -> (x: T) => Some(x))\r\n```","created_at":"2018-06-15T18:37:16Z","updated_at":"2018-06-21T11:30:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c26c4d4ca1c84d9990128a37a8ee9029237ce402","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":436371980,"node_id":"MDU6TGFiZWw0MzYzNzE5ODA=","url":"https://api.github.com/repos/lampepfl/dotty/labels/stat:wip","name":"stat:wip","color":"f9d0c4","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lampepfl/dotty/pulls/4672/commits","review_comments_url":"https://api.github.com/repos/lampepfl/dotty/pulls/4672/comments","review_comment_url":"https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lampepfl/dotty/issues/4672/comments","statuses_url":"https://api.github.com/repos/lampepfl/dotty/statuses/86a7a5af88fa1b57e111fc4e360c9b22f65485e1","head":{"label":"dotty-staging:poly-functions","ref":"poly-functions","sha":"86a7a5af88fa1b57e111fc4e360c9b22f65485e1","user":{"login":"dotty-staging","id":6998674,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5OTg2NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6998674?v=4","gravatar_id":"","url":"https://api.github.com/users/dotty-staging","html_url":"https://github.com/dotty-staging","followers_url":"https://api.github.com/users/dotty-staging/followers","following_url":"https://api.github.com/users/dotty-staging/following{/other_user}","gists_url":"https://api.github.com/users/dotty-staging/gists{/gist_id}","starred_url":"https://api.github.com/users/dotty-staging/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotty-staging/subscriptions","organizations_url":"https://api.github.com/users/dotty-staging/orgs","repos_url":"https://api.github.com/users/dotty-staging/repos","events_url":"https://api.github.com/users/dotty-staging/events{/privacy}","received_events_url":"https://api.github.com/users/dotty-staging/received_events","type":"Organization","site_admin":false},"repo":{"id":17904384,"node_id":"MDEwOlJlcG9zaXRvcnkxNzkwNDM4NA==","name":"dotty","full_name":"dotty-staging/dotty","owner":{"login":"dotty-staging","id":6998674,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5OTg2NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6998674?v=4","gravatar_id":"","url":"https://api.github.com/users/dotty-staging","html_url":"https://github.com/dotty-staging","followers_url":"https://api.github.com/users/dotty-staging/followers","following_url":"https://api.github.com/users/dotty-staging/following{/other_user}","gists_url":"https://api.github.com/users/dotty-staging/gists{/gist_id}","starred_url":"https://api.github.com/users/dotty-staging/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotty-staging/subscriptions","organizations_url":"https://api.github.com/users/dotty-staging/orgs","repos_url":"https://api.github.com/users/dotty-staging/repos","events_url":"https://api.github.com/users/dotty-staging/events{/privacy}","received_events_url":"https://api.github.com/users/dotty-staging/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotty-staging/dotty","description":"Research platform for new language concepts and compiler technologies for Scala.","fork":true,"url":"https://api.github.com/repos/dotty-staging/dotty","forks_url":"https://api.github.com/repos/dotty-staging/dotty/forks","keys_url":"https://api.github.com/repos/dotty-staging/dotty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotty-staging/dotty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotty-staging/dotty/teams","hooks_url":"https://api.github.com/repos/dotty-staging/dotty/hooks","issue_events_url":"https://api.github.com/repos/dotty-staging/dotty/issues/events{/number}","events_url":"https://api.github.com/repos/dotty-staging/dotty/events","assignees_url":"https://api.github.com/repos/dotty-staging/dotty/assignees{/user}","branches_url":"https://api.github.com/repos/dotty-staging/dotty/branches{/branch}","tags_url":"https://api.github.com/repos/dotty-staging/dotty/tags","blobs_url":"https://api.github.com/repos/dotty-staging/dotty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotty-staging/dotty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotty-staging/dotty/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotty-staging/dotty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotty-staging/dotty/statuses/{sha}","languages_url":"https://api.github.com/repos/dotty-staging/dotty/languages","stargazers_url":"https://api.github.com/repos/dotty-staging/dotty/stargazers","contributors_url":"https://api.github.com/repos/dotty-staging/dotty/contributors","subscribers_url":"https://api.github.com/repos/dotty-staging/dotty/subscribers","subscription_url":"https://api.github.com/repos/dotty-staging/dotty/subscription","commits_url":"https://api.github.com/repos/dotty-staging/dotty/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotty-staging/dotty/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotty-staging/dotty/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotty-staging/dotty/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotty-staging/dotty/contents/{+path}","compare_url":"https://api.github.com/repos/dotty-staging/dotty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotty-staging/dotty/merges","archive_url":"https://api.github.com/repos/dotty-staging/dotty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotty-staging/dotty/downloads","issues_url":"https://api.github.com/repos/dotty-staging/dotty/issues{/number}","pulls_url":"https://api.github.com/repos/dotty-staging/dotty/pulls{/number}","milestones_url":"https://api.github.com/repos/dotty-staging/dotty/milestones{/number}","notifications_url":"https://api.github.com/repos/dotty-staging/dotty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotty-staging/dotty/labels{/name}","releases_url":"https://api.github.com/repos/dotty-staging/dotty/releases{/id}","deployments_url":"https://api.github.com/repos/dotty-staging/dotty/deployments","created_at":"2014-03-19T13:06:15Z","updated_at":"2018-06-19T03:27:53Z","pushed_at":"2018-06-21T11:26:33Z","git_url":"git://github.com/dotty-staging/dotty.git","ssh_url":"git@github.com:dotty-staging/dotty.git","clone_url":"https://github.com/dotty-staging/dotty.git","svn_url":"https://github.com/dotty-staging/dotty","homepage":"","size":50789,"stargazers_count":12,"watchers_count":12,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4,"open_issues":0,"watchers":12,"default_branch":"master"}},"base":{"label":"lampepfl:master","ref":"master","sha":"76b110b5bb029a6607f517304dd2fa9c58547a88","user":{"login":"lampepfl","id":2684793,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2ODQ3OTM=","avatar_url":"https://avatars1.githubusercontent.com/u/2684793?v=4","gravatar_id":"","url":"https://api.github.com/users/lampepfl","html_url":"https://github.com/lampepfl","followers_url":"https://api.github.com/users/lampepfl/followers","following_url":"https://api.github.com/users/lampepfl/following{/other_user}","gists_url":"https://api.github.com/users/lampepfl/gists{/gist_id}","starred_url":"https://api.github.com/users/lampepfl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lampepfl/subscriptions","organizations_url":"https://api.github.com/users/lampepfl/orgs","repos_url":"https://api.github.com/users/lampepfl/repos","events_url":"https://api.github.com/users/lampepfl/events{/privacy}","received_events_url":"https://api.github.com/users/lampepfl/received_events","type":"Organization","site_admin":false},"repo":{"id":7035651,"node_id":"MDEwOlJlcG9zaXRvcnk3MDM1NjUx","name":"dotty","full_name":"lampepfl/dotty","owner":{"login":"lampepfl","id":2684793,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2ODQ3OTM=","avatar_url":"https://avatars1.githubusercontent.com/u/2684793?v=4","gravatar_id":"","url":"https://api.github.com/users/lampepfl","html_url":"https://github.com/lampepfl","followers_url":"https://api.github.com/users/lampepfl/followers","following_url":"https://api.github.com/users/lampepfl/following{/other_user}","gists_url":"https://api.github.com/users/lampepfl/gists{/gist_id}","starred_url":"https://api.github.com/users/lampepfl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lampepfl/subscriptions","organizations_url":"https://api.github.com/users/lampepfl/orgs","repos_url":"https://api.github.com/users/lampepfl/repos","events_url":"https://api.github.com/users/lampepfl/events{/privacy}","received_events_url":"https://api.github.com/users/lampepfl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lampepfl/dotty","description":"Research compiler that will become Scala 3","fork":false,"url":"https://api.github.com/repos/lampepfl/dotty","forks_url":"https://api.github.com/repos/lampepfl/dotty/forks","keys_url":"https://api.github.com/repos/lampepfl/dotty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lampepfl/dotty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lampepfl/dotty/teams","hooks_url":"https://api.github.com/repos/lampepfl/dotty/hooks","issue_events_url":"https://api.github.com/repos/lampepfl/dotty/issues/events{/number}","events_url":"https://api.github.com/repos/lampepfl/dotty/events","assignees_url":"https://api.github.com/repos/lampepfl/dotty/assignees{/user}","branches_url":"https://api.github.com/repos/lampepfl/dotty/branches{/branch}","tags_url":"https://api.github.com/repos/lampepfl/dotty/tags","blobs_url":"https://api.github.com/repos/lampepfl/dotty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lampepfl/dotty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lampepfl/dotty/git/refs{/sha}","trees_url":"https://api.github.com/repos/lampepfl/dotty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lampepfl/dotty/statuses/{sha}","languages_url":"https://api.github.com/repos/lampepfl/dotty/languages","stargazers_url":"https://api.github.com/repos/lampepfl/dotty/stargazers","contributors_url":"https://api.github.com/repos/lampepfl/dotty/contributors","subscribers_url":"https://api.github.com/repos/lampepfl/dotty/subscribers","subscription_url":"https://api.github.com/repos/lampepfl/dotty/subscription","commits_url":"https://api.github.com/repos/lampepfl/dotty/commits{/sha}","git_commits_url":"https://api.github.com/repos/lampepfl/dotty/git/commits{/sha}","comments_url":"https://api.github.com/repos/lampepfl/dotty/comments{/number}","issue_comment_url":"https://api.github.com/repos/lampepfl/dotty/issues/comments{/number}","contents_url":"https://api.github.com/repos/lampepfl/dotty/contents/{+path}","compare_url":"https://api.github.com/repos/lampepfl/dotty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lampepfl/dotty/merges","archive_url":"https://api.github.com/repos/lampepfl/dotty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lampepfl/dotty/downloads","issues_url":"https://api.github.com/repos/lampepfl/dotty/issues{/number}","pulls_url":"https://api.github.com/repos/lampepfl/dotty/pulls{/number}","milestones_url":"https://api.github.com/repos/lampepfl/dotty/milestones{/number}","notifications_url":"https://api.github.com/repos/lampepfl/dotty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lampepfl/dotty/labels{/name}","releases_url":"https://api.github.com/repos/lampepfl/dotty/releases{/id}","deployments_url":"https://api.github.com/repos/lampepfl/dotty/deployments","created_at":"2012-12-06T12:57:33Z","updated_at":"2018-06-21T11:22:51Z","pushed_at":"2018-06-21T11:26:35Z","git_url":"git://github.com/lampepfl/dotty.git","ssh_url":"git@github.com:lampepfl/dotty.git","clone_url":"https://github.com/lampepfl/dotty.git","svn_url":"https://github.com/lampepfl/dotty","homepage":"http://dotty.epfl.ch","size":408965,"stargazers_count":2731,"watchers_count":2731,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":381,"mirror_url":null,"archived":false,"open_issues_count":411,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":381,"open_issues":411,"watchers":2731,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/4672"},"html":{"href":"https://github.com/lampepfl/dotty/pull/4672"},"issue":{"href":"https://api.github.com/repos/lampepfl/dotty/issues/4672"},"comments":{"href":"https://api.github.com/repos/lampepfl/dotty/issues/4672/comments"},"review_comments":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/4672/comments"},"review_comment":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/4672/commits"},"statuses":{"href":"https://api.github.com/repos/lampepfl/dotty/statuses/86a7a5af88fa1b57e111fc4e360c9b22f65485e1"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"LPTK"}}