Description of the problem or enhancement request:
When instanced called is a subclass of mocking instance, and called method has a generic signature, mockit.internal.expectations.invocation.ExpectedInvocation#isMatchingGenericMethod will only match signature (return type and params type).
Check the following:
[x] If a defect or unexpected result, JMockit project members should be able to reproduce it.
For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which
can be executed without changes and reproduces the failure.
[x] If an enhancement or new feature request, it should be justified by an example test
demonstrating the validity and usefulness of the desired enhancement or new feature.
[x] The issue does not fall outside the scope of the project (for example, attempting to use
JMockit APIs from Groovy or Scala code, or with an Android runtime).
[x] The JDK where the problem occurs is a final release, not a development build.
Snippet to reproduce it:
public class GenericTest {
public static class ClassWithGenericMethod {
public List<String> m() {
return null;
}
public List<Integer> m2() {
return null;
}
}
@Test
public void test(@Capturing ClassWithGenericMethod classWithGenericMethod) {
new Expectations() {
{
classWithGenericMethod.m();
result = Collections.singletonList("hello");
}
};
System.out.println(new ClassWithGenericMethod(){}.m2()); // prints "[hello]"
}
}
Please provide the following information:
When instanced called is a subclass of mocking instance, and called method has a generic signature, mockit.internal.expectations.invocation.ExpectedInvocation#isMatchingGenericMethod will only match signature (return type and params type).
Check the following:
[x] If a defect or unexpected result, JMockit project members should be able to reproduce it. For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which can be executed without changes and reproduces the failure.
[x] If an enhancement or new feature request, it should be justified by an example test demonstrating the validity and usefulness of the desired enhancement or new feature.
[x] The issue does not fall outside the scope of the project (for example, attempting to use JMockit APIs from Groovy or Scala code, or with an Android runtime).
[x] The JDK where the problem occurs is a final release, not a development build.
Snippet to reproduce it: