{"action":"created","issue":{"url":"https://api.github.com/repos/google/closure-compiler/issues/1922","repository_url":"https://api.github.com/repos/google/closure-compiler","labels_url":"https://api.github.com/repos/google/closure-compiler/issues/1922/labels{/name}","comments_url":"https://api.github.com/repos/google/closure-compiler/issues/1922/comments","events_url":"https://api.github.com/repos/google/closure-compiler/issues/1922/events","html_url":"https://github.com/google/closure-compiler/issues/1922","id":168197517,"number":1922,"title":"calls super method with the window as context when called from arrow function","user":{"login":"davityle","id":5864474,"avatar_url":"https://avatars.githubusercontent.com/u/5864474?v=3","gravatar_id":"","url":"https://api.github.com/users/davityle","html_url":"https://github.com/davityle","followers_url":"https://api.github.com/users/davityle/followers","following_url":"https://api.github.com/users/davityle/following{/other_user}","gists_url":"https://api.github.com/users/davityle/gists{/gist_id}","starred_url":"https://api.github.com/users/davityle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davityle/subscriptions","organizations_url":"https://api.github.com/users/davityle/orgs","repos_url":"https://api.github.com/users/davityle/repos","events_url":"https://api.github.com/users/davityle/events{/privacy}","received_events_url":"https://api.github.com/users/davityle/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-28T21:09:43Z","updated_at":"2016-07-28T21:19:10Z","closed_at":"2016-07-28T21:19:10Z","body":"When a super class method is called inside of an anonymous arrow function closure compiles the code to call the method with the window as context.\r\nMinimum reproducible  case:\r\n\r\n```\r\n// ==ClosureCompiler==\r\n// @output_file_name default.js\r\n// @compilation_level SIMPLE_OPTIMIZATIONS\r\n// @formatting pretty_print\r\n// ==/ClosureCompiler==\r\n\r\nclass A {\r\n\ta() { console.log('a'); }\r\n}\r\n\r\nclass B extends A {\r\n  b() {\r\n\t\treturn () => { super.a(); };\r\n  }\r\n}\r\n\r\nnew B().b()();\r\n```\r\n\r\n[Link](https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250Aclass%2520A%2520%257B%250A%2509a()%2520%257B%2520console.log('a')%253B%2520%257D%250A%257D%250A%250Aclass%2520B%2520extends%2520A%2520%257B%250A%2520%2520b()%2520%257B%250A%2509%2509return%2520()%2520%253D%253E%2520%257B%2520super.a()%253B%2520%257D%253B%250A%2520%2520%257D%250A%257D%250A%250Anew%2520B().b()()%253B%250A%250A)\r\n\r\nIf you compile this you get code that calls the `a` method on the class `A` with the window as the context:\r\n\r\n```\r\nB.prototype.b = function() {\r\n  return function() {\r\n    A.prototype.a.call(this);\r\n  };\r\n};\r\n```\r\na workaround is to place `super.<method>()` with `<SuperClass>.prototype.<method>.call(this)`.\r\nClosure then creates a local variable `a` that it assigns to `this` and uses that as the context.\r\n\r\n```\r\n//workaround\r\n\r\nclass C extends A {\r\n  c() {\r\n\t\treturn () => { A.prototype.a.call(this); };\r\n  }\r\n}\r\n\r\nnew C().c()();\r\n```\r\n\r\nwhich generates:\r\n\r\n```\r\nC.prototype.c = function() {\r\n  var a = this;\r\n  return function() {\r\n    A.prototype.a.call(a);\r\n  };\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/google/closure-compiler/issues/comments/236028495","html_url":"https://github.com/google/closure-compiler/issues/1922#issuecomment-236028495","issue_url":"https://api.github.com/repos/google/closure-compiler/issues/1922","id":236028495,"user":{"login":"davityle","id":5864474,"avatar_url":"https://avatars.githubusercontent.com/u/5864474?v=3","gravatar_id":"","url":"https://api.github.com/users/davityle","html_url":"https://github.com/davityle","followers_url":"https://api.github.com/users/davityle/followers","following_url":"https://api.github.com/users/davityle/following{/other_user}","gists_url":"https://api.github.com/users/davityle/gists{/gist_id}","starred_url":"https://api.github.com/users/davityle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davityle/subscriptions","organizations_url":"https://api.github.com/users/davityle/orgs","repos_url":"https://api.github.com/users/davityle/repos","events_url":"https://api.github.com/users/davityle/events{/privacy}","received_events_url":"https://api.github.com/users/davityle/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T21:19:10Z","updated_at":"2016-07-28T21:19:10Z","body":"It does look like the same issue"}}
{"actor":{"display_login":"davityle"}}