Skip to content

Commit 0fbd6b8

Browse files
committed
Disable some special cases about RefiningVars
1 parent 71f7478 commit 0fbd6b8

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@ import collection.mutable
1717
private val Captures: Key[CaptureSet] = Key()
1818
private val BoxedType: Key[BoxedTypeCache] = Key()
1919

20-
/** Switch whether unpickled function types and byname types should be mapped to
21-
* impure types. With the new gradual typing using Fluid capture sets, this should
22-
* be no longer needed. Also, it has bad interactions with pickling tests.
23-
*/
24-
private val adaptUnpickledFunctionTypes = false
20+
object ccConfig:
2521

26-
/** Switch whether we constrain a root var that includes the source of a
27-
* root map to be an alias of that source (so that it can be mapped)
28-
*/
29-
private val constrainRootsWhenMapping = true
22+
/** Switch whether unpickled function types and byname types should be mapped to
23+
* impure types. With the new gradual typing using Fluid capture sets, this should
24+
* be no longer needed. Also, it has bad interactions with pickling tests.
25+
*/
26+
private[cc] val adaptUnpickledFunctionTypes = false
27+
28+
/** Switch whether we constrain a root var that includes the source of a
29+
* root map to be an alias of that source (so that it can be mapped)
30+
*/
31+
private[cc] val constrainRootsWhenMapping = true
32+
33+
val oldRefiningRoots = false
34+
end ccConfig
3035

3136
def allowUniversalInBoxed(using Context) =
3237
Feature.sourceVersion.isAtLeast(SourceVersion.`3.3`)
@@ -86,7 +91,7 @@ class mapRoots(from0: CaptureRoot, to: CaptureRoot)(using Context) extends BiTyp
8691
def apply(t: Type): Type =
8792
if t eq from then to
8893
else t match
89-
case t: CaptureRoot.Var if constrainRootsWhenMapping && t.unifiesWith(from) =>
94+
case t: CaptureRoot.Var if ccConfig.constrainRootsWhenMapping && t.unifiesWith(from) =>
9095
to
9196
case t @ Setup.Box(t1) =>
9297
t.derivedBox(this(t1))
@@ -129,7 +134,7 @@ extension (tree: Tree)
129134
* a by name parameter type, turning the latter into an impure by name parameter type.
130135
*/
131136
def adaptByNameArgUnderPureFuns(using Context): Tree =
132-
if adaptUnpickledFunctionTypes && Feature.pureFunsEnabledSomewhere then
137+
if ccConfig.adaptUnpickledFunctionTypes && Feature.pureFunsEnabledSomewhere then
133138
val rbn = defn.RetainsByNameAnnot
134139
Annotated(tree,
135140
New(rbn.typeRef).select(rbn.primaryConstructor).appliedTo(
@@ -228,7 +233,7 @@ extension (tp: Type)
228233
*/
229234
def adaptFunctionTypeUnderPureFuns(using Context): Type = tp match
230235
case AppliedType(fn, args)
231-
if adaptUnpickledFunctionTypes && Feature.pureFunsEnabledSomewhere && defn.isFunctionClass(fn.typeSymbol) =>
236+
if ccConfig.adaptUnpickledFunctionTypes && Feature.pureFunsEnabledSomewhere && defn.isFunctionClass(fn.typeSymbol) =>
232237
val fname = fn.typeSymbol.name
233238
defn.FunctionType(
234239
fname.functionArity,
@@ -241,7 +246,7 @@ extension (tp: Type)
241246
* a by name parameter type, turning the latter into an impure by name parameter type.
242247
*/
243248
def adaptByNameArgUnderPureFuns(using Context): Type =
244-
if adaptUnpickledFunctionTypes && Feature.pureFunsEnabledSomewhere then
249+
if ccConfig.adaptUnpickledFunctionTypes && Feature.pureFunsEnabledSomewhere then
245250
AnnotatedType(tp,
246251
CaptureAnnotation(CaptureSet.universal, boxed = false)(defn.RetainsByNameAnnot))
247252
else

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2117,7 +2117,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
21172117
ExprType(info1.resType)
21182118
case info1 => info1
21192119

2120-
if ctx.phase == Phases.checkCapturesPhase || ctx.phase == Phases.checkCapturesPhase.prev then
2120+
if ccConfig.oldRefiningRoots && ctx.phase == Phases.checkCapturesPhase || ctx.phase == Phases.checkCapturesPhase.prev then
21212121
// When comparing against a RefiningVar refinement, map the
21222122
// localRoot of the corresponding class in `tp1` to the owner of the
21232123
// refining capture set.

0 commit comments

Comments
 (0)