{"action":"opened","issue":{"url":"https://api.github.com/repos/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/issues/160","repository_url":"https://api.github.com/repos/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring","labels_url":"https://api.github.com/repos/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/issues/160/comments","events_url":"https://api.github.com/repos/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/issues/160/events","html_url":"https://github.com/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/issues/160","id":162019630,"number":160,"title":"Check for type parameter differences between return type and parameter types of source method and target method missing","user":{"login":"khatchad","id":2048831,"avatar_url":"https://avatars.githubusercontent.com/u/2048831?v=3","gravatar_id":"","url":"https://api.github.com/users/khatchad","html_url":"https://github.com/khatchad","followers_url":"https://api.github.com/users/khatchad/followers","following_url":"https://api.github.com/users/khatchad/following{/other_user}","gists_url":"https://api.github.com/users/khatchad/gists{/gist_id}","starred_url":"https://api.github.com/users/khatchad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khatchad/subscriptions","organizations_url":"https://api.github.com/users/khatchad/orgs","repos_url":"https://api.github.com/users/khatchad/repos","events_url":"https://api.github.com/users/khatchad/events{/privacy}","received_events_url":"https://api.github.com/users/khatchad/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"khatchad","id":2048831,"avatar_url":"https://avatars.githubusercontent.com/u/2048831?v=3","gravatar_id":"","url":"https://api.github.com/users/khatchad","html_url":"https://github.com/khatchad","followers_url":"https://api.github.com/users/khatchad/followers","following_url":"https://api.github.com/users/khatchad/following{/other_user}","gists_url":"https://api.github.com/users/khatchad/gists{/gist_id}","starred_url":"https://api.github.com/users/khatchad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khatchad/subscriptions","organizations_url":"https://api.github.com/users/khatchad/orgs","repos_url":"https://api.github.com/users/khatchad/repos","events_url":"https://api.github.com/users/khatchad/events{/privacy}","received_events_url":"https://api.github.com/users/khatchad/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/milestones/3","html_url":"https://github.com/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/milestones/Preconditions","labels_url":"https://api.github.com/repos/khatchad/Migrate-Skeletal-Implementation-to-Interface-Refactoring/milestones/3/labels","id":1335634,"number":3,"title":"Preconditions","description":"","creator":{"login":"khatchad","id":2048831,"avatar_url":"https://avatars.githubusercontent.com/u/2048831?v=3","gravatar_id":"","url":"https://api.github.com/users/khatchad","html_url":"https://github.com/khatchad","followers_url":"https://api.github.com/users/khatchad/followers","following_url":"https://api.github.com/users/khatchad/following{/other_user}","gists_url":"https://api.github.com/users/khatchad/gists{/gist_id}","starred_url":"https://api.github.com/users/khatchad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khatchad/subscriptions","organizations_url":"https://api.github.com/users/khatchad/orgs","repos_url":"https://api.github.com/users/khatchad/repos","events_url":"https://api.github.com/users/khatchad/events{/privacy}","received_events_url":"https://api.github.com/users/khatchad/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":52,"state":"open","created_at":"2015-10-02T21:19:43Z","updated_at":"2016-06-23T20:48:14Z","due_on":"2016-04-29T04:00:00Z","closed_at":null},"comments":0,"created_at":"2016-06-23T20:48:14Z","updated_at":"2016-06-23T20:48:14Z","closed_at":null,"body":"There can be differences between return type and parameter types regarding type parameters. For example, the following test case should fail because C<Integer> doesn't match up with C<T>:\n\n```java\nclass C<E> {\n}\n\ninterface I<T> {\n\tvoid m(C<T> c);\n}\n\nabstract class A implements I<Integer> {\n\t@Override\n\tpublic void m(C<Integer> c) {\n\t\tm(new C<Integer>());\n\t}\n}\n```\n\nHowever, this case should should pass because we can simply substitute the type parameters:\n\n## Before\n```java\nclass C<E> {\n}\n\ninterface I<T> {\n\tvoid m(C<T> c);\n}\n\nabstract class A<E> implements I<E> {\n\t@Override\n\tpublic void m(C<E> c) {\n\t\tm(new C<E>());\n\t}\n}\n```\n\n## After\n```java\npackage p;\n\nclass C<E> {\n}\n\ninterface I<T> {\n\tdefault void m(C<T> c) {\n\t\tm(new C<T>());\n\t}\n}\n\nabstract class A<E> implements I<E> {\n}\n```\n\nHere's a failing case with return types. T gets substituted for Integer inside A, which is why m() works there, but after migration, we've lost the relationship to Integer:\n\n```java\ninterface I<T> {\n\tT m();\n}\n\nabstract class A implements I<Integer> {\n\t@Override\n\tpublic Integer m() {\n\t\treturn 0;\n\t}\n}\n```\n\nIn this case, we also have a mismatch, but it's a little more indirect as a parameterized return type is used:\n\n```java\nclass C<E> {\n}\n\ninterface I<T> {\n\tC<T> m();\n}\n\nabstract class A implements I<Integer> {\n\t@Override\n\tpublic C<Integer> m() {\n\t\treturn new C<Integer>();\n\t}\n}\n```\n\nHowever, if we can substitute the type parameters, we should be able to get it to pass:\n\n## Before\n```java\nclass C<E> {\n}\n\ninterface I<T> {\n\tC<T> m();\n}\n\nabstract class A<S> implements I<S> {\n\t@Override\n\tpublic C<S> m() {\n\t\treturn new C<S>();\n\t}\n}\n```\n\n## After\n```java\nclass C<E> {\n}\n\ninterface I<T> {\n\tdefault C<T> m() {\n\t\treturn new C<T>();\n\t}\n}\n\nabstract class A<S> implements I<S> {\n}\n```"}}
{"actor":{"display_login":"khatchad"}}