-
Notifications
You must be signed in to change notification settings - Fork 330
Check private
access at resolution, not an invocation
#13392
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
Check private
access at resolution, not an invocation
#13392
Conversation
This reverts commit 142fecf. See #13078 (comment)
This reverts commit 1a8f5bc. See #13078 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just one question about being able to access a field of a public constructor of a private type.
...ests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateConstructorAccessTest.java
Outdated
Show resolved
Hide resolved
...ion-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateMethodAccessTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- looks like the names of the test methods are/were incorrect
- the title needs a change
- looking at the CI failures, this is not going to be minor
- I suggest one such title
- a change log entry might be needed
...e/runtime/src/main/java/org/enso/interpreter/runtime/callable/argument/CallArgumentInfo.java
Outdated
Show resolved
Hide resolved
@@ -20,17 +20,14 @@ add_specs spec_builder = | |||
group_builder.specify "can get on hold of private constructor" <| | |||
Public_Type.cons . is_nothing . should_be_false | |||
|
|||
group_builder.specify "cannot directly call private constructor" <| | |||
Test.expect_panic Private_Access <| Public_Type.cons 42 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This test was clearly wrong - calling public static method
Public_Type.cons
is certainly allowed - again the name of the test was misleading -
cons
is a method, not a constructor
private
access at resolution, not an invocation
...ion-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateMethodAccessTest.java
Show resolved
Hide resolved
… call arguments" This reverts commit 78f2b81.
❌ prevent getting value from private constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- return back the code that had to be changed to lambdas in #13047
- having the access checks in
UnresolvedSymbol
seems correct - please add
.name
test
...ion-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateMethodAccessTest.java
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/UnresolvedSymbol.java
Show resolved
Hide resolved
# allow us to do that easily. | ||
# For more info, see https://github.com/enso-org/enso/issues/6729 | ||
group_builder.specify "can get reference to private constructor, but cannot call it" <| | ||
group_builder.specify "can get reference to private constructor, and call it from different project" <| | ||
cons_fn data = Public_Type.cons data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where exactly one is getting reference to a private constructor? Shouldn't it be
cons_fn = Public_Type.cons
c = Meta.meta cons_fn : Meta.Constructor
c.fields . should_equal []
c.declaring_type . should_fail_with Private_Check
c.name . should_fail...
? But yeah, maybe that's happening behind the scene anyway.
…e scope. And not from the scope of the current node.
Calling private constructor is possible, there is no more private access check at invocation.
… from Java if reference was obtained from public method.
Fixes #13078
Pull Request Description
Previously, runtime privacy checking did not respect lexical scope. This change moves the privacy checks into UnresolvedSymbol.resolveFor, where the project of the
UnresolvedSymbol
's scope is compared to the project where the target function is defined.In other words, private access is checked at resolution (which happens at runtime, before a method is invoked), not at invocation.
Important Notes
Workarounds introduced in 08b04dd reverted in:
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.