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

scalamock 7+ not uses Scala LTS #567

Open
visma-alexander-maslov opened this issue Jan 13, 2025 · 8 comments
Open

scalamock 7+ not uses Scala LTS #567

visma-alexander-maslov opened this issue Jan 13, 2025 · 8 comments
Milestone

Comments

@visma-alexander-maslov
Copy link

Scala has LTS version https://virtuslab.com/blog/technology/the-scala-3-compatibility-story/#lts-and-scala-next

It feels like for the generally used library it is better to stick to the LTS branch and and upgrade to the next one when it is absolutely necessary.

The ScalaMock 7.0.0 introduced dependency to Scala 3.4.2 which breaks builds depending on LTS Scala 3.3.x as compiler is not able to read TASTY format from the 3.4.2.

some info about versioning and binary compatibility
https://virtuslab.com/blog/technology/the-scala-3-compatibility-story/
https://docs.scala-lang.org/scala3/reference/language-versions/binary-compatibility.html
https://www.scala-lang.org/blog/2022/08/17/long-term-compatibility-plans.html

@visma-alexander-maslov
Copy link
Author

More info about Scala versions and development guarantees: https://www.scala-lang.org/development/

@goshacodes
Copy link
Collaborator

goshacodes commented Jan 13, 2025

Hi, @visma-alexander-maslov.

scalamock 6 uses scala 3 experimental features and exploits compiler bug which breaks @experimental correct behavior.

current LTS not gives you an opportunity to add Test / scalaOptions := "-experimental", so actually you can't use scalamock on LTS without exploiting this bug

If you are afraid of migrating to at least 3.4.3 you should wait till next LTS release.

scalamock will use next LTS (and will give guaranties on that in the future) as soon as it is released

@goshacodes goshacodes pinned this issue Jan 13, 2025
@goshacodes goshacodes changed the title use Scala LTS scalamock 7+ not uses Scala LTS Jan 13, 2025
@prolativ
Copy link

@goshacodes what's the compiler bug that's being exploited exactly?

@goshacodes
Copy link
Collaborator

goshacodes commented Jan 13, 2025

Annotation @experimental is present here.
https://github.com/paulbutcher/ScalaMock/blob/maintenance-6.x/shared/src/main/scala-3/org/scalamock/clazz/MockMaker.scala#L27

But you can omit it outside of macro scope. No annotation here, as you see.
https://github.com/paulbutcher/ScalaMock/blob/maintenance-6.x/shared/src/test/scala-3/com/paulbutcher/test/Scala3Spec.scala

This is a bug, which allows you to use scalamock 6.x.x actually without annotating every peace of your test code with @experimental
https://github.com/paulbutcher/ScalaMock/blob/maintenance-6.x/build.sbt#L7-L11

I guess, exploit word was too harsh for this one, this bug is not very scary in terms of scalamock

@prolativ
Copy link

So in theory, if scala LTS provided the -experimental compiler flag, would the compiler version used by scalamock be downgraded to 3.3.x?
I'm wondering if the inability of using scalamock with scala LTS is a valid use case for backporting this compiler flag to LTS at all (putting aside whether this change could/should be done in the compiler itself) or if there were some other blockers for using LTS from scalamocks'perspective or if it's already too late to rollback things and downgrade the compiler as scalamocks' new stable major version is already out

@goshacodes
Copy link
Collaborator

goshacodes commented Jan 13, 2025

I can't be sure, it is now impossible to compile even with 3.3.0, since TupledFunction is used, but I think everything should work and compiler version used by scalamock can be downgraded without any problems

@goshacodes
Copy link
Collaborator

goshacodes commented Jan 15, 2025

No backport of experimental compiler flag to LTS from compiler team, so the issue will be open and pinned until next LTS

scala/scala3#18571 (comment)

@ScalaMock ScalaMock locked as resolved and limited conversation to collaborators Jan 15, 2025
@ScalaMock ScalaMock unlocked this conversation Jan 15, 2025
@goshacodes
Copy link
Collaborator

goshacodes commented Feb 21, 2025

I'm going to backport everything to 2.13 and downgrade scala 3 to LTS

@goshacodes goshacodes added this to the 7.3.0 milestone Feb 22, 2025
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

3 participants