{"action":"created","issue":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/691","labels_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/691/labels{/name}","comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/691/comments","events_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/691/events","html_url":"https://github.com/SpongePowered/SpongeAPI/pull/691","id":77879476,"number":691,"title":"Enforce setting the correct type in generated event methods","user":{"login":"Aaron1011","id":1408859,"avatar_url":"https://avatars.githubusercontent.com/u/1408859?v=3","gravatar_id":"","url":"https://api.github.com/users/Aaron1011","html_url":"https://github.com/Aaron1011","followers_url":"https://api.github.com/users/Aaron1011/followers","following_url":"https://api.github.com/users/Aaron1011/following{/other_user}","gists_url":"https://api.github.com/users/Aaron1011/gists{/gist_id}","starred_url":"https://api.github.com/users/Aaron1011/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aaron1011/subscriptions","organizations_url":"https://api.github.com/users/Aaron1011/orgs","repos_url":"https://api.github.com/users/Aaron1011/repos","events_url":"https://api.github.com/users/Aaron1011/events{/privacy}","received_events_url":"https://api.github.com/users/Aaron1011/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-19T01:16:29Z","updated_at":"2015-05-19T06:13:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/pulls/691","html_url":"https://github.com/SpongePowered/SpongeAPI/pull/691","diff_url":"https://github.com/SpongePowered/SpongeAPI/pull/691.diff","patch_url":"https://github.com/SpongePowered/SpongeAPI/pull/691.patch"},"body":"Many event interfaces in the API provide getters which are overridden in subinterfaces, using covariant types. An example of this is `TileEntityChangeEvent`, which has a method `getNewData`, returning a `DataManiuplator`. In `SignChangeEvent`, this is overridden to return `SignData`.\r\n\r\nIf corresponding setters are provided in both interfaces, then there's currently no mechanism to verify that a setter is being called with the most specific type. For example:\r\n\r\nAgain, look at `TileEntityChangeEvent`, which, in addition to the methods mentioned above, has a `setNewData` method, which takes a `DataManipulator` as a parameter. Should a plugin call this method with some generic `DataManipulator`, it may turn out that the parameter type used is incompatible with the overriden getter method, should the event turn out to be an instance of the subinterface.\r\n\r\nIn the above example, if a plugin were to call `setNewData(DataManipulator manipulator)` on an event which is actually a `SignChangeEvent`, no exception would be thrown. However, the next time the overriden getter - `getNewData` in `SignChangeEvent` - was called, a cast exception would be thrown, due to the set `DataManipulator` not being a `SignData`.\r\n\r\nThis PR ensures that the generated setter methods check the type of the passed in parameter, and determine whether it's compatible with the actual instance of the event."},"comment":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/comments/103352668","html_url":"https://github.com/SpongePowered/SpongeAPI/pull/691#issuecomment-103352668","issue_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/691","id":103352668,"user":{"login":"AlphaModder","id":2100733,"avatar_url":"https://avatars.githubusercontent.com/u/2100733?v=3","gravatar_id":"","url":"https://api.github.com/users/AlphaModder","html_url":"https://github.com/AlphaModder","followers_url":"https://api.github.com/users/AlphaModder/followers","following_url":"https://api.github.com/users/AlphaModder/following{/other_user}","gists_url":"https://api.github.com/users/AlphaModder/gists{/gist_id}","starred_url":"https://api.github.com/users/AlphaModder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlphaModder/subscriptions","organizations_url":"https://api.github.com/users/AlphaModder/orgs","repos_url":"https://api.github.com/users/AlphaModder/repos","events_url":"https://api.github.com/users/AlphaModder/events{/privacy}","received_events_url":"https://api.github.com/users/AlphaModder/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T06:13:24Z","updated_at":"2015-05-19T06:13:24Z","body":"@ST-DDT Ah I see, a complement rather than an alternative. Would there be any issues with handlers though?"}}