SHARE
TWEET

Untitled

a guest May 19th, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Foundation
  2.  
  3. class Type: NSObject {
  4.     let value = 1
  5. }
  6.  
  7. struct MyString : ExpressibleByStringLiteral {
  8.    
  9.     init(stringLiteral value: String) {}
  10.     init(unicodeScalarLiteral value: String) {}
  11.     init(extendedGraphemeClusterLiteral value: String) {}
  12. }
  13.  
  14. // StringLiteralType を変更すると #keyPath から推論される型も変化するみたい
  15. typealias StringLiteralType = MyString
  16.  
  17. let path = #keyPath(Type.value)
  18.  
  19. type(of: path)      // __lldb_expr_72.MyString
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top