Skip to content

[WIP] Check the containing context when checking access for operators #18164

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

Closed
wants to merge 4 commits into from

Conversation

jrose-apple
Copy link
Contributor

This might help eliminate operators from overload sets sooner, if they weren't supposed to be accessed from the current context at all. Or it might not make any noticeable difference. Builds on #18048.

No functionality change; the tests added did not change behavior.

...to push people towards getFormalAccessScope. The one use case that
isn't covered by that is checking whether a declaration behaves as
'open' in the current file; I've added ValueDecl::hasOpenAccess to
handle that specific case.

No intended functionality change.
This gets adjustAccessLevelForProtocolExtension, a hack of sorts to
begin with, out of ValueDecl's general API, and down to a helper for
isAccessibleFrom and isSetterAccessibleFrom. (The only reason these
two don't go through access scopes is as an optimization.)
This function (actually checkAccess) was relying on some implicit
assumptions that aren't actually valid in all cases. When they're not,
just fall back to a slower but more correct implementation; when they
are, assert that the two implementations get the same answer. This
allows us to get rid of adjustAccessLevelForProtocolExtension (see
previous commit), though unfortunately not all of the associated hack.

The diff is bigger than I'd like because it includes moving functions
from NameLookup.cpp into Decl.cpp, but most of those didn't change.

- checkAccess only changed in the one if branch for protocols
- ValueDecl::isAccessibleFrom just added the assertion
- AbstractStorageDecl::isSetterAccessibleFrom did not change

No expected functionality change.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test compiler performance

@swift-ci
Copy link
Contributor

Build comment file:

Compilation-performance test failed

This might help eliminate operators from overload sets sooner, if they
weren't supposed to be accessed from the current context at all. Or it
might not make any noticeable difference.

No functionality change; the tests added did not change behavior.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test compiler performance

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 12c64b829a9349dc1affddce2969cf649945fbfe

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 12c64b829a9349dc1affddce2969cf649945fbfe

@swift-ci
Copy link
Contributor

!!! Couldn't read commit file !!!

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test compiler performance

@swift-ci
Copy link
Contributor

Build comment file:

Compilation-performance test failed

@jrose-apple
Copy link
Contributor Author

20:41:14 
/Users/buildnode/jenkins/workspace/swift-PR-osx/branch-master/swiftpm/Sources/SPMLLBuild/llbuild.swift:13:19: error: module file was created by a newer version of the compiler: /Users/buildnode/jenkins/workspace/swift-PR-osx/branch-master/buildbot_incremental/llbuild-macosx-x86_64/products/llbuildSwift/llbuildSwift.swiftmodule
20:41:14 @_exported import llbuildSwift
20:41:14                   ^

@aciidb0mb3r, @shahmishal, do we need to clean out the build directory here?

@aciidgh
Copy link
Contributor

aciidgh commented Jul 24, 2018

hmmm, I think we need to make sure llbuild rebuilds the Swift bindings when Swift compiler binary changes.

@aciidgh
Copy link
Contributor

aciidgh commented Jul 24, 2018

I'll try to fix that today. Cleaning should work in the meantime.

@shahmishal
Copy link
Member

@jrose-apple workspace cleaned, please start testing again.

@jrose-apple
Copy link
Contributor Author

Well, the patch does have other bugs anyway, so I'll hold off here. But hopefully it's fixed things for others.

@CodaFi
Copy link
Contributor

CodaFi commented Nov 18, 2019

@jrose-apple seems like the refactoring parts have been accomplished in other PRs. Is there a bug fix here that we should take as well, or should this be closed?

@jrose-apple
Copy link
Contributor Author

Indeed, I'm not sure what's salvageable from here. It's been a long time.

@jrose-apple jrose-apple closed this Dec 5, 2019
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.

5 participants