Skip to content

Avoid time travel when handling of LazyRefs #9114

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 2 commits into from
Jun 9, 2020
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class TypeApplications(val self: Type) extends AnyVal {
case dealiased: TypeBounds =>
dealiased.derivedTypeBounds(dealiased.lo.appliedTo(args), dealiased.hi.appliedTo(args))
case dealiased: LazyRef =>
LazyRef(c => dealiased.ref(c).appliedTo(args))
LazyRef(c => dealiased.ref(c).appliedTo(args)(using c))
case dealiased: WildcardType =>
WildcardType(dealiased.optBounds.orElse(TypeBounds.empty).appliedTo(args).bounds)
case dealiased: TypeRef if dealiased.symbol == defn.NothingClass =>
Expand Down
13 changes: 11 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4862,7 +4862,7 @@ object Types {
}
}

abstract class TypeMap(implicit protected val mapCtx: Context)
abstract class TypeMap(implicit protected var mapCtx: Context)
extends VariantTraversal with (Type => Type) { thisMap =>

protected def stopAtStatic: Boolean = true
Expand Down Expand Up @@ -4979,7 +4979,16 @@ object Types {
derivedSuperType(tp, this(thistp), this(supertp))

case tp: LazyRef =>
LazyRef(_ => this(tp.ref))
LazyRef { c =>
val ref1 = tp.ref(using c)
if c.runId == mapCtx.runId then this(ref1)
else // splice in new run into map context
val saved = mapCtx
mapCtx = mapCtx.fresh
.setPeriod(Period(c.runId, mapCtx.phaseId))
.setRun(c.run)
try this(ref1) finally mapCtx = saved
}

case tp: ClassInfo =>
mapClassInfo(tp)
Expand Down