SHARE
TWEET

Untitled

a guest Jun 15th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protocol Foo {
  2.     associatedtype F
  3. }
  4.  
  5. class FooClass : Foo {
  6.     typealias F = String
  7. }
  8.  
  9. class Bar<F:Foo> {
  10.     let foo: F
  11.  
  12.     init(){
  13.         // Error, cannot assign value of type 'FooClass' to type 'F'
  14.         foo = FooClass()
  15.     }
  16. }
  17.      
  18. func weird<F:Foo>(_ f: F){ }
  19.  
  20. func test(){
  21.     weird(FooClass()) // this works
  22. }
  23.      
  24. class Bar<F:Foo> {
  25.     let foo: FooClass.F
  26.  
  27.     init(){
  28.         foo = FooClass.F()
  29.     }
  30. }
  31.      
  32. class Bar<F:Foo> {
  33.     let foo: FooClass
  34.  
  35.     init(){
  36.         foo = FooClass()
  37.     }
  38. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top