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

[SR-4155] Generic argument deduction disabled in generic context #46738

Closed
dabrahams opened this issue Mar 3, 2017 · 6 comments
Closed

[SR-4155] Generic argument deduction disabled in generic context #46738

dabrahams opened this issue Mar 3, 2017 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@dabrahams
Copy link
Collaborator

Previous ID SR-4155
Radar None
Original Reporter @dabrahams
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 2f198f51481b5b4892e90af8f01334c2

duplicates:

  • SR-1789 Swift can't infer types in generic methods that reuse part of the struct/class' parameters

Issue Description:

This should work, but doesn't:

(swift) struct X<T> {
          init(_: T) {}
          func f() {
            print(X(3))
        }
        }
<REPL Input>:4:13: error: 'Int' is not convertible to 'T'
    print(X(3))
           ~^~
(swift)

The problem is that inside X, all mentions of X without explicit generic parameters are assumed to be Self, rather than only using that deduction as a last resort. It's very inconvenient in my particular use-case!

@belkadan
Copy link
Contributor

belkadan commented Mar 4, 2017

@DougGregor, @slavapestov, there's a bug tracking removing this "feature", right?

@slavapestov
Copy link
Member

My preferred fix would be to write up a proposal for Swift 4 to eliminate the "self arg deduction" feature.

@dabrahams
Copy link
Collaborator Author

I actually wouldn't mind that.

@DougGregor
Copy link
Member

Given that it's a language feature, I think we'd want a swift-evolution proposal to remove it.

@dabrahams
Copy link
Collaborator Author

@slavapestov The phrasing of this suggests you'd volunteer? ;-)

@belkadan
Copy link
Contributor

Consolidating.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

4 participants