Skip to content
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

Problem with Scala 2.13.0-RC1 #95

Closed
gslowikowski opened this issue Apr 11, 2019 · 14 comments
Closed

Problem with Scala 2.13.0-RC1 #95

gslowikowski opened this issue Apr 11, 2019 · 14 comments

Comments

@gslowikowski
Copy link

gslowikowski commented Apr 11, 2019

I found very strange problem with Scala 2.13.0-RC1. Simple mocking code, that works with all previous versions, fails with this version.

Check the example project https://github.com/gslowikowski/mockito-scala-2.13.0-RC1-problem

It fails with the same error with Scalatest 3.0.8-RC2 and org.scalatestplus.mockito.MockitoSugar class.

@ultrasecreth
Copy link
Member

@gslowikowski Interesting, I'll take a look over the weekend

@ultrasecreth
Copy link
Member

@gslowikowski it seems to be a problem with the compiler not handling final methods correctly, I've reported it here.

In the meantime, you can use inline-mocking as a workaround.

inline-mocking uses a different stubber that allows to mock final methods and classes, but is still not the default in Mockito as it doesn't support 100% of the use cases and feedback from the community is still being collected.

To enable it, just create a simple text file test/resources/mockito-extensions/org.mockito.plugins.MockMaker that just contains the text mock-maker-inline.

Let's hope RC2 or the final version includes a fix for this.

@gslowikowski
Copy link
Author

Thank you @bbonanno

@ultrasecreth
Copy link
Member

Update: PR that should fix this issue here

@smarter
Copy link

smarter commented Apr 15, 2019

To try this PR, you can set scalaVersion := 2.13.0-pre-02f59fb-SNAPSHOT after adding to your build:

  resolvers += "scala-integration" at
    "https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/",

Would be interested in knowing if everything works with that.

@ultrasecreth
Copy link
Member

@smarter It was a wise call, it works for the simple example in the PR, but it doesn't in a more complex scenario, I couldn't figure out what type of hierarchy creates it, but if you run

java.lang.reflect.Modifier.isFinal(classOf[scala.reflect.io.AbstractFile].getMethod("toIterable").getModifiers)

it yields true, which causes everything to blow up

@smarter
Copy link

smarter commented Apr 16, 2019

@bbonanno Once a version of the scala-library compiled with the fixed scala-compiler is published, this should fix itself.

@ultrasecreth
Copy link
Member

@smarter Fair enough, I'll give it a go as son as RC2 is released

Thanks for your help!

@smarter
Copy link

smarter commented Apr 16, 2019

The following should work:

scalaVersion := 2.13.0-pre-cf9468e
 resolvers += "scala-integration" at
    "https://scala-ci.typesafe.com/artifactory/scala-integration/",

@ultrasecreth
Copy link
Member

@smarter it works as expected

Thanks!

@erikvanoosten
Copy link

erikvanoosten commented May 22, 2019

2.13.0-RC2 is already out :)

@ultrasecreth
Copy link
Member

@erikvanoosten Yes!, but I have to wait for my depencencies to be released compiled for RC2 (so far cats-core is the missing one).
I'll release a version supporting RC2 as soon as all my dependencies do :)

@magnolia-k
Copy link
Contributor

cats-core 2.0.0-M2 for Scala 2.13.0-RC2 is released!

https://search.maven.org/artifact/org.typelevel/cats-core_2.13.0-RC2/2.0.0-M2/jar

@ultrasecreth
Copy link
Member

Fixed by #112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants