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 Swift 4 ambiguity #39
Conversation
@@ -39,11 +43,11 @@ func curryDefinitionGenerator(arguments: Int) -> String { | |||
let lowerFunctionArguments = inputParameters.map { "\($0.lowercased())" } // ["a", "b", "c"] | |||
let returnType = genericParameters.last! // "D" | |||
|
|||
let functionArguments = "(\(commaConcat(inputParameters)))" // "(A, B, C)" | |||
let functionArguments = extraParentheses("(\(commaConcat(inputParameters)))", when: inputParameters.count > 1) // "(A, B, C)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if there is only one argument? does it error out? could we skip this condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, you get something like Cannot convert value of type '(String) -> Service1' to expected argument type '((_)) -> _'
. There can't be extra parentheses for a single parameter.
Is there anything holding this up from getting merged? |
Not sure who's maintaining this anymore ... @sharplet ? |
It's surprising to me that this works at all, beyond that it's needed. My understanding was that Swift moved away from letting you pass tuples to functions that take multiple arguments, and yet this seems to be exactly what this is doing? |
Bump |
Any clue about when this will be merged? |
I'll get this into a release today. |
@@ -454,7 +454,7 @@ | |||
ONLY_ACTIVE_ARCH = YES; | |||
SDKROOT = iphoneos; | |||
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | |||
SWIFT_VERSION = 3.0; | |||
SWIFT_VERSION = 4.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we should do a major version bump? @sharplet I feel like you know more about this compatibility than I do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm pretty sure this would break compilation on Xcode 8.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😞 sigh that's what I was afraid of. Curry 4.0 here we come!
Curry 4.0 is now released, which includes this change and so should fix compatibility with Swift 4. |
Sorry for the delay on this btw, and thank you for your PR and your patience. |
Thank you @gfontenot for your fast reactivity! |
d'oh! Thanks. I'll get that pushed. |
Latest Xcode 9 beta 3 shows
ambiguous use of curry
when the swift 4 version flag is set for the project.This is likely related to changes in compiler implementation in swift 4 -
see more here: Swinject/SwinjectAutoregistration#29
The solution is to disambiguate by adding parentheses to functions with more than one parameter. As far as I tested this, it should be backward compatible with earlier versions of swift.
I would wait before merging this to see whether it is a bug of compiler in the beta or a real change.