kosi-libs / MocKMP

A mocking processor for Kotlin Multiplatform
https://kosi-libs.org/mockmp
MIT License
183 stars 12 forks source link

java.lang.RuntimeException: Could not find a way to get a reference of MySealedInterface #56

Closed ankushg closed 1 year ago

ankushg commented 1 year ago

I'm running into issues with sealed interfaces and sealed classes when attempting to match in a Mock with isAny()

The stacktrace is coming from ArgConstraintsBuilder.toReturn

which calls References.getReference which calls cls.isInstance(ref) which seems eventually seems to throw an error for sealed interfaces from validateProxyInterfaces

I've worked around it for now by rewriting tests to just explicitly assert equality instead of using isAny(), but this should probably at least be documented 😅

motorro commented 1 year ago

@ankushg did you upgrade to AGP8 and Java17? I had my tests running but upgraded dependencies and it seems that matters. Haven't done proper git bisecting yet but I suspect the issue is there as I didn't change any sources

motorro commented 1 year ago

Confirmed. Reverting to:

SalomonBrys commented 1 year ago

Fix released in v1.14.0.