{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/51590327","id":51590327,"diff_hunk":"@@ -980,6 +981,69 @@ static bool argumentMismatchIsNearMiss(Type argType, Type paramType) {\n   return false;\n }\n \n+/// Given a parameter type that may contain generic type params and an actual\n+/// argument type, decide whether the param and actual arg have the same shape\n+/// and equal fixed type portions, and return by reference each archetype and\n+/// the matching portion of the actual arg type where that archetype appears.\n+static bool findGenericSubstitutions(Type paramType, Type actualArgType,\n+                                     SmallVector<ArchetypeType *, 4> &archetypes,\n+                                     SmallVector<Type, 4> &substitutions) {\n+  if (auto genericParam = paramType->getAs<GenericTypeParamType>())\n+    paramType = genericParam->getDecl()->getArchetype();\n+  if (auto archetype = paramType->getAs<ArchetypeType>()) {\n+    for (unsigned i = 0, c = archetypes.size(); i < c; i++) {\n+      if (archetypes[i]->isEqual(archetype))\n+        return substitutions[i]->isEqual(actualArgType);\n+    }\n+    archetypes.push_back(archetype);\n+    substitutions.push_back(actualArgType);\n+    return true;\n+  }\n+  \n+  if (paramType->isEqual(actualArgType))\n+    return true;\n+  if (paramType->getKind() != actualArgType->getKind())\n+    return false;\n+  \n+  // A little walker that just collects direct child types. Can't easily have a\n+  // walker walk recursively because we need to coordinate two of them.\n+  struct ChildWalker : public TypeWalker {\n+  public:\n+    SmallVector<Type, 4> children;\n+    bool top = true;\n+    \n+    virtual Action walkToTypePre(Type ty) {\n+      if (top) {\n+        top = false;\n+        return Action::Continue;\n+      }\n+      children.push_back(ty);\n+      return Action::SkipChildren;\n+    }\n+  } paramWalker, actualArgWalker;\n+  \n+  paramType.walk(paramWalker);\n+  actualArgType.walk(actualArgWalker);\n+  \n+  unsigned childCount = paramWalker.children.size();\n+  if (childCount == 0 || actualArgWalker.children.size() != childCount)\n+    return false;\n+  for(unsigned i = 0; i < childCount; i++) {\n+    if (!findGenericSubstitutions(paramWalker.children[i], actualArgWalker.children[i],\n+                                  archetypes, substitutions))\n+      return false;\n+  }\n+  \n+  // Unfortunate special case, FunctionType also needs to compare ExtInfo. This is the only","path":"lib/Sema/CSDiag.cpp","position":65,"original_position":65,"commit_id":"0d2c1954efcd3596e282c22978c7c896f83ac89c","original_commit_id":"0d2c1954efcd3596e282c22978c7c896f83ac89c","user":{"login":"gregomni","id":15795449,"avatar_url":"https://avatars.githubusercontent.com/u/15795449?v=3","gravatar_id":"","url":"https://api.github.com/users/gregomni","html_url":"https://github.com/gregomni","followers_url":"https://api.github.com/users/gregomni/followers","following_url":"https://api.github.com/users/gregomni/following{/other_user}","gists_url":"https://api.github.com/users/gregomni/gists{/gist_id}","starred_url":"https://api.github.com/users/gregomni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregomni/subscriptions","organizations_url":"https://api.github.com/users/gregomni/orgs","repos_url":"https://api.github.com/users/gregomni/repos","events_url":"https://api.github.com/users/gregomni/events{/privacy}","received_events_url":"https://api.github.com/users/gregomni/received_events","type":"User","site_admin":false},"body":"Without this check, test/attr/attr_autoclosure.swift:53 regresses and emits the old worse diagnoses from before https://github.com/apple/swift/pull/1042:\r\n```\r\nfunc overloadedEach<O: P1>(source: O, _ closure: () -> ()) {\r\n}\r\n\r\nfunc overloadedEach<P: P2>(source: P, _ closure: () -> ()) {\r\n}\r\n\r\nstruct S : P2 {\r\n  typealias Element = Int\r\n  func each(@autoclosure closure: () -> ()) {\r\n    overloadedEach(self, closure) // expected-error {{invalid conversion from non-escaping function of type '@autoclosure () -> ()' to potentially escaping function type '() -> ()'}}\r\n  }\r\n}\r\n```","created_at":"2016-02-02T16:13:55Z","updated_at":"2016-02-02T16:13:55Z","html_url":"https://github.com/apple/swift/pull/1160#discussion_r51590327","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/1160","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/51590327"},"html":{"href":"https://github.com/apple/swift/pull/1160#discussion_r51590327"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/1160"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/1160","id":57935067,"html_url":"https://github.com/apple/swift/pull/1160","diff_url":"https://github.com/apple/swift/pull/1160.diff","patch_url":"https://github.com/apple/swift/pull/1160.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/1160","number":1160,"state":"open","locked":false,"title":"[Sema] Extend callee diagnosis to complex args including generics, e.g. (Void) -> T","user":{"login":"gregomni","id":15795449,"avatar_url":"https://avatars.githubusercontent.com/u/15795449?v=3","gravatar_id":"","url":"https://api.github.com/users/gregomni","html_url":"https://github.com/gregomni","followers_url":"https://api.github.com/users/gregomni/followers","following_url":"https://api.github.com/users/gregomni/following{/other_user}","gists_url":"https://api.github.com/users/gregomni/gists{/gist_id}","starred_url":"https://api.github.com/users/gregomni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregomni/subscriptions","organizations_url":"https://api.github.com/users/gregomni/orgs","repos_url":"https://api.github.com/users/gregomni/repos","events_url":"https://api.github.com/users/gregomni/events{/privacy}","received_events_url":"https://api.github.com/users/gregomni/received_events","type":"User","site_admin":false},"body":"Correctly determine callee closeness for func/ops that include generics as part of more complicated parameters, i.e. tuple or closure args containing generics as elements or args/results. Still only handling single archetypes.\r\n\r\nTests added, all tests pass. The one changed diagnostic in misc_diagnostics is sort of a regression, although both messages are of about equal quality, I think. This commit lets evaluateCloseness find a second partial match for ~= there, but the two partial matches involve different parameter archetypes, so filtering makes the callee argument failure info invalid as a result, thus going back to the generic message as opposed to a specific argument failure message. (In short, the older specific error was actually incorrectly over-specific.)","created_at":"2016-02-02T03:12:16Z","updated_at":"2016-02-02T16:13:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a3c94ee4846b8025844171a11a27da2e46424b6b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/1160/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/1160/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/1160/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/0d2c1954efcd3596e282c22978c7c896f83ac89c","head":{"label":"gregomni:generic-func-args","ref":"generic-func-args","sha":"0d2c1954efcd3596e282c22978c7c896f83ac89c","user":{"login":"gregomni","id":15795449,"avatar_url":"https://avatars.githubusercontent.com/u/15795449?v=3","gravatar_id":"","url":"https://api.github.com/users/gregomni","html_url":"https://github.com/gregomni","followers_url":"https://api.github.com/users/gregomni/followers","following_url":"https://api.github.com/users/gregomni/following{/other_user}","gists_url":"https://api.github.com/users/gregomni/gists{/gist_id}","starred_url":"https://api.github.com/users/gregomni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregomni/subscriptions","organizations_url":"https://api.github.com/users/gregomni/orgs","repos_url":"https://api.github.com/users/gregomni/repos","events_url":"https://api.github.com/users/gregomni/events{/privacy}","received_events_url":"https://api.github.com/users/gregomni/received_events","type":"User","site_admin":false},"repo":{"id":47734038,"name":"swift","full_name":"gregomni/swift","owner":{"login":"gregomni","id":15795449,"avatar_url":"https://avatars.githubusercontent.com/u/15795449?v=3","gravatar_id":"","url":"https://api.github.com/users/gregomni","html_url":"https://github.com/gregomni","followers_url":"https://api.github.com/users/gregomni/followers","following_url":"https://api.github.com/users/gregomni/following{/other_user}","gists_url":"https://api.github.com/users/gregomni/gists{/gist_id}","starred_url":"https://api.github.com/users/gregomni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregomni/subscriptions","organizations_url":"https://api.github.com/users/gregomni/orgs","repos_url":"https://api.github.com/users/gregomni/repos","events_url":"https://api.github.com/users/gregomni/events{/privacy}","received_events_url":"https://api.github.com/users/gregomni/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gregomni/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/gregomni/swift","forks_url":"https://api.github.com/repos/gregomni/swift/forks","keys_url":"https://api.github.com/repos/gregomni/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gregomni/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gregomni/swift/teams","hooks_url":"https://api.github.com/repos/gregomni/swift/hooks","issue_events_url":"https://api.github.com/repos/gregomni/swift/issues/events{/number}","events_url":"https://api.github.com/repos/gregomni/swift/events","assignees_url":"https://api.github.com/repos/gregomni/swift/assignees{/user}","branches_url":"https://api.github.com/repos/gregomni/swift/branches{/branch}","tags_url":"https://api.github.com/repos/gregomni/swift/tags","blobs_url":"https://api.github.com/repos/gregomni/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gregomni/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gregomni/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/gregomni/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gregomni/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/gregomni/swift/languages","stargazers_url":"https://api.github.com/repos/gregomni/swift/stargazers","contributors_url":"https://api.github.com/repos/gregomni/swift/contributors","subscribers_url":"https://api.github.com/repos/gregomni/swift/subscribers","subscription_url":"https://api.github.com/repos/gregomni/swift/subscription","commits_url":"https://api.github.com/repos/gregomni/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/gregomni/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/gregomni/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/gregomni/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/gregomni/swift/contents/{+path}","compare_url":"https://api.github.com/repos/gregomni/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gregomni/swift/merges","archive_url":"https://api.github.com/repos/gregomni/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gregomni/swift/downloads","issues_url":"https://api.github.com/repos/gregomni/swift/issues{/number}","pulls_url":"https://api.github.com/repos/gregomni/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/gregomni/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/gregomni/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gregomni/swift/labels{/name}","releases_url":"https://api.github.com/repos/gregomni/swift/releases{/id}","deployments_url":"https://api.github.com/repos/gregomni/swift/deployments","created_at":"2015-12-10T02:58:32Z","updated_at":"2016-01-13T15:52:33Z","pushed_at":"2016-02-02T03:12:15Z","git_url":"git://github.com/gregomni/swift.git","ssh_url":"git@github.com:gregomni/swift.git","clone_url":"https://github.com/gregomni/swift.git","svn_url":"https://github.com/gregomni/swift","homepage":"","size":75416,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"f6866b4ae702b5c9cd37bf9a3bf9c7c4faed45f3","user":{"login":"apple","id":10639145,"avatar_url":"https://avatars.githubusercontent.com/u/10639145?v=3","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,"name":"swift","full_name":"apple/swift","owner":{"login":"apple","id":10639145,"avatar_url":"https://avatars.githubusercontent.com/u/10639145?v=3","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},"private":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":"2016-02-02T15:51:37Z","pushed_at":"2016-02-02T11:34:47Z","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":102908,"stargazers_count":26351,"watchers_count":26351,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3351,"mirror_url":null,"open_issues_count":53,"forks":3351,"open_issues":53,"watchers":26351,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/1160"},"html":{"href":"https://github.com/apple/swift/pull/1160"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/1160"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/1160/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/1160/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/1160/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/0d2c1954efcd3596e282c22978c7c896f83ac89c"}}}}