Skip to content

Fix atoms computation of OrType #16697

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
Jan 14, 2023
Merged
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
15 changes: 7 additions & 8 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3441,20 +3441,19 @@ object Types {
val tp2w = tp2.widenSingletons
if ((tp1 eq tp1w) && (tp2 eq tp2w)) this else TypeComparer.lub(tp1w, tp2w, isSoft = isSoft)

private def ensureAtomsComputed()(using Context): Boolean =
if atomsRunId != ctx.runId && !isProvisional then
private def ensureAtomsComputed()(using Context): Unit =
if atomsRunId != ctx.runId then
myAtoms = computeAtoms()
myWidened = computeWidenSingletons()
atomsRunId = ctx.runId
true
else
false
if !isProvisional then atomsRunId = ctx.runId

override def atoms(using Context): Atoms =
if ensureAtomsComputed() then myAtoms else computeAtoms()
ensureAtomsComputed()
myAtoms

override def widenSingletons(using Context): Type =
if ensureAtomsComputed() then myWidened else computeWidenSingletons()
ensureAtomsComputed()
myWidened

def derivedOrType(tp1: Type, tp2: Type, soft: Boolean = isSoft)(using Context): Type =
if ((tp1 eq this.tp1) && (tp2 eq this.tp2) && soft == isSoft) this
Expand Down