Avatar
omochimetaru 11/2/2018 6:39 AM
コンパイラのバグみつけた import UIKit protocol HogeProtocol where Self : UIViewController {} protocol FugaProtocol : HogeProtocol {} extension FugaProtocol { func fuga() { print(self.parent) } } func foo(_ fuga: FugaProtocol) { fuga.fuga() } class ViewController: UIViewController, FugaProtocol { @IBOutlet var textView: UITextView! override func viewDidLoad() { super.viewDidLoad() } @IBAction func onButton() { foo(self) } }
6:41 AM
@swift-4.2.4 class Animal { func bark() { } } protocol HogeP where Self : Animal {} protocol FugaP : HogeP {} extension FugaP { func fuga() { self.bark() } } func foo(_ fuga: FugaP) { fuga.fuga() } class Cat : Animal, FugaP { } let cat = Cat() foo(cat) (edited)