File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -195,3 +195,14 @@ extension AnyWorkflowConvertible {
195195        asAnyWorkflow ( ) . mapRendering ( transform) 
196196    } 
197197} 
198+ 
199+ // MARK: -
200+ 
201+ extension  AnyWorkflowConvertible  where  Output ==  Never  { 
202+     /// A convenience for workflows that don't produce output but want to change the declared output type.
203+     public  func  mapOutput< NewOutput> ( )  ->  AnyWorkflow < Rendering ,  NewOutput >  { 
204+         mapOutput ( mapNever ( _: ) ) 
205+     } 
206+ } 
207+ 
208+ private  func  mapNever< T> ( _ input:  Never )  ->  T  { } 
Original file line number Diff line number Diff line change @@ -82,6 +82,13 @@ public class AnyWorkflowTests: XCTestCase {
8282
8383        XCTAssertNotNil ( erased. base as?  OnOutputWorkflow ) 
8484    } 
85+ 
86+     func  testMapNeverToOtherType( )  { 
87+         // test that this `Output = Bool` workflow compiles when mapped from an `Output = Never` workflow
88+         let  boolOutputWorkflow :  AnyWorkflow < String ,  Bool >  =  NeverOutputWorkflow ( ) . mapOutput ( ) 
89+ 
90+         XCTAssertNotNil ( boolOutputWorkflow) 
91+     } 
8592} 
8693
8794/// Has no state or output, simply renders a reversed string
@@ -150,3 +157,13 @@ private struct OnOutputChildWorkflow: Workflow {
150157        } 
151158    } 
152159} 
160+ 
161+ private  struct  NeverOutputWorkflow :  Workflow  { 
162+     typealias  Output  =  Never 
163+     typealias  Rendering  =  String 
164+     typealias  State  =  Void 
165+ 
166+     func  render( state:  State ,  context:  RenderContext < NeverOutputWorkflow > )  ->  String  { 
167+         " Never " 
168+     } 
169+ } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments