{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/313063037","pull_request_review_id":273868283,"id":313063037,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMxMzA2MzAzNw==","diff_hunk":"@@ -6080,10 +6090,33 @@ ConstraintSystem::simplifyApplicableFnConstraint(\n   ConstraintLocatorBuilder outerLocator =\n     getConstraintLocator(anchor, parts, locator.getSummaryFlags());\n \n-  // Before stripping optional types, save original type for handling\n-  // @dynamicCallable applications. This supports the fringe case where\n-  // `Optional` itself is extended with @dynamicCallable functionality.\n-  auto origType2 = desugar2;\n+  // Handle applications of types with `callAsFunction` methods.\n+  // Do this before stripping optional types below, when `shouldAttemptFixes()`\n+  // is true.\n+  auto hasCallAsFunctionMethods =\n+      desugar2->mayHaveMembers() &&\n+      llvm::any_of(lookupMember(desugar2, DeclName(ctx.Id_callAsFunction)),\n+                   [](LookupResultEntry entry) {\n+                     return isa<FuncDecl>(entry.getValueDecl());\n+                   });\n+  if (hasCallAsFunctionMethods) {\n+    auto memberLoc = getConstraintLocator(\n+        outerLocator.withPathElement(ConstraintLocator::Member));\n+    // Add a `callAsFunction` member constraint, binding the member type to a\n+    // type variable.\n+    auto memberTy = createTypeVariable(memberLoc, TVO_CanBindToLValue |\n+                                                  TVO_CanBindToNoEscape |\n+                                                  TVO_CanBindToInOut);\n+    addValueMemberConstraint(origType2, DeclName(ctx.Id_callAsFunction),\n+                             memberTy, DC, FunctionRefKind::SingleApply,\n+                             /*outerAlternatives*/ {}, locator);","path":"lib/Sema/CSSimplify.cpp","position":51,"original_position":51,"commit_id":"4cb7ebf8a0345a0e7f9041a0be41990e68c7cd14","original_commit_id":"4cb7ebf8a0345a0e7f9041a0be41990e68c7cd14","user":{"login":"xedin","id":21240,"node_id":"MDQ6VXNlcjIxMjQw","avatar_url":"https://avatars1.githubusercontent.com/u/21240?v=4","gravatar_id":"","url":"https://api.github.com/users/xedin","html_url":"https://github.com/xedin","followers_url":"https://api.github.com/users/xedin/followers","following_url":"https://api.github.com/users/xedin/following{/other_user}","gists_url":"https://api.github.com/users/xedin/gists{/gist_id}","starred_url":"https://api.github.com/users/xedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xedin/subscriptions","organizations_url":"https://api.github.com/users/xedin/orgs","repos_url":"https://api.github.com/users/xedin/repos","events_url":"https://api.github.com/users/xedin/events{/privacy}","received_events_url":"https://api.github.com/users/xedin/received_events","type":"User","site_admin":false},"body":"Might make sense to add a `TODO` in case we'd ever want to get a static variant of `callAsFunction`...","created_at":"2019-08-12T18:23:19Z","updated_at":"2019-08-12T18:23:19Z","html_url":"https://github.com/apple/swift/pull/24299#discussion_r313063037","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/24299","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/313063037"},"html":{"href":"https://github.com/apple/swift/pull/24299#discussion_r313063037"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/24299"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/24299","id":273722036,"node_id":"MDExOlB1bGxSZXF1ZXN0MjczNzIyMDM2","html_url":"https://github.com/apple/swift/pull/24299","diff_url":"https://github.com/apple/swift/pull/24299.diff","patch_url":"https://github.com/apple/swift/pull/24299.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/24299","number":24299,"state":"open","locked":false,"title":"[SE-0253] Introduce callables.","user":{"login":"dan-zheng","id":5590046,"node_id":"MDQ6VXNlcjU1OTAwNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/5590046?v=4","gravatar_id":"","url":"https://api.github.com/users/dan-zheng","html_url":"https://github.com/dan-zheng","followers_url":"https://api.github.com/users/dan-zheng/followers","following_url":"https://api.github.com/users/dan-zheng/following{/other_user}","gists_url":"https://api.github.com/users/dan-zheng/gists{/gist_id}","starred_url":"https://api.github.com/users/dan-zheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dan-zheng/subscriptions","organizations_url":"https://api.github.com/users/dan-zheng/orgs","repos_url":"https://api.github.com/users/dan-zheng/repos","events_url":"https://api.github.com/users/dan-zheng/events{/privacy}","received_events_url":"https://api.github.com/users/dan-zheng/received_events","type":"User","site_admin":false},"body":"Implementation for [SE-0253](https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md).\r\n\r\nIntroduce callables: values that can be called like functions.\r\nMethods named `func callFunction` act as call-syntax delegate methods.\r\n\r\n```swift\r\nstruct Adder {\r\n  var base: Int\r\n  func callAsFunction(_ x: Int) -> Int {\r\n    return x + base\r\n  }\r\n}\r\nvar adder = Adder(base: 3)\r\nadder(10) // desugars to `adder.callAsFunction(10)`\r\n```","created_at":"2019-04-26T00:11:23Z","updated_at":"2019-08-12T18:23:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15116e46e5247926c3d37b0498754f57b5045ea2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":303289391,"node_id":"MDU6TGFiZWwzMDMyODkzOTE=","url":"https://api.github.com/repos/apple/swift/labels/swift-evolution-approved","name":"swift-evolution-approved","color":"006b75","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/24299/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/24299/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/24299/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/4cb7ebf8a0345a0e7f9041a0be41990e68c7cd14","head":{"label":"dan-zheng:callables","ref":"callables","sha":"4cb7ebf8a0345a0e7f9041a0be41990e68c7cd14","user":{"login":"dan-zheng","id":5590046,"node_id":"MDQ6VXNlcjU1OTAwNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/5590046?v=4","gravatar_id":"","url":"https://api.github.com/users/dan-zheng","html_url":"https://github.com/dan-zheng","followers_url":"https://api.github.com/users/dan-zheng/followers","following_url":"https://api.github.com/users/dan-zheng/following{/other_user}","gists_url":"https://api.github.com/users/dan-zheng/gists{/gist_id}","starred_url":"https://api.github.com/users/dan-zheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dan-zheng/subscriptions","organizations_url":"https://api.github.com/users/dan-zheng/orgs","repos_url":"https://api.github.com/users/dan-zheng/repos","events_url":"https://api.github.com/users/dan-zheng/events{/privacy}","received_events_url":"https://api.github.com/users/dan-zheng/received_events","type":"User","site_admin":false},"repo":{"id":135949956,"node_id":"MDEwOlJlcG9zaXRvcnkxMzU5NDk5NTY=","name":"swift","full_name":"dan-zheng/swift","private":false,"owner":{"login":"dan-zheng","id":5590046,"node_id":"MDQ6VXNlcjU1OTAwNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/5590046?v=4","gravatar_id":"","url":"https://api.github.com/users/dan-zheng","html_url":"https://github.com/dan-zheng","followers_url":"https://api.github.com/users/dan-zheng/followers","following_url":"https://api.github.com/users/dan-zheng/following{/other_user}","gists_url":"https://api.github.com/users/dan-zheng/gists{/gist_id}","starred_url":"https://api.github.com/users/dan-zheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dan-zheng/subscriptions","organizations_url":"https://api.github.com/users/dan-zheng/orgs","repos_url":"https://api.github.com/users/dan-zheng/repos","events_url":"https://api.github.com/users/dan-zheng/events{/privacy}","received_events_url":"https://api.github.com/users/dan-zheng/received_events","type":"User","site_admin":false},"html_url":"https://github.com/dan-zheng/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/dan-zheng/swift","forks_url":"https://api.github.com/repos/dan-zheng/swift/forks","keys_url":"https://api.github.com/repos/dan-zheng/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dan-zheng/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dan-zheng/swift/teams","hooks_url":"https://api.github.com/repos/dan-zheng/swift/hooks","issue_events_url":"https://api.github.com/repos/dan-zheng/swift/issues/events{/number}","events_url":"https://api.github.com/repos/dan-zheng/swift/events","assignees_url":"https://api.github.com/repos/dan-zheng/swift/assignees{/user}","branches_url":"https://api.github.com/repos/dan-zheng/swift/branches{/branch}","tags_url":"https://api.github.com/repos/dan-zheng/swift/tags","blobs_url":"https://api.github.com/repos/dan-zheng/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dan-zheng/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dan-zheng/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/dan-zheng/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dan-zheng/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/dan-zheng/swift/languages","stargazers_url":"https://api.github.com/repos/dan-zheng/swift/stargazers","contributors_url":"https://api.github.com/repos/dan-zheng/swift/contributors","subscribers_url":"https://api.github.com/repos/dan-zheng/swift/subscribers","subscription_url":"https://api.github.com/repos/dan-zheng/swift/subscription","commits_url":"https://api.github.com/repos/dan-zheng/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/dan-zheng/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/dan-zheng/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/dan-zheng/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/dan-zheng/swift/contents/{+path}","compare_url":"https://api.github.com/repos/dan-zheng/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dan-zheng/swift/merges","archive_url":"https://api.github.com/repos/dan-zheng/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dan-zheng/swift/downloads","issues_url":"https://api.github.com/repos/dan-zheng/swift/issues{/number}","pulls_url":"https://api.github.com/repos/dan-zheng/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/dan-zheng/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/dan-zheng/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dan-zheng/swift/labels{/name}","releases_url":"https://api.github.com/repos/dan-zheng/swift/releases{/id}","deployments_url":"https://api.github.com/repos/dan-zheng/swift/deployments","created_at":"2018-06-03T23:56:41Z","updated_at":"2019-02-26T09:20:41Z","pushed_at":"2019-08-11T19:26:40Z","git_url":"git://github.com/dan-zheng/swift.git","ssh_url":"git@github.com:dan-zheng/swift.git","clone_url":"https://github.com/dan-zheng/swift.git","svn_url":"https://github.com/dan-zheng/swift","homepage":"https://swift.org/","size":440741,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"529d784329b56ab620bc36bf8465d54b1b4e17c2","user":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":44838949,"node_id":"MDEwOlJlcG9zaXRvcnk0NDgzODk0OQ==","name":"swift","full_name":"apple/swift","private":false,"owner":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apple/swift","description":"The Swift Programming Language","fork":false,"url":"https://api.github.com/repos/apple/swift","forks_url":"https://api.github.com/repos/apple/swift/forks","keys_url":"https://api.github.com/repos/apple/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift/teams","hooks_url":"https://api.github.com/repos/apple/swift/hooks","issue_events_url":"https://api.github.com/repos/apple/swift/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift/events","assignees_url":"https://api.github.com/repos/apple/swift/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift/tags","blobs_url":"https://api.github.com/repos/apple/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift/languages","stargazers_url":"https://api.github.com/repos/apple/swift/stargazers","contributors_url":"https://api.github.com/repos/apple/swift/contributors","subscribers_url":"https://api.github.com/repos/apple/swift/subscribers","subscription_url":"https://api.github.com/repos/apple/swift/subscription","commits_url":"https://api.github.com/repos/apple/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift/merges","archive_url":"https://api.github.com/repos/apple/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift/downloads","issues_url":"https://api.github.com/repos/apple/swift/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift/deployments","created_at":"2015-10-23T21:15:07Z","updated_at":"2019-08-12T16:13:43Z","pushed_at":"2019-08-12T17:54:54Z","git_url":"git://github.com/apple/swift.git","ssh_url":"git@github.com:apple/swift.git","clone_url":"https://github.com/apple/swift.git","svn_url":"https://github.com/apple/swift","homepage":"https://swift.org","size":454888,"stargazers_count":48778,"watchers_count":48778,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7830,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":569,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":7830,"open_issues":569,"watchers":48778,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/24299"},"html":{"href":"https://github.com/apple/swift/pull/24299"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/24299"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/24299/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/24299/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/24299/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/4cb7ebf8a0345a0e7f9041a0be41990e68c7cd14"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"xedin"}}