Avatar
omochimetaru 6/5/2019 9:42 AM
ドット記法はただの推論じゃなくて、「書き下せないパターン」に落ちてる場合があるって事じゃないか
9:43 AM
むむ
9:43 AM
@swift-5.1.5 struct StaticMember<Base> { init(_ base: Base) {} } protocol ColorStyle { typealias Member = StaticMember<Self> } struct RedStyle : ColorStyle {} struct BlueStyle : ColorStyle {} extension StaticMember where Base : ColorStyle { static var red: RedStyle.Member { print(self) return .init(.init()) } } protocol View {} extension View { func colorStyle<S : ColorStyle>(_ style: S.Member) {} } struct MyView : View {} MyView().colorStyle(.red) MyView().colorStyle(RedStyle.Member.red) MyView().colorStyle(BlueStyle.Member.red)