-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Cleanups and source compatibility improvements for repl.AbstractFileClassLoader #24514
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
Conversation
…bstractFileClassLoader
…source compatibilty
| root: AbstractFile, | ||
| parent: ClassLoader, | ||
| interruptInstrumentation: InterruptInstrumentation = InterruptInstrumentation.fromString(ScalaSettings.XreplInterruptInstrumentation.default) | ||
| ) extends io.AbstractFileClassLoader(root, parent): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/scalameta/mdoc/blob/main/mdoc/src/main/scala-3/mdoc/internal/markdown/MarkdownCompiler.scala this is the file that uses it.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. :/
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
REPL and AbstractFileClassLoader is used by multiple downstream dependencies (eg. scalameta/mdoc), this PR is oriented on improving source compatibility of this class :
io.AbstractFileClassLoaderandrepl.AbstractFileClassLoaderinterruptInstrumentationconstructor arguemntInterruptInstrumentationan enum