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-7349] Bad diagnostic using internal generic argument in superclass #49897

Closed
AnthonyLatsis opened this issue Apr 4, 2018 · 3 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation

Comments

@AnthonyLatsis
Copy link
Collaborator

Previous ID SR-7349
Radar None
Original Reporter @AnthonyLatsis
Type Bug
Status Resolved
Resolution Done
Environment

Xcode Version 9.4 beta (9Q1004a)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI
Assignee @AnthonyLatsis
Priority Medium

md5: 05fc683074114c7b22e3729aeb958c63

Issue Description:

This little code snippet will trigger a warning underlining `B`. Obviously, there shouldn't be a problem here as long as all occurrences of `Foo` in `A` are at least internal (or stricter). Otherwise, they are simply downgraded to the same access level as the type that is involved.

Thread

internal class Foo {} 

public class A<T> {} 

public class B: A<Foo> {} // Class should not be declared public because its superclass is internal

I understand this is simply a warning, but I think it is understandable they can be annoying when appearing in hundreds from pods and external frameworks without a significant reason. I would like to request not to show this warning unless it bears important information (i.e. that can lead to unsafe code.) or if the code doesn't involve any access level downgrading because of the inheritance, like in my case.

In contrast, a case that deserves a warning or even an error (warning if t and init aren't explicitly public, otherwise error)

internal class Foo {} 

public class A<T> {
    public var t: T 
    public init(_ t: T) { self.t = t }
}
public class B: A<Foo> {}
@belkadan
Copy link
Contributor

belkadan commented Apr 5, 2018

As explained on the forum, this is correct behavior as is, but the diagnostic could at least be a little clearer about it being the generic argument's fault. Keeping around for that.

@AnthonyLatsis
Copy link
Collaborator Author

PR for master #16223

@AnthonyLatsis
Copy link
Collaborator Author

The message is now

class should not be declared $accessLevel because its superclass uses a $accessLevel type as a generic parameter (for the warning)

class cannot be declared $accessLevel because its superclass uses a $accessLevel type as a generic parameter (for the error)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 diagnostics QoI Bug: Diagnostics Quality of Implementation
Projects
None yet
Development

No branches or pull requests

2 participants