Skip to content

Introduce Best Effort compilation options #17582

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 10 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix passesConditionForErroringBestEffortCode and improve doc comments
  • Loading branch information
jchyb committed Apr 17, 2024
commit cdf4f987b58ce5a15a7758b2d7843d1280a559e8
15 changes: 8 additions & 7 deletions compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
fillRef(lengthAddr, currentAddr, relative = true)
}

/** There are certain expectations with code which is naturally able to reach pickling
* phase as opposed to one that uses best-effort compilation features.
* When pickling betasty files, we do some custom checks, in case those expectations
* cannot be fulfilled, and if then we can try to do something else.
* For regular non best-effort compilation (without best-effort and without using .betasty on classpath),
* this will always return true.
/** There are certain expectations with code which is naturally able to reach
* pickling phase as opposed to one that uses best-effort compilation features.
* When pickling betasty files, we do some custom checks, in case those
* expectations cannot be fulfilled, and if so, then we can try to do something
* else (usually pickle an ERRORtype).
* For regular non best-effort compilation (without -Ybest-effort with thrown errors
* and without using .betasty on classpath), this will always return true.
*/
private inline def passesConditionForErroringBestEffortCode(condition: => Boolean)(using Context): Boolean =
((!ctx.isBestEffort && ctx.reporter.errorsReported) || ctx.usedBestEffortTasty) || condition
!((ctx.isBestEffort && ctx.reporter.errorsReported) || ctx.usedBestEffortTasty) || condition

def addrOfSym(sym: Symbol): Option[Addr] =
symRefs.get(sym)
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Pickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ class Pickler extends Phase {
(super.isRunnable || ctx.isBestEffort)
&& (!ctx.settings.fromTasty.value || doAsyncTasty)
&& (!ctx.usedBestEffortTasty || ctx.isBestEffort)
// we do not want to pickle `.betasty` if will not create the file either way
// we do not want to pickle `.betasty` if do not plan to actually create the
// betasty file (as signified by the -Ybest-effort option)

// when `-Yjava-tasty` is set we actually want to run this phase on Java sources
override def skipIfJava(using Context): Boolean = false
Expand Down