Skip to content

Commit 1dc7eb7

Browse files
authored
Merge pull request #23 from ReactiveCocoa/scoped-disposable-fix
[ScopedDisposable] Fix infinite loop in `init(_ disposable: Disposable)`
2 parents 228fd56 + 965dd8f commit 1dc7eb7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sources/Disposable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ extension ScopedDisposable where InnerDisposable: AnyDisposable {
227227
/// - disposable: A disposable to dispose of when deinitializing, which
228228
/// will be wrapped in an `AnyDisposable`.
229229
public convenience init(_ disposable: Disposable) {
230-
self.init(AnyDisposable(disposable))
230+
self.init(InnerDisposable(disposable))
231231
}
232232
}
233233

Tests/ReactiveSwiftTests/DisposableSpec.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ class DisposableSpec: QuickSpec {
8484
}
8585

8686
describe("ScopedDisposable") {
87+
it("should be initialized with an instance of `Disposable` protocol type") {
88+
let d: Disposable = SimpleDisposable()
89+
let scoped = ScopedDisposable(d)
90+
expect(type(of: scoped) == ScopedDisposable<AnyDisposable>.self) == true
91+
}
92+
8793
it("should dispose of the inner disposable upon deinitialization") {
8894
let simpleDisposable = SimpleDisposable()
8995

0 commit comments

Comments
 (0)