{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/6401","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/6401/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/6401/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/6401/events","html_url":"https://github.com/facebook/flow/issues/6401","id":328334440,"node_id":"MDU6SXNzdWUzMjgzMzQ0NDA=","number":6401,"title":"Flow treats instance properties incorrectly","user":{"login":"deecewan","id":4755785,"node_id":"MDQ6VXNlcjQ3NTU3ODU=","avatar_url":"https://avatars0.githubusercontent.com/u/4755785?v=4","gravatar_id":"","url":"https://api.github.com/users/deecewan","html_url":"https://github.com/deecewan","followers_url":"https://api.github.com/users/deecewan/followers","following_url":"https://api.github.com/users/deecewan/following{/other_user}","gists_url":"https://api.github.com/users/deecewan/gists{/gist_id}","starred_url":"https://api.github.com/users/deecewan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deecewan/subscriptions","organizations_url":"https://api.github.com/users/deecewan/orgs","repos_url":"https://api.github.com/users/deecewan/repos","events_url":"https://api.github.com/users/deecewan/events{/privacy}","received_events_url":"https://api.github.com/users/deecewan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-31T23:48:35Z","updated_at":"2018-06-06T02:47:42Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I found this bug when using React, but have created a minimum example [on https://flow.org/try](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBjGBDAzrsAFQFNcAXAHgHEA+MAb1TDAEsziBbXALjAEEATgOwBPajQDcTMAAcBcMnACS7YYoEBhbDBgAjbBgDWvABRUAlGAC8dAG5wWAEynNpGOADtyAgK4Z1JmycPPxCouKWjMxgAJBkABYsuAB0QVzWrOxcLmDSzAlJyXIKyqrY6lo6+kYZBSnFiirEanCa2noGhsm6LB6OJnXmOQC+0tK95NgeGMRNLW1VnRmBWbwW1nRR0dKjrswNpc3lrZUdRiuca5F5ucy7t2COcADKcBzEBR4A5ibX0WB1VJZFIcbAyAaJeryRplCrtaqGcw3QFpEFgiGFCZkKYzObHBZnRE7VDDIA) that doesn't involve React at all\r\n\r\nEssentially, Flow treats an instance property method differently to a prototype method.  This seems to occur only when generics are involved.\r\n\r\nI'm not sure exactly what's happening, but it's almost like *different* generics by the same name are used inside the instance property-based method.\r\n\r\nThe reproducing code (you can also see in the link above) is:\r\n\r\n```js\r\nclass Test<G> {\r\n  items: Array<G>;\r\n  protoIteratorCallback: (G) => void;\r\n  \r\n  constructor(items: Array<G>) {\r\n   \tthis.items = items;\r\n    this.protoIteratorCallback = this.protoIteratorCallback.bind(this);\r\n  }\r\n  \r\n  instanceIteratorCallback = (item: G) => {}\r\n  \r\n  protoIteratorCallback(item: G) {}\r\n  \r\n  doSomething() {\r\n    this.items.map(this.protoIteratorCallback)\r\n    // next line fails. says `G` is not compatible with `G`\r\n    this.items.map(this.instanceIteratorCallback)\r\n  }\r\n}\r\n```\r\n\r\nI feel like this code shouldn't be too out of the ordinary, and I can't figure out why it won't work if not for a bug.\r\n\r\nEdit: My co-worker has just pointed out that it's broken with static properties as well. You can see the flow/try [here](https://flow.org/try/#0MYGwhgzhAEAqCmEAuAeA4gPmgbwFDWgEsl4BbCALmgEEAnWsAT3QwG5d9pkwlDhoADrQD2A+LSSMAwmBAgARmGABraAF5oACmJkqaAJTqs2AL6duvfqXhIAFsIAmMuYpXaSpPYdMcCD4QDKwtZ2hAB2AOaa3pwEoRAAdDrkCaRgApoIyAlCouKSzgpKyoYA9KXQAGZghCAQsdDxSR6JaRlZSKk29k6yRSplFQKQEIicZiZAA).\r\n\r\n```js\r\nclass Test<G> {\r\n  items: Array<G>;\r\n\r\n  static propertyCallback = (item: G) => {}\r\n  static methodCallback(item: G) {}\r\n\r\n  doSomething() {\r\n    this.items.map(Test.propertyCallback) // fails\r\n    this.items.map(Test.methodCallback) // passes\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/394922902","html_url":"https://github.com/facebook/flow/issues/6401#issuecomment-394922902","issue_url":"https://api.github.com/repos/facebook/flow/issues/6401","id":394922902,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDkyMjkwMg==","user":{"login":"idiostruct","id":8364981,"node_id":"MDQ6VXNlcjgzNjQ5ODE=","avatar_url":"https://avatars3.githubusercontent.com/u/8364981?v=4","gravatar_id":"","url":"https://api.github.com/users/idiostruct","html_url":"https://github.com/idiostruct","followers_url":"https://api.github.com/users/idiostruct/followers","following_url":"https://api.github.com/users/idiostruct/following{/other_user}","gists_url":"https://api.github.com/users/idiostruct/gists{/gist_id}","starred_url":"https://api.github.com/users/idiostruct/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idiostruct/subscriptions","organizations_url":"https://api.github.com/users/idiostruct/orgs","repos_url":"https://api.github.com/users/idiostruct/repos","events_url":"https://api.github.com/users/idiostruct/events{/privacy}","received_events_url":"https://api.github.com/users/idiostruct/received_events","type":"User","site_admin":false},"created_at":"2018-06-06T02:47:42Z","updated_at":"2018-06-06T02:47:42Z","author_association":"NONE","body":"Here are workarounds: [Try Flow](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBjGBDAzrsAFQFNcAXAHgHEA+MAb1TDAEsziBbXALjAEEATgOwBPajQDcTMAAcBcMnACS7YYoEBhbDBgAjbBgDWvABRUAlGAC8dAG5wWAEynNpGOADtyAgK4Z1JmycPPxCouKWjMxgAJBkABYsuAB0QVzWrOxcLmDSzAlJyXIKyqrY6lo6+kYZBSnFiirEanCa2noGhsm6LB6OJnXmOQC+0tK95NgeGMRNLW1VnbxU1nYOjhlpqwx5ucyjrswNpc3lrZUdRoFZy5G70gd7YI5wAMpwHMQFHgDmJnfRMDAYB1VJZFIcbAyAaJeryRplCrtaqGcy7UFpCFQmGFCZkKYzOZnBaXVEPVDDIA), [Try Flow](https://flow.org/try/#0MYGwhgzhAEAqCmEAuAeA4gPmgbwFDWgEsl4BbCALmgEEAnWsAT3QwG5d9pkwlDhoADrQD2A+LSSMAwmBAgARmGABrKmmgBeLADdhhACaaiJUpqzYAvp269+peEgAWw-TLmKVACmJk1AShwrTn1hAGVheydCADsAc08AvAICKIgAOh9yNNIwAU8EZDShUXFJNwUlZQCAemroADMwQhAIThTHQnTM9Jy8gqRsh2dXWQqVGrqBSAhETisLIA).\r\n\r\n```diff\r\n- instanceIteratorCallback = (item: G) => {}\r\n+ instanceIteratorCallback: G => void = item => {}\r\n\r\n- static propertyCallback = (item: G) => {}\r\n+ static propertyCallback: G => void = item => {}\r\n```"}}
{"actor":{"display_login":"idiostruct"}}