Skip to content

Incremental compilation: handle constructor proxies #11360

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

Merged
merged 1 commit into from
Feb 10, 2021

Conversation

smarter
Copy link
Member

@smarter smarter commented Feb 9, 2021

I noticed that repeatedly runnning sbt compile in dotty lead to the
same files being compiled over and over even though nothing changed,
running sbt "debug; compile" revealed messages like this:

[debug] Invalidating '${BASE}/compiler/target/scala-3.0.0-RC1/classes/dotty/tools/dotc/typer/Namer.class' because could not find class dotty.tools.dotc.typer.Namer$ on the classpath.

Indeed, Namer does not have a companion object so there's no
Namer$.class file, but sbt was looking for one because we registered
such a companion with ctx.sbtCallback.binaryDependency, this happened
because we created a fake companion object for the purpose of holding
constructor proxies (fake apply methods that forward to a constructor).
The fix is to special-case such references, just like we already
special-cased references to the fake companion of Java classes.

@smarter smarter added this to the 3.0.0-RC1 milestone Feb 9, 2021
@smarter smarter requested a review from bishabosha February 9, 2021 17:30
Copy link
Contributor

@michelou michelou left a comment

Choose a reason for hiding this comment

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

@smarter Two suggestions :

  • Write If we create constructor proxies instead of If we decide to create constructor proxies.
  • Mention in comment the phase/method names where constructor proxies are created.

@smarter smarter force-pushed the inc-constructor-proxy branch 2 times, most recently from e907119 to 5fcc131 Compare February 9, 2021 18:03
I noticed that repeatedly runnning `sbt compile` in dotty lead to the
same files being compiled over and over even though nothing changed,
running `sbt "debug; compile"` revealed messages like this:

[debug] Invalidating '${BASE}/compiler/target/scala-3.0.0-RC1/classes/dotty/tools/dotc/typer/Namer.class' because could not find class dotty.tools.dotc.typer.Namer$ on the classpath.

Indeed, Namer does not have a companion object so there's no
`Namer$.class` file, but sbt was looking for one because we registered
such a companion with `ctx.sbtCallback.binaryDependency`, this happened
because we created a fake companion object for the purpose of holding
constructor proxies (fake apply methods that forward to a constructor).
The fix is to special-case such references, just like we already
special-cased references to the fake companion of Java classes.
@bishabosha
Copy link
Member

bishabosha commented Feb 10, 2021

on this branch, whenever I open a new sbt session and run repl for example, I still have to recompile 62 files (which also happened before this change), is there another explanation for this?

@smarter
Copy link
Member Author

smarter commented Feb 10, 2021

Yep, that happens because the reference compiler is still broken, if you try sbt scala3-compiler-bootstrapped/compile it should only recompile the non-bootstrapped compiler.

@bishabosha
Copy link
Member

Yep, that happens because the reference compiler is still broken, if you try sbt scala3-compiler-bootstrapped/compile it should only recompile the non-bootstrapped compiler.

Thanks for the info, well I can can confirm that the bootstrapped sources keep compiling on master, but not this branch so I approve this change

@bishabosha bishabosha merged commit 9834cae into scala:master Feb 10, 2021
@bishabosha bishabosha deleted the inc-constructor-proxy branch February 10, 2021 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants