@@ -15,7 +15,7 @@ import Annotations.Annotation
1515import  Denotations ._ 
1616import  SymDenotations ._ 
1717import  StdNames .{nme , tpnme }
18- import  ast .{Trees , untpd }
18+ import  ast .{Trees , tpd ,  untpd }
1919import  typer .{Implicits , Namer , Applications }
2020import  typer .ProtoTypes ._ 
2121import  Trees ._ 
@@ -25,10 +25,12 @@ import NameKinds.{WildcardParamName, DefaultGetterName}
2525import  util .Chars .isOperatorPart 
2626import  transform .TypeUtils ._ 
2727import  transform .SymUtils ._ 
28+ import  config .Config 
2829
2930import  language .implicitConversions 
3031import  dotty .tools .dotc .util .{NameTransformer , SourcePosition }
3132import  dotty .tools .dotc .ast .untpd .{MemberDef , Modifiers , PackageDef , RefTree , Template , TypeDef , ValOrDefDef }
33+ import  cc .{EventuallyCapturingType , CaptureSet , toCaptureSet , IllegalCaptureRef }
3234
3335class  RefinedPrinter (_ctx : Context ) extends  PlainPrinter (_ctx) {
3436
@@ -602,7 +604,17 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
602604 case  tree : Template  => 
603605 toTextTemplate(tree)
604606 case  Annotated (arg, annot) => 
605-  toTextLocal(arg) ~~  annotText(annot.symbol.enclosingClass, annot)
607+  def  captureSet  = 
608+  annot.asInstanceOf [tpd.Tree ].toCaptureSet
609+  def  toTextAnnot  = 
610+  toTextLocal(arg) ~~  annotText(annot.symbol.enclosingClass, annot)
611+  def  toTextRetainsAnnot  = 
612+  try  changePrec(GlobalPrec )(toText(captureSet) ~  "  " ~  toText(arg))
613+  catch  case  ex : IllegalCaptureRef  =>  toTextAnnot
614+  if  annot.symbol.maybeOwner ==  defn.RetainsAnnot 
615+  &&  ctx.settings.Ycc .value &&  Config .printCaptureSetsAsPrefix &&  ! printDebug
616+  then  toTextRetainsAnnot
617+  else  toTextAnnot
606618 case  EmptyTree  => 
607619 " <empty>" 
608620 case  TypedSplice (t) => 
0 commit comments