Skip to content
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

Backport "Fix #20521: Optimise caching for computing atoms and widened in OrTypes" to 3.5.2 #21453

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ updates:
- hamzaremmal
reviewers:
- hamzaremmal
- package-ecosystem: bundler
directory: '/docs/_spec'
schedule:
interval: weekly
assignees:
- hamzaremmal
reviewers:
- hamzaremmal

11 changes: 5 additions & 6 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3695,6 +3695,7 @@ object Types extends TypeUtils {
myUnion

private var atomsRunId: RunId = NoRunId
private var widenedRunId: RunId = NoRunId
private var myAtoms: Atoms = uninitialized
private var myWidened: Type = uninitialized

Expand All @@ -3710,20 +3711,18 @@ object Types extends TypeUtils {
val tp2w = tp2.widenSingletons()
if ((tp1 eq tp1w) && (tp2 eq tp2w)) this else TypeComparer.lub(tp1w, tp2w, isSoft = isSoft)

private def ensureAtomsComputed()(using Context): Unit =
override def atoms(using Context): Atoms =
if atomsRunId != ctx.runId then
myAtoms = computeAtoms()
myWidened = computeWidenSingletons()
if !isProvisional then atomsRunId = ctx.runId

override def atoms(using Context): Atoms =
ensureAtomsComputed()
myAtoms

override def widenSingletons(skipSoftUnions: Boolean)(using Context): Type =
if isSoft && skipSoftUnions then this
else
ensureAtomsComputed()
if widenedRunId != ctx.runId then
myWidened = computeWidenSingletons()
if !isProvisional then widenedRunId = ctx.runId
myWidened

def derivedOrType(tp1: Type, tp2: Type, soft: Boolean = isSoft)(using Context): Type =
Expand Down
Loading