GitHub PullRequestReviewCommentEvent at 2014-09-17 19:39:57
Repository: TypeScript
Actor: mhegazy
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/17688238","id":17688238,"diff_hunk":"@@ -0,0 +1,148 @@\n+==== tests/cases/compiler/protectedMembers.ts (14 errors) ====\r\n+    // Class with protected members\r\n+    class C1 {\r\n+        protected x: number;\r\n+        protected static sx: number;\r\n+        protected f() {\r\n+            return this.x;\r\n+        }\r\n+        protected static sf() {\r\n+            return this.sx;\r\n+        }\r\n+    }\r\n+    \r\n+    // Derived class accessing protected members\r\n+    class C2 extends C1 {\r\n+        protected f() {\r\n+            return super.f() + this.x;\r\n+        }\r\n+        protected static sf() {\r\n+            return super.sf() + this.sx;\r\n+        }\r\n+    }\r\n+    \r\n+    // Derived class making protected members public\r\n+    class C3 extends C2 {\r\n+        x: number;\r\n+        static sx: number;\r\n+        f() {\r\n+            return super.f();\r\n+        }\r\n+        static sf() {\r\n+            return super.sf();\r\n+        }\r\n+    }\r\n+    \r\n+    var c1: C1;\r\n+    var c2: C2;\r\n+    var c3: C3;\r\n+    \r\n+    // All of these should be errors\r\n+    c1.x;\r\n+    ~~~~\r\n+!!! Property 'C1.x' is inaccessible.\r\n+    c1.f();\r\n+    ~~~~\r\n+!!! Property 'C1.f' is inaccessible.\r\n+    C1.sx;\r\n+    ~~~~~\r\n+!!! Property 'C1.sx' is inaccessible.\r\n+    C1.sf();\r\n+    ~~~~~\r\n+!!! Property 'C1.sf' is inaccessible.\r\n+    \r\n+    // All of these should be errors\r\n+    c2.x;\r\n+    ~~~~\r\n+!!! Property 'C1.x' is inaccessible.\r\n+    c2.f();\r\n+    ~~~~\r\n+!!! Property 'C2.f' is inaccessible.\r\n+    C2.sx;\r\n+    ~~~~~\r\n+!!! Property 'C1.sx' is inaccessible.\r\n+    C2.sf();\r\n+    ~~~~~\r\n+!!! Property 'C2.sf' is inaccessible.\r\n+    \r\n+    // All of these should be ok\r\n+    c3.x;\r\n+    c3.f();\r\n+    C3.sx;\r\n+    C3.sf();\r\n+    \r\n+    class A {\r\n+        protected x;\r\n+    }\r\n+    \r\n+    class B extends A {\r\n+        y;\r\n+    }\r\n+    \r\n+    class C extends A {\r\n+        z;\r\n+        static foo(a: A, b: B, c: C, d: D, e: E) {\r\n+            a.x = 1;  // Error, access must be through C or type derived from C\r\n+            ~~~\r\n+!!! Property 'A.x' is inaccessible.\r\n+            b.x = 1;  // Error, access must be through C or type derived from C\r\n+            ~~~\r\n+!!! Property 'A.x' is inaccessible.\r\n+            c.x = 1;\r\n+            d.x = 1;\r\n+            e.x = 1;\r\n+        }\r\n+    }\r\n+    \r\n+    class D extends C {\r\n+        d;\r\n+    }\r\n+    \r\n+    interface E extends C {\r","path":"tests/baselines/reference/protectedMembers.errors.txt","position":101,"original_position":101,"commit_id":"ce6b6234ef823b7d6c9ff00c913d663779b3165f","original_commit_id":"ce6b6234ef823b7d6c9ff00c913d663779b3165f","user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=2","gravatar_id":"17e2da9785d45119a4c4cfed99e40d9c","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"body":"I do not see any .d.ts emit test cases either, we probably need a few tests for:\r\n* just emitting the protected property\r\n* protected methods\r\n* defined in constructors\r\n* protected property with private type, ensuring the error is still reported.","created_at":"2014-09-17T19:39:57Z","updated_at":"2014-09-17T19:39:57Z","html_url":"https://github.com/Microsoft/TypeScript/pull/688#discussion_r17688238","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/688","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/17688238"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/688#discussion_r17688238"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/688"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/688","id":21384096,"html_url":"https://github.com/Microsoft/TypeScript/pull/688","diff_url":"https://github.com/Microsoft/TypeScript/pull/688.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/688.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/688","number":688,"state":"open","locked":false,"title":"Support for protected members in classes","user":{"login":"ahejlsberg","id":4226954,"avatar_url":"https://avatars.githubusercontent.com/u/4226954?v=2","gravatar_id":"822469a87883aae8493f4579c2641bc6","url":"https://api.github.com/users/ahejlsberg","html_url":"https://github.com/ahejlsberg","followers_url":"https://api.github.com/users/ahejlsberg/followers","following_url":"https://api.github.com/users/ahejlsberg/following{/other_user}","gists_url":"https://api.github.com/users/ahejlsberg/gists{/gist_id}","starred_url":"https://api.github.com/users/ahejlsberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahejlsberg/subscriptions","organizations_url":"https://api.github.com/users/ahejlsberg/orgs","repos_url":"https://api.github.com/users/ahejlsberg/repos","events_url":"https://api.github.com/users/ahejlsberg/events{/privacy}","received_events_url":"https://api.github.com/users/ahejlsberg/received_events","type":"User","site_admin":false},"body":"This change adds support for protected members in classes as proposed in #1. Also, this change introduces better error messages for assignability and subtype checks involving private and optional properties.\r\n\r\nProtected members are modeled after C# and Java. Protected members can be accessed only within the declaring class and subclasses of the declaring class. Furthermore, access to a protected instance member is required to take place *through* an instance of the enclosing class type or a class type constructed from it (this prevents \"sibling\" class access).\r\n\r\nProtected members can be made public in derived classes. Similar to private members, constructors and signature members cannot be protected.\r\n\r\nI will follow up with a more formal specification of the rules but wanted to put up the code for folks to experiment with.","created_at":"2014-09-17T18:00:00Z","updated_at":"2014-09-17T19:39:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/688/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/688/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/688/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/ce6b6234ef823b7d6c9ff00c913d663779b3165f","head":{"label":"Microsoft:protectedMembers","ref":"protectedMembers","sha":"ce6b6234ef823b7d6c9ff00c913d663779b3165f","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=2","gravatar_id":"7d3b0469b6f73dd41ed7de7931e44510","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=2","gravatar_id":"7d3b0469b6f73dd41ed7de7931e44510","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/{number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2014-09-17T18:04:09Z","pushed_at":"2014-09-17T19:33:57Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":89124,"stargazers_count":2121,"watchers_count":2121,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":202,"forks":156,"open_issues":202,"watchers":2121,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"aa02ab588675616d72d9800552650f5bbb686da6","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=2","gravatar_id":"7d3b0469b6f73dd41ed7de7931e44510","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=2","gravatar_id":"7d3b0469b6f73dd41ed7de7931e44510","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/{number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2014-09-17T18:04:09Z","pushed_at":"2014-09-17T19:33:57Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":89124,"stargazers_count":2121,"watchers_count":2121,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":202,"forks":156,"open_issues":202,"watchers":2121,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/688"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/688"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/688"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/688/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/688/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/688/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/ce6b6234ef823b7d6c9ff00c913d663779b3165f"}}}}