File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed 
compiler/src/dotty/tools/dotc/cc 
tests/neg-custom-args/captures Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -640,8 +640,8 @@ object CapsOfApply:
640640class  AnnotatedCapability (annot : Context  ?=>  ClassSymbol ): 
641641  def  apply (tp : Type )(using  Context ) = 
642642    AnnotatedType (tp, Annotation (annot, util.Spans .NoSpan ))
643-   def  unapply (tree : AnnotatedType )(using  Context ):  Option [SingletonCaptureRef ] =  tree match 
644-     case  AnnotatedType (parent : SingletonCaptureRef , ann) if  ann.symbol ==  annot =>  Some (parent)
643+   def  unapply (tree : AnnotatedType )(using  Context ):  Option [CaptureRef ] =  tree match 
644+     case  AnnotatedType (parent : CaptureRef , ann) if  ann.symbol ==  annot =>  Some (parent)
645645    case  _ =>  None 
646646
647647/**  An extractor for `ref @annotation.internal.reachCapability`, which is used to express
Original file line number Diff line number Diff line change 1+ import  language .experimental .captureChecking 
2+ import  caps .Capability 
3+ 
4+ trait  File  extends  Capability 
5+ 
6+ class  Resource [T  <:  Capability ](gen : T ): 
7+   def  use [U ](f : T  =>  U ):  U  = 
8+     f(gen) //  error
9+ 
10+ @ main def  run  = 
11+   val  myFile :  File  =  ??? 
12+   val  r  =  Resource (myFile) //  error
13+   ()
Original file line number Diff line number Diff line change 1+ class  C 
2+ def  test (x : C ^ , y : C ^ ) = 
3+   class  D  {
4+     println(x)
5+     def  foo () =  println(y)
6+   }
7+   val  d  =  D ()
8+   val  _:  D ^ {y} =  d //  error, should be ok
9+   val  _:  D  =  d //  error
10+ 
11+   val  f  =  () =>  println(D ())
12+   val  _:  () -> {x} Unit  =  f //  ok
13+   val  _:  () ->  Unit  =  f //  should be error
14+ 
15+   def  g  =  () => 
16+     println(x)
17+     () =>  println(y)
18+   val  _:  () -> {x} () -> {y} Unit  =  g //  error, should be ok
19+   val  _:  () ->  () ->  Unit  =  g //  error
20+ 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments