{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/83521975","pull_request_review_id":4363858,"id":83521975,"diff_hunk":"@@ -122,6 +132,11 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID,\n         ty = parseTypeImplicitlyUnwrappedOptional(ty.get());\n         continue;\n       }\n+      // Parse legacy array types for migration.","path":"lib/Parse/ParseType.cpp","position":70,"original_position":70,"commit_id":"2a6fc982eb35b6ad4d24dc5c2b0e95ab399ec4f4","original_commit_id":"43aa2ba297fe81b71e01ae6fcfab2e58132fa784","user":{"login":"jrose-apple","id":15097531,"avatar_url":"https://avatars.githubusercontent.com/u/15097531?v=3","gravatar_id":"","url":"https://api.github.com/users/jrose-apple","html_url":"https://github.com/jrose-apple","followers_url":"https://api.github.com/users/jrose-apple/followers","following_url":"https://api.github.com/users/jrose-apple/following{/other_user}","gists_url":"https://api.github.com/users/jrose-apple/gists{/gist_id}","starred_url":"https://api.github.com/users/jrose-apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrose-apple/subscriptions","organizations_url":"https://api.github.com/users/jrose-apple/orgs","repos_url":"https://api.github.com/users/jrose-apple/repos","events_url":"https://api.github.com/users/jrose-apple/events{/privacy}","received_events_url":"https://api.github.com/users/jrose-apple/received_events","type":"User","site_admin":false},"body":"Heh, I'm pretty sure we can stop parsing legacy array types at this point.","created_at":"2016-10-15T01:01:17Z","updated_at":"2016-10-15T01:13:07Z","html_url":"https://github.com/apple/swift/pull/5290#discussion_r83521975","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/5290","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/83521975"},"html":{"href":"https://github.com/apple/swift/pull/5290#discussion_r83521975"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/5290"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/5290","id":89377115,"html_url":"https://github.com/apple/swift/pull/5290","diff_url":"https://github.com/apple/swift/pull/5290.diff","patch_url":"https://github.com/apple/swift/pull/5290.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/5290","number":5290,"state":"open","locked":false,"title":"[RFC] [SR-2843] Reorder precedence of '&' in type parsing","user":{"login":"rintaro","id":142081,"avatar_url":"https://avatars.githubusercontent.com/u/142081?v=3","gravatar_id":"","url":"https://api.github.com/users/rintaro","html_url":"https://github.com/rintaro","followers_url":"https://api.github.com/users/rintaro/followers","following_url":"https://api.github.com/users/rintaro/following{/other_user}","gists_url":"https://api.github.com/users/rintaro/gists{/gist_id}","starred_url":"https://api.github.com/users/rintaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rintaro/subscriptions","organizations_url":"https://api.github.com/users/rintaro/orgs","repos_url":"https://api.github.com/users/rintaro/repos","events_url":"https://api.github.com/users/rintaro/events{/privacy}","received_events_url":"https://api.github.com/users/rintaro/received_events","type":"User","site_admin":false},"body":"Fix [SR-2843](https://bugs.swift.org/browse/SR-2843)\r\n\r\nIn type parsing, `P1 & P2.Type` was parsed as `(metatype (composition P1 & P2))` and accepted.\r\nOn the other hand, in expression position, `(P1 & P2.Type).self` was converted to just `P1` (`P2.Type` was silently discarded).\r\n[SE-0095](https://github.com/apple/swift-evolution/blob/master/proposals/0095-any-as-existential.md) doesn't mention about this. But this is obviously counter-intuitive.\r\n\r\nThis PR fixes this problem, while keeping *source compatibility* to the current behavior.\r\nThat said, expr:`(P1 & P2.Type).self` as type:`P1` is just a bug. IMO, no need to keep this behavior.\r\n\r\n* **[AST] Rename `ProtocolCompositionTypeRepr` to `CompositionTypeRepr`**<br>\r\nTypically, we want to reject `P1 & P2.Type` because `P2.Type` is not a `IdentTypeRepr`, thus can't be a protocol.\r\nTypeResolver has diagnostic logic for this: `\"non protocol type 'T' (aka P.Type) cannot be used in a protocol composition\"`\r\nTo use this facility, we want `ProtocolCompositionTypeRepr` be able to hold any `TypeExpr`s,\r\nnot only `IdentTypeExpr`.\r\nRenamed to `CompositionTypeRepr` because it's not only for protocols anymore.\r\n\r\n* **[Sema] Fix TypeExpr construction for protocol composition**<br>\r\nPreviously `P2.Type` in `(P1 & P2.Type).self` was *silently* discarded because it's not `IdentTypeRepr`.\r\nNow that, `CompositionTypeRepr` can hold any `TypeRepr`s. so let it hold all operands and let TypeResolver to diagnose that.\r\n\r\n* **[Parse] Reorder precedence of `&` operator in type parsing**<br>\r\n*Note: This is source breaking change*\r\nFormerly, precedence of `&` was too strong.\r\nIt was between `type-simple` and `type-identifier`\r\nThis change weaken it between `type-function` and `type-simple`.\r\nSo that, for instance `P1.Type & P2 -> P3 & P4?` is parsed as\r\n  ```\r\n  (function\r\n    (composition\r\n      (metatype (ident id='P1')),\r\n      (ident id='P2'))\r\n    (composition\r\n      (ident id='P3'),\r\n      (optional (ident id='P4'))))\r\n  ```\r\n\r\n  Of course this is illegal. But TypeResolver can properly diagnose it.\r\n  ```\r\n  test.swift:3:20: error: non-protocol type 'P2.Type' cannot be used within a protocol composition\r\n  typealias P = P1 & P2.Type\r\n                     ^\r\n  ```\r\n\r\n  Note that deprecated `protocol<...>` production is still in `type-simple` and accepts only `IdentTypeRepr`s.\r\n  \r\n* **[Parse] Emit specialized diagnostics if seeing non-IdentTypeRepr in inheritance clause**<br>\r\nIn previous change, inheritance clause got to be able to parse any `type-simple` types.\r\nThat means,`struct S: [Int] { }` is accepted. Although TypeChecker can diagnose it `\"inheritance from non-protocol type ...\"`, it should *not* be propagated to `Sema`. Diagnose it in `Parse` and produce `ErrorTypeRepr` for that.\r\nThis improves diagnostics for erroneous inheritance clause. Previously, on `struct S: [Int] {}`:\r\n  ```\r\n  test.swift:1:12: error: expected identifier for type name\r\n  test.swift:1:12: error: expected '{' in struct\r\n  test.swift:1:18: error: statement cannot begin with a closure expression\r\n  test.swift:1:18: note: explicitly discard the result of the closure by assigning to '_'\r\n  test.swift:1:18: error: braced block of statements is an unused closure\r\n  test.swift:1:18: error: expression resolves to an unused function\r\n  ```\r\nNow:\r\n  ```\r\n  test.swift:1:12: error: inheritance from non-named type '[Int]'\r\n  struct S : [Int] {}\r\n             ^~~~~\r\n  ```\r\n\r\n* **[Sema] Swift3 compatibility: Fix ambiguous protocol composition production**<br>\r\nRe-ordering the precedence of `&` was clearly a *source breaking change*.\r\nFor source compatibility, in `isSwiftVersion3()` mode, restore Swift3 behavior.\r\nNamely, convert typerepr `(composition 'P1', (metatype 'P2'))` into `(metatype (composition 'P1',  'P2'))` before typecheck.\r\nAlso, emit a warning with fix-it:\r\n  ```\r\n  test.swift:6:23: warning: protocol composition with postfix '.Type' is ambiguous and will be rejected in future version of Swift\r\n  typealias P = P1 & P2.Type\r\n                        ^\r\n  test.swift:6:15: note: wrap the composition in parentheses to suppress this warning\r\n  typealias P = P1 & P2.Type\r\n                ^~~~~~~\r\n                (      )\r\n  ```\r\n\r\n### Conclusion\r\n\r\n* Parse `P1? & [P2] & P3.Type` as a `CompositionTypeRepr` and reject it.\r\n* Consistent behavior between `typealias P = P1 & P2.Type` and `let P = (P1 & P2.Type).self`\r\n* Restore Swift3 behavior in `-swift-version 3`(default) for source compatibility.<br>\r\n  On `P1 & P2.Type`:\r\n  * `-swift-version 3`: resolved as `(metatype (composition 'P1', 'P2'))`, but warned.\r\n  * `-swift-version 4`: rejected as `(composition 'P1', (metatype 'P2'))`\r\n\r\n### TODO\r\n(probably in later PR)\r\n* `CompositionTypeRepr` is still `isSimple()`. Make it `!isSimple()` so that some diagnostic fixits to wrap it in parentheses.\r\n* `P1 & P2 -> P3 & P4` still behaves differently between type position and expression position.\r\n","created_at":"2016-10-14T12:38:15Z","updated_at":"2016-10-15T01:13:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"519dbf266b691120273d60bbda284e6015670c6b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/5290/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/5290/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/5290/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/2a6fc982eb35b6ad4d24dc5c2b0e95ab399ec4f4","head":{"label":"rintaro:composition-typerepr","ref":"composition-typerepr","sha":"2a6fc982eb35b6ad4d24dc5c2b0e95ab399ec4f4","user":{"login":"rintaro","id":142081,"avatar_url":"https://avatars.githubusercontent.com/u/142081?v=3","gravatar_id":"","url":"https://api.github.com/users/rintaro","html_url":"https://github.com/rintaro","followers_url":"https://api.github.com/users/rintaro/followers","following_url":"https://api.github.com/users/rintaro/following{/other_user}","gists_url":"https://api.github.com/users/rintaro/gists{/gist_id}","starred_url":"https://api.github.com/users/rintaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rintaro/subscriptions","organizations_url":"https://api.github.com/users/rintaro/orgs","repos_url":"https://api.github.com/users/rintaro/repos","events_url":"https://api.github.com/users/rintaro/events{/privacy}","received_events_url":"https://api.github.com/users/rintaro/received_events","type":"User","site_admin":false},"repo":{"id":53176184,"name":"swift","full_name":"rintaro/swift","owner":{"login":"rintaro","id":142081,"avatar_url":"https://avatars.githubusercontent.com/u/142081?v=3","gravatar_id":"","url":"https://api.github.com/users/rintaro","html_url":"https://github.com/rintaro","followers_url":"https://api.github.com/users/rintaro/followers","following_url":"https://api.github.com/users/rintaro/following{/other_user}","gists_url":"https://api.github.com/users/rintaro/gists{/gist_id}","starred_url":"https://api.github.com/users/rintaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rintaro/subscriptions","organizations_url":"https://api.github.com/users/rintaro/orgs","repos_url":"https://api.github.com/users/rintaro/repos","events_url":"https://api.github.com/users/rintaro/events{/privacy}","received_events_url":"https://api.github.com/users/rintaro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rintaro/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/rintaro/swift","forks_url":"https://api.github.com/repos/rintaro/swift/forks","keys_url":"https://api.github.com/repos/rintaro/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rintaro/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rintaro/swift/teams","hooks_url":"https://api.github.com/repos/rintaro/swift/hooks","issue_events_url":"https://api.github.com/repos/rintaro/swift/issues/events{/number}","events_url":"https://api.github.com/repos/rintaro/swift/events","assignees_url":"https://api.github.com/repos/rintaro/swift/assignees{/user}","branches_url":"https://api.github.com/repos/rintaro/swift/branches{/branch}","tags_url":"https://api.github.com/repos/rintaro/swift/tags","blobs_url":"https://api.github.com/repos/rintaro/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rintaro/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rintaro/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/rintaro/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rintaro/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/rintaro/swift/languages","stargazers_url":"https://api.github.com/repos/rintaro/swift/stargazers","contributors_url":"https://api.github.com/repos/rintaro/swift/contributors","subscribers_url":"https://api.github.com/repos/rintaro/swift/subscribers","subscription_url":"https://api.github.com/repos/rintaro/swift/subscription","commits_url":"https://api.github.com/repos/rintaro/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/rintaro/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/rintaro/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/rintaro/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/rintaro/swift/contents/{+path}","compare_url":"https://api.github.com/repos/rintaro/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rintaro/swift/merges","archive_url":"https://api.github.com/repos/rintaro/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rintaro/swift/downloads","issues_url":"https://api.github.com/repos/rintaro/swift/issues{/number}","pulls_url":"https://api.github.com/repos/rintaro/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/rintaro/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/rintaro/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rintaro/swift/labels{/name}","releases_url":"https://api.github.com/repos/rintaro/swift/releases{/id}","deployments_url":"https://api.github.com/repos/rintaro/swift/deployments","created_at":"2016-03-05T01:24:05Z","updated_at":"2016-08-16T11:23:29Z","pushed_at":"2016-10-14T12:07:11Z","git_url":"git://github.com/rintaro/swift.git","ssh_url":"git@github.com:rintaro/swift.git","clone_url":"https://github.com/rintaro/swift.git","svn_url":"https://github.com/rintaro/swift","homepage":"https://swift.org/","size":121334,"stargazers_count":0,"watchers_count":0,"language":null,"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":"empty"}},"base":{"label":"apple:master","ref":"master","sha":"be55ede0e3fadc67a88df07a8aa3a4b4940bc8db","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-10-15T01:03:38Z","pushed_at":"2016-10-15T01:11:45Z","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":189087,"stargazers_count":34509,"watchers_count":34509,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4938,"mirror_url":null,"open_issues_count":107,"forks":4938,"open_issues":107,"watchers":34509,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/5290"},"html":{"href":"https://github.com/apple/swift/pull/5290"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/5290"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/5290/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/5290/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/5290/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/2a6fc982eb35b6ad4d24dc5c2b0e95ab399ec4f4"}}}}
{"actor":{"display_login":"jrose-apple"}}