You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstractclassFootraitBarextendsFoovalbar= mock[Bar]
valfoo:Foo= bar // or bar.asInstanceOf[Foo]
fails with:
class Bar$MockitoMock$419587131 cannot be cast to class Foo (Bar$MockitoMock$419587131 and Foo are in unnamed module of loader 'app')
java.lang.ClassCastException: class Bar$MockitoMock$419587131 cannot be cast to class Foo (Bar$MockitoMock$419587131 and Foo are in unnamed module of loader 'app')
The text was updated successfully, but these errors were encountered:
As the issue in the scala compiler says, it's a limitation on the Java type system, which is what Mockito uses under the hood, I'll try to see if there is a way to overcome this limitation, but I'm not really sure it will be possible in the short term
I also though it something specific to way how traits are compiled. I have found workaround in my codebase, but will be great if this issue could be solved in future
I can't promise anything as the mock generator uses Java reflection which is completely oblivious of this particular case, as it's illegal in the Java type system.
I'll keep trying ideas, but most probably unless I re-write the core of mockito again in Scala, I don't think it will be feasible.
Java: 11
Scala: 2.13.1
Mockito: 3.3.3
Mockito Scala: 1.13.10
fails with:
The text was updated successfully, but these errors were encountered: