Skip to content

Commit 13012c8

Browse files
committed
Fix printing of some refined function types
Some refined function types are of the form (A->B)^{cs} { def apply(x: A): B' = ... } In this case the capture set `cs` was previously dropped. Now it is printed.
1 parent 209d793 commit 13012c8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import config.{Config, Feature}
2929

3030
import dotty.tools.dotc.util.SourcePosition
3131
import dotty.tools.dotc.ast.untpd.{MemberDef, Modifiers, PackageDef, RefTree, Template, TypeDef, ValOrDefDef}
32-
import cc.{CaptureSet, toCaptureSet, IllegalCaptureRef, ccNestingLevelOpt}
32+
import cc.{CaptureSet, CapturingType, toCaptureSet, IllegalCaptureRef, ccNestingLevelOpt}
3333

3434
class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
3535

@@ -268,7 +268,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
268268
toText(tycon)
269269
case tp: RefinedType if defn.isFunctionType(tp) && !printDebug =>
270270
toTextMethodAsFunction(tp.refinedInfo,
271-
isPure = Feature.pureFunsEnabled && !tp.typeSymbol.name.isImpureFunction)
271+
isPure = Feature.pureFunsEnabled && !tp.typeSymbol.name.isImpureFunction,
272+
refs = tp.parent match
273+
case CapturingType(_, cs) => toTextCaptureSet(cs)
274+
case _ => "")
272275
case tp: TypeRef =>
273276
if (tp.symbol.isAnonymousClass && !showUniqueIds)
274277
toText(tp.info)

0 commit comments

Comments
 (0)