AliSoftware / Dip

Simple Swift Dependency container. Use protocols to resolve your dependencies and avoid singletons / sharedInstances!
MIT License
978 stars 75 forks source link

Auto-Injection warnings #139

Closed ArtFeel closed 7 years ago

ArtFeel commented 7 years ago

Hi, I'm new to Swift, maybe I'm doing something wrong, but in Wiki, there is the same code example

private let injectedApiClient = Injected<APIClient>()
var apiClient: APIClient? { return injectedApiClient.value }

But, when I'm doing like this, I received warnings:

Warning:(22, 20) expression implicitly coerced from 'APIClient?' to Any
Note:(22, 20) provide a default value to avoid this warning
Note:(22, 20) force-unwrap the value to avoid this warning
Note:(22, 20) explicitly cast to Any with 'as Any' to silence this warning
ilyapuchka commented 7 years ago

Never saw these warnings. What version of Xcode do you use?

ilyapuchka commented 7 years ago

I guess it has something to do with this bug https://bugs.swift.org/browse/SR-2921. Will close that and add it to Swift 3 issues list.

ArtFeel commented 7 years ago

Sorry, this bug appears only in AppCode, I think I should fill a bug report. In XCode 8.1 everything is ok.