Skip to content

Conversation

@WojciechMazur
Copy link
Contributor

@WojciechMazur WojciechMazur commented Nov 24, 2025

REPL and AbstractFileClassLoader is used by multiple downstream dependencies (eg. scalameta/mdoc), this PR is oriented on improving source compatibility of this class :

  • Share common parts of implementation between io.AbstractFileClassLoader and repl.AbstractFileClassLoader
  • Added default value for interruptInstrumentation constructor arguemnt
  • Made InterruptInstrumentation an enum
  • Fixed warnings present in the repl projects

@WojciechMazur WojciechMazur added the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label Nov 24, 2025
@WojciechMazur WojciechMazur added this to the 3.8.0 milestone Nov 24, 2025
root: AbstractFile,
parent: ClassLoader,
interruptInstrumentation: InterruptInstrumentation = InterruptInstrumentation.fromString(ScalaSettings.XreplInterruptInstrumentation.default)
) extends io.AbstractFileClassLoader(root, parent):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for binary compatibility we would need a separate def this(...) constructor if I am not mistaken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no binary compatibility to uphold. We shouldn't worsen our code to "preserve" binary compatibility.

Even preserving source compat is a benevolent favor we make. We can do it if it helps other projects, but not to expense of our own code quality.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been stable for a while and we use it in Mdoc, which then is used by worksheets in Metals. We don't fully cross publish for different Scala versions, we just check if each version works. I don't really want to add another library that we would need to cross publish.

The other solution would be to have a worksheet API, but that is something no one had the time for.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sjrd for the clarifications. I completely agree with this. T repl and the compiler too are not libraries but rather applications, there is no guarantee to have or to follow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we should think of having an interface for worksheets, but if we decide not to include this change, worksheets will stop working altogether and it will require a lot of my work to fix it. At a cost of a single added custom constructor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think we already accepted much worse code that is being fixed by Wojtek in this PR, so the change is anyway a net positive. Not sure why we would be blocking this change (which will save me loads of time) and anyway accept much worse PRs. :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not blocking anything. But the expectation for this code should be that it will break. There is no guarantee here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully understand this. I will try to vibe code some solution in the background modeled on the presentation compiler interfaces.

@WojciechMazur WojciechMazur enabled auto-merge (squash) November 24, 2025 16:44
@WojciechMazur WojciechMazur merged commit e442879 into scala:main Nov 25, 2025
45 checks passed
@WojciechMazur WojciechMazur deleted the repl/classloader branch November 25, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants