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

Fix a crash when iterating over the results of Realm.subscriptions() #6050

Merged
merged 2 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
x.y.z Release notes (yyyy-MM-dd)
=============================================================
### Enhancements
* None.

### Fixed
* Fix a crash when iterating over `Realm.subscriptions()` using for-in.
(Since 3.13.0, PR [#6050](https://github.com/realm/realm-cocoa/pull/6050)).

### Compatibility
* File format: Generates Realms with format v9 (Reads and upgrades all previous formats)
* Realm Object Server: 3.11.0 or later.
* APIs are backwards compatible with all previous releases in the 3.x.y series.

### Internal
* None.

3.13.0 Release notes (2018-12-14)
=============================================================

Expand Down
4 changes: 4 additions & 0 deletions Realm/ObjectServerTests/SwiftObjectServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ class SwiftObjectServerTests: SwiftSyncTestCase {
let sub3 = realm.subscription(named: "query")!
XCTAssertEqual(sub3.name, "query")
XCTAssertEqual(sub3.state, .complete)
for sub in realm.subscriptions() {
XCTAssertEqual(sub.name, "query")
XCTAssertEqual(sub.state, .complete)
}

XCTAssertNil(realm.subscription(named: "not query"))
}
Expand Down
2 changes: 1 addition & 1 deletion RealmSwift/RealmCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public struct RLMIterator<Element: RealmCollectionValue>: IteratorProtocol {
}
return unsafeBitCast(next, to: Optional<Element>.self)
}
return next as! Element?
return dynamicBridgeCast(fromObjectiveC: next as Any)
}
}

Expand Down