Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass a Swift compiler bug in generic subclass associated object #30

Merged
merged 1 commit into from Jul 28, 2017

Conversation

devxoul
Copy link
Member

@devxoul devxoul commented Jul 28, 2017

I found something weird. Reactor's action is created again after the state stream is created when subclassing a generic class.

// Generic class
class ParentReactor<T>: Reactor {
  enum Action {}
  typealias Mutation = Void
  typealias State = Void
  let initialState: State = State()
}

// Subclass
class ChildReactor: ParentReactor<String> {
}

let reactor = ChildReactor()
let address1 = ObjectIdentifier(reactor.action).hashValue // 140212178080688
_ = reactor.state // will call createStateSteam()
let address2 = ObjectIdentifier(reactor.action).hashValue // 140212178094112
XCTAssertEqual(address1, address2) // FAIL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant