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-12028] Compiler should warn about shadowing nested type declaration #54465

Open
BenchR267 opened this issue Jan 14, 2020 · 0 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@BenchR267
Copy link
Member

Previous ID SR-12028
Radar rdar://problem/58566078
Original Reporter @BenchR267
Type Bug
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: edaea98a55a77b81f9acde3ba5640b09

Issue Description:

When declaring a nested type in a subclass that has the same name as a nested type in its superclass, the compiler doesn't warn about shadowing/overriding that name which could create unwanted ambiguity. I think the compiler should warn about that. Imagine the following code:

public class Foo {
    public enum Baz {}
}
public class Bar: Foo {
    public struct Baz {}
}

In that simple example the ambiguity is obvious. In a more complicated code base that could create serious problems. Having the compiler warn or even error at the declaration of Bar.Baz would help preventing that kind of problems.

@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
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

1 participant