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-2579] Private access is not always enforced correctly #45184

Closed
swift-ci opened this issue Sep 8, 2016 · 4 comments
Closed

[SR-2579] Private access is not always enforced correctly #45184

swift-ci opened this issue Sep 8, 2016 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Sep 8, 2016

Previous ID SR-2579
Radar rdar://problem/28271313
Original Reporter DrTae (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 8 Beta 6, Xcode 8 GM Seed

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

md5: e1d5b277addb554d1b13990a20f8c9dd

relates to:

Issue Description:

The following specific example from SE-0025 is supposed to be illegal but doesn't produce any errors.

and continues to treat this code as illegal:

struct Outer {
  private struct Inner {
    private typealias Value = Int
    var value: Value
  }
}

Here's a similar example that uses another nested struct instead of a typealias. This example also does not produce any errors but should:

struct Outer {
    private struct Inner {
        private struct InnerPrivateType {
            
        }
        // the declaration of innerProperty has an access level
        // greater than its type which should not be allowed
        var innerProperty = InnerPrivateType()
    }
    // outerProperty is of type Outer.Inner.InnerPrivateType
    // which is obviously outside the scope of Inner
    // and also should not be allowed
    private var outerProperty = Inner().innerProperty
}
@belkadan
Copy link
Contributor

belkadan commented Sep 8, 2016

Thanks! I don't know why these aren't triggering errors, but they definitely should.

@belkadan
Copy link
Contributor

*sigh* Two old optimizations from Swift 2 access checking are causing us to skip the whole thing. See https://github.com/apple/swift/blob/126b9fcb2a8d22ea9313172bff150a39939df1ff/lib/Sema/TypeCheckDecl.cpp#L1500-L1503.

@belkadan
Copy link
Contributor

#4904

@belkadan
Copy link
Contributor

Merged into swift-3.0-branch in #4909

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

No branches or pull requests

2 participants