-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type error when mocking java method with generic parameter declared without type parameter #86
Comments
Here's the minimal example that fails to compile: import java.util.Map;
public interface Issue86 {
public void route(Map<Integer, Integer> map); // compiles
public void route(Map map); // does not compile
} val m = mock[Issue86] |
Is there a fix or is it not possible to mock something that has an unrefined Map, or any generic object without the generic explicitly defined |
You can mock a raw type like this Code: import java.util.Map;
public interface Foo {
public void route2(Map<String, Integer> map);
public void route(Map map);
} Test: it should "work" in {
trait FooB extends Foo {
override def route(map: util.Map[_, _])
}
val m = mock[FooB]
} problem is the macro-generated mockfunction definition:
With the overridden trait:
So a possible fix would be to identify missing type parameters in MockMaker.mockMethod, but for now there is solution where you can use a subtrait/interface. |
This is now mentioned in the FAQ: http://scalamock.org/user-guide/faq/ We will aim to make this easier to use without the additional boilerplate in a future version. |
This methods has same type after erasure.
|
Hello,
I am using
mock[InterfaceName]
to mock a java interface, but I get the following error:I am trying to mock EPRuntime using:
Thank you
The text was updated successfully, but these errors were encountered: