SHARE
TWEET

Untitled

a guest Jun 17th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import UIKit
  2.  
  3. @UIApplicationMain
  4. class AppDelegate: UIResponder, UIApplicationDelegate {
  5.   var window: UIWindow?
  6.  
  7.   func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  8.     print(process(MyFoo()))
  9.     return true
  10.   }
  11. }
  12.  
  13. struct MyFoo: Foo {
  14.   var body: some Foo {
  15.     return Bar()
  16.   }
  17. }
  18.  
  19. public func process<Out: Foo>(_ foo: Out) -> String {
  20.   print("hi")
  21.   return process(foo.body)
  22. }
  23.  
  24. public protocol Foo {
  25.   associatedtype Body: Foo
  26.   var body: Body { get }
  27. }
  28.  
  29. extension Never: Foo {
  30.   public var body: Never {
  31.     fatalError()
  32.   }
  33. }
  34.  
  35. struct Bar: Foo {
  36.   typealias Body = Never
  37.  
  38.   public var body: Self.Body {
  39.     fatalError()
  40.   }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top