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-7405] Protocol compositions: improve composing diagnostics #49948

Open
AnthonyLatsis opened this issue Apr 11, 2018 · 3 comments
Open

[SR-7405] Protocol compositions: improve composing diagnostics #49948

AnthonyLatsis opened this issue Apr 11, 2018 · 3 comments
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation improvement

Comments

@AnthonyLatsis
Copy link
Collaborator

Previous ID SR-7405
Radar None
Original Reporter @AnthonyLatsis
Type Improvement
Environment

Xcode 9.2, Xcode 9.3 (9E145), Xcode 9.4 beta

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI
Assignee None
Priority Medium

md5: a5014aa2b07f08f1fa957bb4660b5a8d

relates to:

  • SR-8151 Class inheriting from class existential behaviour doesn't match SE-0156

Issue Description:

Although apparently they aren't harmful, in Xcode 9.4 (Swift 4.1) the following cases do not produce warnings. Some of them do produce warnings in Xcode 9.2 (Swift 4) together with the error "Protocol-constrained type is neither allowed nor needed here". I suggest to show warnings in all these cases:

protocol Foo {}
protocol Fooo: Foo {}

class A: Foo {}

protocol Soo1: Foo & Foo {} 
// Xcode 9.2:  
//     error: Duplicate inheritance from 'Foo'
//     error: Protocol-constrained type is neither allowed nor needed here
//     warning: Redundant conformance constraint 'Self: Foo'
// 
// Xcode 9.4 beta: Nothing
//
// Suggested warning: Duplicate inheritance from 'Foo'


protocol Soo2: Foo & Fooo {}
// Xcode 9.2:  
//     error: Protocol-constrained type is neither allowed nor needed here
//     warning: Redundant conformance constraint 'Self: Foo'
//
// Xcode 9.4 beta: Nothing
//
// Suggested warning: Redundant conformance constraint 'Self: Foo' 



// Xcode 9.2 & Xcode 9.4 beta: Nothing

func foo1(_ arg: A & Foo) {} 
// Suggested warning:
// Redundant conformance of protocol-constrained type (or existential type) to 'Foo'  

func foo2(_ arg: A & A) {} 
// Suggested warning:
// Protocol-constrained type (or existential type) already contains class 'A'  

func foo3(_ arg: Foo & Foo) {} 
// Suggested warning:
// Redundant conformance of protocol-constrained type (or existential type) to 'Foo' [or]  Protocol-constrained type (or existential type) already contains protocol 'Foo'  

func foo4(_ arg: Fooo & Foo) {} 
// Suggested warning:
// Redundant conformance of protocol-constrained type (or existential type) to 'Foo'
@belkadan
Copy link
Contributor

cc @DougGregor, @huonw, @slavapestov

@huonw
Copy link
Mannequin

huonw mannequin commented Jun 28, 2018

Search keyword: protocol composition.

@swift-ci
Copy link
Collaborator

Comment by Daryle Walker (JIRA)

This thread on the Swift forums suggests some more cases that currently resolve to errors, instead of being permissible (possibly with warnings).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 improvement
Projects
None yet
Development

No branches or pull requests

3 participants