-
Notifications
You must be signed in to change notification settings - Fork 121
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
MatchError in ApiPhase.processScalaUnit
with -sourcepath
compiler option
#1304
MatchError in ApiPhase.processScalaUnit
with -sourcepath
compiler option
#1304
Comments
Thanks for the bug report & explanation of the bug! Would you mind to provide link to a small Github Repo as repro? I was trying to follow the setup locally, but without much success. A Github Repo repro would really help out. |
@Friendseeker I managed to reproduce it as a scripted test: https://github.com/sbt/zinc/compare/develop...lrytz:zinc:t1304?expand=1
|
A comment I made on our internal chat: I guess the right fix is to override something in zinc's Global subclass to make sure the apropriate file subclass is created. Not sure if the right hooks are available. I have never looked at the many, many, many File subclasses that exist in the compiler and in zinc, so I'd need to spend some time. |
It seems, given Lukas' analysis, that the compiler is over-compiling the touched but unchanged A source file, due to the naive incremental compilation logic that exists in the compiler. If the source should have been recompiled, it would've been passed by zinc, as an AbstractZincFile. So rather than try to fix this by trying to fixup the compilation unit file (in #1309) I think we should try to avoid getting here. Ideally we could get the compiler to not trigger its own incremental compilation logic, somehow. But in the meantime perhaps we can skip the incremental analysis, assuming that we don't wipe out any metadata for A, that is still true - though we'll still have a fresh classfile, with a new timestamp... |
Perhaps we can emit an error when zinc is on and By the way, are there cases where |
Sorry for the long comment this turned into...
The user-facing functionality for
That's the reason people seem to use this setting: https://github.com/search?q=%22-sourcepath%22%20path%3A*.sbt&type=code. The original use case for The compiler needs to look up certain symbols from the standard library, see https://github.com/scala/scala/blob/v2.13.12/src/reflect/scala/reflect/internal/Definitions.scala#L371. Usually these symbols are provided by scala-library.jar, i.e., the compiler is invoked with However, when compiling the standard library we don't put I think @dwijnand is right about removing the compiler's built-in incremental compile option for when both a classfile and a source file is available. That was probably useful back in the days before we had actual incremental compilation, but now it can be removed. But even then, It turns out that the So in principle we should still go ahead with your PR to zinc, to make sure a To clean things up we could
|
A big source of my hesitation is I don't like the slippery slope that is |
Setup:
-sourcepath
compiler flagZinc's incremental compilation runs the compiler on the changed source file B. For class A, the compiler finds both a classfile and a source file. Because the source file has a more recent timestamp it creates a SourcefileLoader for symbol A, which invokes
compileLate
and creates a plainBatchSourceFile
.The API phase crashes because it expects an
xsbti.VirtualFile
: https://github.com/sbt/zinc/blob/v1.9.5/internal/compiler-bridge/src/main/scala/xsbt/API.scala#L62I'm encountering this when switching branches in scala/scala.
(edit from Dale: switched A and B in the setup, to match the description below.)
The text was updated successfully, but these errors were encountered: