Skip to content

[Sema] Minimum access for override method is fileprivate #4404

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

Merged
merged 1 commit into from
Aug 19, 2016

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Aug 19, 2016

What's in this pull request?

CC: @jrose-apple
As discussed in #4348 (comment)

Minimum access level of override member in private classes should be fileprivate.
This C.init() and C.foo() is illegal now.

public class B {
  public required init() {}
  public func foo() {}
}
private class C : B {
  private required init() {} // 'required' initializer must be as accessible as its enclosing type
  private override func foo() {} // overriding instance method must be as accessible as its enclosing type
}

Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

A smoke test on macOS does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library only for macOS. Simulator standard libraries and
    device standard libraries are not built.
  3. lldb is not built.
  4. The test and validation-test targets are run only for macOS. The optimized
    version of these tests are not run.

A smoke test on Linux does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library incrementally.
  3. lldb is built incrementally.
  4. The swift test and validation-test targets are run. The optimized version of these
    tests are not run.
  5. lldb is tested.

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

@rintaro
Copy link
Member Author

rintaro commented Aug 19, 2016

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 3e8def2
Test requested by - @rintaro

@rintaro
Copy link
Member Author

rintaro commented Aug 19, 2016

https://ci.swift.org/job/swift-PR-Linux/3523/
Foundation needs update

Foundation/Unit.swift:101:27: error: overriding instance method must be as accessible as its enclosing type
06:34:11     private override func baseUnitValue(fromValue value: Double) -> Double {
06:34:11     ~~~~~~~               ^
06:34:11     fileprivate
06:34:11 Foundation/Unit.swift:23:15: note: overridden declaration is here
06:34:11     open func baseUnitValue(fromValue value: Double) -> Double {
06:34:11               ^
06:34:11 Foundation/Unit.swift:105:27: error: overriding instance method must be as accessible as its enclosing type
06:34:11     private override func value(fromBaseUnitValue baseUnitValue: Double) -> Double {
06:34:11     ~~~~~~~               ^
06:34:11     fileprivate
06:34:11 Foundation/Unit.swift:33:15: note: overridden declaration is here
06:34:11     open func value(fromBaseUnitValue baseUnitValue: Double) -> Double {
06:34:11               ^

@jrose-apple
Copy link
Contributor

This is certainly an incremental improvement (once the Foundation change goes in), but really it should probably be switched over to access scopes like #4176. Otherwise we'll do the wrong thing for members that are more public than the enclosing type.

@CodaFi
Copy link
Contributor

CodaFi commented Aug 19, 2016

@rintaro Foundation patches landed.

@swift-ci please test Linux platform.

@jrose-apple
Copy link
Contributor

Do you think it makes sense to land this or to go all the way to access scopes?

@rintaro
Copy link
Member Author

rintaro commented Aug 19, 2016

@jrose-apple
Even while we are implementing https://bugs.swift.org/browse/SR-2209,
We should stop people from writing private override.
Yes, I think It's reasonable to merge this for now.

@jrose-apple
Copy link
Contributor

Ah, we don't have to get to SR-2209 to get the checking like #4176 (which was merged), but okay.

@jrose-apple jrose-apple merged commit 9a0f9d1 into swiftlang:master Aug 19, 2016
@rintaro
Copy link
Member Author

rintaro commented Aug 19, 2016

Hm, sorry I'm not fully understand #4176 or SR-2209.
Anyway, I will take vacation next week. I don't have time to do that.

Thank you anyway!

@rintaro rintaro deleted the override-accessibility branch August 26, 2016 18:51
jrose-apple pushed a commit to jrose-apple/swift that referenced this pull request Sep 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants