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

Compile with xcode 10.2 #316

Merged
merged 2 commits into from
Apr 23, 2019
Merged
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
12 changes: 11 additions & 1 deletion ios/RIBs/Classes/DI/Component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
open class Component<DependencyType>: Dependency {

/// The dependency of this `Component`.
open let dependency: DependencyType
public let dependency: DependencyType

/// Initializer.
///
Expand All @@ -47,6 +47,14 @@ open class Component<DependencyType>: Dependency {
lock.unlock()
}

#if swift(>=5.0)

if let instance = sharedInstances[__function] as? T {
return instance
}

#else

// Additional nil coalescing is needed to mitigate a Swift bug appearing in Xcode 10.
// see https://bugs.swift.org/browse/SR-8704.
// Without this measure, calling `shared` from a function that returns an optional type
Expand All @@ -55,6 +63,8 @@ open class Component<DependencyType>: Dependency {
return instance
}

#endif

let instance = factory()
sharedInstances[__function] = instance

Expand Down