-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Separate parsing into its own Phase #13173
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
@@ -64,7 +66,6 @@ object Phases { | |||
YCheckAfter: List[String])(using Context): List[Phase] = { | |||
val fusedPhases = ListBuffer[Phase]() | |||
var prevPhases: Set[String] = Set.empty | |||
val YCheckAll = YCheckAfter.contains("all") |
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 was redundant because containsPhase already checks for "all"
@@ -106,7 +107,7 @@ object Phases { | |||
phase | |||
} | |||
fusedPhases += phaseToAdd | |||
val shouldAddYCheck = YCheckAfter.containsPhase(phaseToAdd) || YCheckAll | |||
val shouldAddYCheck = filteredPhases(i).exists(_.isCheckable) && YCheckAfter.containsPhase(phaseToAdd) |
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.
Check for isCheckable.
@@ -402,9 +407,17 @@ object Phases { | |||
final def iterator: Iterator[Phase] = | |||
Iterator.iterate(this)(_.next) takeWhile (_.hasNext) | |||
|
|||
final def monitor(doing: String)(body: => Unit)(using Context): Unit = |
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.
Moved up from FrontEnd
@@ -573,7 +573,7 @@ object SymDenotations { | |||
case _ => | |||
// Otherwise, no completion is necessary, see the preconditions of `markAbsent()`. | |||
(myInfo `eq` NoType) | |||
|| is(Invisible) && !ctx.isAfterTyper | |||
|| is(Invisible) && ctx.isTyper |
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 believe this is the intent of this line.
@@ -113,7 +115,7 @@ class Pickler extends Phase { | |||
val ctx2 = ctx.fresh.setSetting(ctx.settings.YreadComments, true) | |||
testUnpickler( | |||
using ctx2 | |||
.setPeriod(Period(ctx.runId + 1, FirstPhaseId)) | |||
.setPeriod(Period(ctx.runId + 1, ctx.base.typerPhase.id)) |
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 was needed to fix the pickling tests. I don't understand why.
@@ -164,3 +164,10 @@ The test suite will create a new file if it detects any difference, which can be | |||
original expect file, or if the user wants to globally replace all expect files for semanticdb they can use | |||
`scala3-compiler-bootstrapped/test:runMain dotty.tools.dotc.semanticdb.updateExpect`, and compare the changes via version | |||
control. | |||
|
|||
## Troubleshooting |
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.
Wrote up some advice I got from gitter.
Cool, /cc @allanrenucci |
d68d3f3
to
adc8f44
Compare
I rebased so there are only two commits. I fixed a test failure. There's a compilation error that seems to be present on master
|
There is an open ticket upstream to remove this compiler plugin: akka/akka#30245 |
adc8f44
to
024b0ad
Compare
val name: String = "typer" | ||
} | ||
|
||
@deprecated(message = "FrontEnd has been split into TyperPhase and Parser. Refer to one or the other.") | ||
object FrontEnd { |
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 is a little sketchy, but should silence the error in the community build.
Also, /cc @biboudis |
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 no expert, but the diff seems reasonable to me. Left some non-major comments, questions and suggestions.
unit.untpdTree.checkPos(nonOverlapping = !unit.isJava && !ctx.reporter.hasErrors) | ||
} | ||
// Run regardless of parsing errors | ||
override def isRunnable(implicit ctx: Context): Boolean = true |
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 seems wrong, no? Then again no checkfile has failed so perhaps I'm wrong.
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 lifted that from the original PR. Without it, at least dotty.tools.dotc.CompilationTests
fail.
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.
Yes, even in case of errors in parsing, we run the typer phase, this is particularly useful for IDEs since it means the presentation compiler is usable even when your code doesn't typecheck.
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.
LGTM.
I'm not sure if Nico's just putting names to PRs or if he wants Guilliaume to sign off on merging this.
Thanks for the quick review! |
I'll hold off until merging until @smarter has approved. |
Should I continue to wait or just go ahead and merge? |
I should be able to review this tomorrow. |
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.
Otherwise LGTM.
@@ -97,7 +97,8 @@ phases. The current list of phases is specified in class [Compiler] as follows: | |||
|
|||
/** Phases dealing with the frontend up to trees ready for TASTY pickling */ | |||
protected def frontendPhases: List[List[Phase]] = | |||
List(new FrontEnd) :: // Compiler frontend: scanner, parser, namer, typer | |||
List(new Parser) :: // scanner, parser, namer, typer |
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.
List(new Parser) :: // scanner, parser, namer, typer | |
List(new Parser) :: // scanner, parser |
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, thanks
// TODO without this test, dotty.tools.repl.ScriptedTests fails. Not sure why. | ||
if (this.start > Periods.FirstPhaseId) |
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.
Rather than using this to indirectly check if we're in the REPL, I suggest defining class TyperPhase(val addRootImports: Boolean = true)
and setting the parameter to false in ReplCompiler.
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
87456bb
to
bd08f7e
Compare
@smarter does this mean we can have pre-typer plugins now? 😬 As per https://contributors.scala-lang.org/t/pre-typer-syntactic-plugins-in-scala-3/5565 |
No, pre-typer plugin are still intentionally restricted to research plugins. |
First-time contributor. This is a resurrection of #5613. I've left a few inline comments about any confusion I had along the way.
Motivations:
-Ystop-after:parser
)