Skip to content

Commit cd1a7b2

Browse files
committed
Don't adapt function and by name types when unpickling
With the new gradual typing using Fluid capture sets, this should be no longer needed.
1 parent 6c949a9 commit cd1a7b2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import config.Feature
1515
private val Captures: Key[CaptureSet] = Key()
1616
private val BoxedType: Key[BoxedTypeCache] = Key()
1717

18+
/** Switch whether unpickled function types and byname types should be mapped to
19+
* impure types. With the new gradual typing using Fluid capture sets, this should
20+
* be no longer needed. Also, it has bad interactions with pickling tests.
21+
*/
22+
private val adaptUnpickledFunctionTypes = false
23+
1824
/** The arguments of a @retains or @retainsByName annotation */
1925
private[cc] def retainedElems(tree: Tree)(using Context): List[Tree] = tree match
2026
case Apply(_, Typed(SeqLiteral(elems, _), _) :: Nil) => elems
@@ -49,7 +55,7 @@ extension (tree: Tree)
4955
* a by name parameter type, turning the latter into an impure by name parameter type.
5056
*/
5157
def adaptByNameArgUnderPureFuns(using Context): Tree =
52-
if Feature.pureFunsEnabledSomewhere then
58+
if adaptUnpickledFunctionTypes && Feature.pureFunsEnabledSomewhere then
5359
val rbn = defn.RetainsByNameAnnot
5460
Annotated(tree,
5561
New(rbn.typeRef).select(rbn.primaryConstructor).appliedTo(
@@ -145,7 +151,7 @@ extension (tp: Type)
145151
*/
146152
def adaptFunctionTypeUnderPureFuns(using Context): Type = tp match
147153
case AppliedType(fn, args)
148-
if Feature.pureFunsEnabledSomewhere && defn.isFunctionClass(fn.typeSymbol) =>
154+
if adaptUnpickledFunctionTypes && Feature.pureFunsEnabledSomewhere && defn.isFunctionClass(fn.typeSymbol) =>
149155
val fname = fn.typeSymbol.name
150156
defn.FunctionType(
151157
fname.functionArity,

0 commit comments

Comments
 (0)