Skip to content

Commit 74c835d

Browse files
authored
Merge pull request #3136 from dotty-staging/leaner-ctx
Leaner Context objects
2 parents 657385b + 02d04c9 commit 74c835d

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ object Contexts {
263263
final def withPhaseNoEarlier(phase: Phase) =
264264
if (phase.exists && ctx.phase.id < phase.id) withPhase(phase) else ctx
265265

266+
// `creationTrace`-related code. To enable, uncomment the code below and the
267+
// call to `setCreationTrace()` in this file.
268+
/*
266269
/** If -Ydebug is on, the top of the stack trace where this context
267270
* was created, otherwise `null`.
268271
*/
@@ -281,6 +284,7 @@ object Contexts {
281284
}
282285
println("=== end context creation trace ===")
283286
}
287+
*/
284288

285289
/** The current reporter */
286290
def reporter: Reporter = typerState.reporter
@@ -414,7 +418,8 @@ object Contexts {
414418
this.implicitsCache = null
415419
this.phasedCtx = this
416420
this.phasedCtxs = null
417-
setCreationTrace()
421+
// See comment related to `creationTrace` in this file
422+
// setCreationTrace()
418423
this
419424
}
420425

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,6 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
7676
private def isLegalPrefix(pre: Type)(implicit ctx: Context) =
7777
pre.isStable || !ctx.phase.isTyper
7878

79-
/** Approximate a type `tp` with a type that does not contain skolem types. */
80-
object deskolemize extends ApproximatingTypeMap {
81-
def apply(tp: Type) = /*ctx.traceIndented(i"deskolemize($tp) at $variance", show = true)*/ {
82-
tp match {
83-
case tp: SkolemType => range(tp.bottomType, atVariance(1)(apply(tp.info)))
84-
case _ => mapOver(tp)
85-
}
86-
}
87-
}
88-
8979
/** Implementation of Types#simplified */
9080
final def simplify(tp: Type, theMap: SimplifyMap): Type = tp match {
9181
case tp: NamedType =>

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,18 @@ class Namer { typer: Typer =>
10611061

10621062
val rhsCtx = ctx.addMode(Mode.InferringReturnType)
10631063
def rhsType = typedAheadExpr(mdef.rhs, inherited orElse rhsProto)(rhsCtx).tpe
1064-
def cookedRhsType = ctx.deskolemize(dealiasIfUnit(widenRhs(rhsType)))
1064+
1065+
// Approximate a type `tp` with a type that does not contain skolem types.
1066+
val deskolemize = new ApproximatingTypeMap {
1067+
def apply(tp: Type) = /*ctx.traceIndented(i"deskolemize($tp) at $variance", show = true)*/ {
1068+
tp match {
1069+
case tp: SkolemType => range(tp.bottomType, atVariance(1)(apply(tp.info)))
1070+
case _ => mapOver(tp)
1071+
}
1072+
}
1073+
}
1074+
1075+
def cookedRhsType = deskolemize(dealiasIfUnit(widenRhs(rhsType)))
10651076
lazy val lhsType = fullyDefinedType(cookedRhsType, "right-hand side", mdef.pos)
10661077
//if (sym.name.toString == "y") println(i"rhs = $rhsType, cooked = $cookedRhsType")
10671078
if (inherited.exists)

0 commit comments

Comments
 (0)