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-12137] Swift 5.2 regression with nested classes #54572

Closed
Agarunov opened this issue Feb 6, 2020 · 4 comments
Closed

[SR-12137] Swift 5.2 regression with nested classes #54572

Agarunov opened this issue Feb 6, 2020 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. regression swift 5.2

Comments

@Agarunov
Copy link

Agarunov commented Feb 6, 2020

Previous ID SR-12137
Radar rdar://problem/59302414
Original Reporter @Agarunov
Type Bug
Status Resolved
Resolution Won't Do

Attachment: Download

Environment

Xcode Version 11.4 beta (11N111s)

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, 5.2Regression
Assignee None
Priority Medium

md5: 9a243bbf747e21e66d4495725aca3fdb

is duplicated by:

  • SR-12281 Name resolution of shadowed nested types no longer disambiguates

Issue Description:

Compilation error for this code:

class Base {

    class Constants {
        static let base: Int = 1
    }
    
}


class Derived: Base {

    class Constants {
        static let derived: Int = 2
    }

    static func staticMethod() {
        print(Constants.base) // error: Type 'Derived.Constants' has no member 'base'
        print(Constants.derived)
    }
    
    func instanceMethod() {
        print(Constants.base) // error: Type 'Derived.Constants' has no member 'base'
        print(Constants.derived)
    }
}

This code compiles successfully with Xcode 10.3

@beccadax
Copy link
Contributor

@swift-ci create

@slavapestov
Copy link
Member

This is a consequence of fixing https://bugs.swift.org/browse/SR-3492. How important is it to keep the old behavior? In my opinion it was more trouble than its worth. For example, if both nested Constants types had a member with the same name, we would diagnose an error.

@Agarunov
Copy link
Author

no, it is not important. We can easily fix this error in our project.

@DougGregor
Copy link
Member

Yeah, rejecting this code is correct behavior.

@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. regression swift 5.2
Projects
None yet
Development

No branches or pull requests

5 participants