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-11519] Dependencies between generics always show up warning #53920

Closed
swift-ci opened this issue Sep 25, 2019 · 3 comments
Closed

[SR-11519] Dependencies between generics always show up warning #53920

swift-ci opened this issue Sep 25, 2019 · 3 comments
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation generics Feature: generic declarations and types improvement

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11519
Radar rdar://problem/55705704
Original Reporter miku1958 (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI, Generics
Assignee None
Priority Medium

md5: 44412cec286246be76f057af4dba2006

Issue Description:

I write a network module:

protocol BaseRequest {
    associatedtype Parser
}
open class BaseParser { }

class ApiProvider<Target: BaseRequest, Parser: BaseParser> where Target.Parser == Parser {
    typealias ParserType = Parser
    
    public typealias SuccessBlcokClosure = (Parser) -> Void
    public typealias FailureBlcokClosure = (Error) -> Void
}

There are some dependencies between generics when I write a extension of BaseRequest but Xcode always keep showing me warning:

extension BaseRequest where Parser == ApiProvider<Self, Parser>.ParserType {//warning: Redundant same-type constraint 'Self.Parser' == 'Self.Parser'
    typealias Provider = ApiProvider<Self, Parser>
    
    func startRequest(success successCallback: Provider.SuccessBlcokClosure, failure failureCallback: Provider.FailureBlcokClosure) {
        
    }
}

If I don't write where Parser == ApiProvider<Self, Parser>.ParserType , typealias Provider = ApiProvider<Self, Parser> will has error:
'ApiProvider' requires that 'Self.Parser' inherit from 'LMBaseParser'
so I have to write this

@belkadan
Copy link
Contributor

I think you're supposed to write where Parser: BaseParser, since you're getting that constraint almost by coincidence by going through ApiProvider<Self, Parser>. But the diagnostic should say that instead of simply claiming it's redundant.

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by 庄黛淳华 (JIRA)

@belkadan I am stupid. It did work. Thinks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@slavapestov
Copy link
Member

Redundant requirement warnings are now disabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation generics Feature: generic declarations and types improvement
Projects
None yet
Development

No branches or pull requests

3 participants