[Sema] Type inference from default expression doesn’t compile in free function#79989
[Sema] Type inference from default expression doesn’t compile in free function#79989hamishknight merged 11 commits intoswiftlang:mainfrom
Conversation
|
Before I un-draft this, @xedin since you responded about this on the forums here: https://forums.swift.org/t/type-inference-from-default-expression-doesnt-compile-in-free-function/70521 would you mind checking, if this is even the right direction to fixing this? Thank you 🙏 |
|
@slavapestov @xedin @hborla Polite ping. Would you be so kind and check this PR? Thank you. |
|
Hello @slavapestov @xedin @hborla, just following up again on this pull request. Would you mind reviewing it and maybe also kick off a CI job? |
|
@swift-ci please test |
|
I think the tests are correct to fail on this: This is ambiguous: final class CondSendable<T> {
init(_: T, other: T = 42) {}
}
_ = CondSendable("f") |
hamishknight
left a comment
There was a problem hiding this comment.
Thanks for fixing this!
Yes I agree, the test should be updated to use a new generic parameter for the default argument I think |
hamishknight
left a comment
There was a problem hiding this comment.
One more comment, otherwise this looks good to me!
1535aac to
91b6561
Compare
hamishknight
left a comment
There was a problem hiding this comment.
Wonderful, thank you!
|
Failures seem unrelated. I preemptively merged main back into my branch. |
|
@swift-ci please test |
|
Looks like this hit some projects in the source compat suite, downgrading to a warning in #81887 |
This is an attempt to solving #72199.
As I've already lined out in the issue, this seems to be a two-fold problem.
The first one was a rather easy fix, as I've seen similar approaches in different parts of the codebase. It is pretty much just un-currying the generic function.
The second problem was, that
DependentMemberTypes were counted towards the generic-parameter-should-only-be-mentioned-once-limit even though you cannot infer the generic type from the dependent member type.Resolves #72199