Hello, can you please describe, why this method throws? I checked sources, and here no functions that can throw inside this init.
public init(assemblies: [Assembly], parentAssembler: Assembler?) throws
@ManWithBear Thanks for pointing this out!
Indeed it seems redundant. There is also an unnecessary optional, as pointed out by @tomassliz.
I think we should improve this API. However, it would technically be a breaking API change, so we might need to tread carefully here. @yoichitgy what do you think? Maybe quick improvement might be more important here, given how (in most cases) negligible impact these changes would have on existing code.
Thanks @ManWithBear and @tomassliz for pointing out the issues.
Swinject v1 had dependency of Assember on SwinjectPropertyLoader. When I removed the dependency from Assember, I forgot taking care of throws and the optional argument.
I agree @jakubvano with the quick improvement in Swinject v2. I think we can keep the existing API (initializers) with @available(*, deprecated) annotation to avoid breaking changes.
Can I help with that?
Thanks @ManWithBear馃槂 Yes, it's very helpful if you make a pull request馃憤馃憤馃憤
Thanks, I will try to find time today.
Hm, it's kinda weird.
From Swift Programming Language:
The
throwskeyword is part of a function鈥檚 type, and nonthrowing functions are subtypes of throwing functions. As a result, you can use a nonthrowing function in the same places as a throwing one.
So removing throws keyword will not break API and should be fully compatible with previous versions.
But statements with guard like:
guard let childAssembler = try? Assembler(assemblies: [], parentAssembler: assembler) else {
return
}
Produce "Segmentation fault: 11"
Right now it's only issue.
Even if compiler wasn't buggy in this case, it would still produce warning about no throwing functions occuring within try expression.
With your PR it produces deprecation warning, but it is much more clear what change caused it.
Thanks again for your work 馃槃