Last active
January 24, 2016 04:21
-
-
Save Ben-G/e201cfb68652e1ab141f to your computer and use it in GitHub Desktop.
Does not crash compiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol X { | |
func _ok(a: Any) | |
} | |
public protocol StoreSubscriber: X { | |
typealias StoreSubscriberStateType | |
typealias AppStateType | |
func newState(state: StoreSubscriberStateType) | |
func substateSelector(state: AppStateType) -> StoreSubscriberStateType | |
} | |
extension StoreSubscriber { | |
public func _ok(a: Any) { | |
if let a = a as? StoreSubscriberStateType { | |
newState(a) | |
} | |
} | |
} | |
struct A { | |
var substate: Int | |
} | |
class Thing: StoreSubscriber { | |
func newState(state: Int) { | |
print(state) | |
} | |
func substateSelector(state: A) -> Int { | |
return state.substate | |
} | |
} | |
let substate = Thing().substateSelector(A(substate: 5)) | |
Thing().newState(substate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment