-
Notifications
You must be signed in to change notification settings - Fork 3.1k
WIP: run refchecks for diagnostics after typer errors #11030
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
base: 2.13.x
Are you sure you want to change the base?
Conversation
source-dependencies/nested-type-params and a few of the |
https://github.com/scala/scala/blob/v2.13.16/build.sbt#L988-L994 - I should add that to CONTRIBUTING.md. |
Actually, they are pending tests, so nothing failed. The reporting is very confusing.. |
I'm not against this, behind a flag ( |
@lrytz I'll work on the change. I'll also make the proposed changes to RefChecks a bit more specific, e.g. instead of
this
And I will undo my changes to the general neg partests. Instead for regression testing I'll copy selected tests with enabled Let me know if you have concerns about this. |
Let's also see what they say on the Scala 3 side, I think we should do the same on both sides. I can bring it up for discussion in the meeting today. |
We didn't have enought time, unfortunately.. |
I haven't looked yet, but IMHO the goal would be to factor out some benign refchecks that can always be run when erroring after typer, much like I don't know if signal/noise would be poor. If I typo a parent class, all my overrides are broken. So maybe only some checks are run, depending on the errors. |
@cvogt we discussed this today at the core meeting. We support having a I think it's unlikely to make it out of a
Maybe there's a way for you to try this out with a local Scala build, to get some data on how useful / bad it is? That would be great. |
@lrytz that's great, thank you. A -Y flag is perfectly fine. And yes, I think we can trial that with several users on Scala 2 in daily real world use before merging. I'd make PRs for Scala 2 and 3. Just a heads up, the next few months are a bit unpredictable for me, it might take until July/August until I can pick this back up. |
Looking for feedback:
We'd love to have IDE diagnostics for things detected in refchecks even when typer reported errors. (also see scala/scala3#22872). For example, we have users used to seeing missing implementations for abstract methods in Scala 2 IntelliJ diagnostics, but missing them via metals.
I ran an expertiment running refchecks after typer reported errors and got the relevant test to pass. I want to share the results of the experiment. Please let me know if this sounds worth it for me to further pursue and polish.
Motivation: Running refchecks unlocks the following diagnostics even when having type errors.
Missing implementation:
def …: … = ??? // variables need to be initialized to be defined
@throws
only allowed for methods and constructorstrait … inherits different type instances of trait …:
…
?For each failed test I made a quick call to either add the diagnostics to the test log, fix the test code to satisfy the new diagnostics or add a condition to refchecks to skip the check. If this were to go forward, polishing would require revisiting the decisions.
Open question:
Are some of the new diagnostics prone to false positives in the light of type errors? Nothing immediately stuck out in the partests.
What would be the best way to deal with the new edge cases handled in RefChecks that make this possible?
Some thoughts:
Most of these
typerReportedErrors
conditions prevent assertion failures or null pointer exceptions. The current conditionals I put there are actually rejecting more cases than necessary.More precise would be checking for the exact conditions, e.g. something being null.
An alternative more wholesale approach would be simply catch and ignore any exception that actually occurs in this best effort mode of refchecks. This might make the mode more resilient against crashes in potential gaps in partest coverage. But it might be too blunt of an instrument even when only used in this best-effort mode.