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-11915] Incorrect diagnostic when instance member of outer type is referenced from static method in nested type #54333

Open
marcomasser opened this issue Dec 6, 2019 · 1 comment
Labels
compiler The Swift compiler in itself improvement

Comments

@marcomasser
Copy link

Previous ID SR-11915
Radar rdar://problem/57712092
Original Reporter @marcomasser
Type Improvement
Environment

Tested with: Xcode 11.2.1 (11B53) with the bundled toolchain as well as Swift Development Snapshot 2019-12-04 (a)

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

md5: 3b4092b1ebd6c8dc3b42aca6f939c4c5

Issue Description:

If a static method of a nested type references an instance member of the outer type, that’s an error. But the error message is somewhat incorrect in that it states that the member “cannot be used on instance of nested type”, even though the use is not in an instance method, but a static method.

The first and second error messages here are correct, but the third one is incorrect:

struct Outer {
    var x: Int


    static func foo() {
        print(x) // Correct error: Instance member 'x' cannot be used on type 'Outer'
    }


    struct Inner {
        func bar() {
            print(x) // Correct error: Instance member 'x' of type 'Outer' cannot be used on instance of nested type 'Outer.Inner'
        }


        static func foo() {
            print(x) // Incorrect error: Instance member 'x' of type 'Outer' cannot be used on instance of nested type 'Outer.Inner'
        }
    }
}

Note: This is not the same issue as SR-5324, but I’m referencing it here because it probably touches the same places in the compiler.

@beccadax
Copy link
Contributor

beccadax commented Dec 6, 2019

@swift-ci create

@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 improvement
Projects
None yet
Development

No branches or pull requests

2 participants