-
Notifications
You must be signed in to change notification settings - Fork 323
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
Import modules' extension methods only with unqualified import statements #3906
Import modules' extension methods only with unqualified import statements #3906
Conversation
Can someone explain me what exactly is limited? If someone pick an extension method |
2637031
to
d09a1b8
Compare
I updated the description. Let me know if this is still confusing. |
Thank you. Now I see it. Seemingly, no additional update in Component Browser is required (it uses |
9f5d037
to
05c158e
Compare
Discovered some more corner cases. I will ping again once I'm done with them. |
9b1df42
to
caba6e2
Compare
OK, added a bunch of tests that cover exporting as well. Now it really looks like it works as expected. @JaroslavTulach @4e6 mind having a look? |
@@ -1,5 +1,6 @@ | |||
import project.Data.Any.Any | |||
import project.Data.Numbers.Integer | |||
import project.Data.Range as Range_Module |
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.
@jdunkerley something to keep in mind in further refactorings (this is because of up_to
)
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.
If the tests are working, then the change is likely good. Few (not that important) comments inline.
engine/runtime/src/main/java/org/enso/interpreter/runtime/scope/ModuleScope.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/scope/ModuleScope.java
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/scope/ModuleScope.java
Outdated
Show resolved
Hide resolved
caba6e2
to
b600118
Compare
Previously, a qualified import would always bring extension methods into the scope. This is because extensions methods weren't taking into account the qualifiers at all and imported scope was blindly added to the existing module scope. The change limits that by taking into account import qualifiers of the types that are being brought and creating a copy of the original `ModuleScope`. This meant that in pretty much every test file of our testsuite we had to import `Test` module. Also, note that one cannot ``` import Standard.Test as Test_Module ``` because of the 2-component name restriction that gets desugared to `Standard.Test.Main` and we have to write ``` import Standard.Test.Main as Test_Module ``` all over the place.
b600118
to
8b43f3d
Compare
Previously, a qualified import would always bring extension methods into the scope. This is because extensions methods weren't taking into account the qualifiers at all and imported scope was blindly added to the existing module scope.
For example, given a module with an extension method in one module (
A.enso
)we weren't consistent with how extension method
foo
could be brought into the scope.All of
import project.A
import project.A.A
from project.A import all
from project.A.A import X, Y
would bring it into the scope.
Now, only
import project.A
from project.A import all
would.
The change limits that by taking into account import qualifiers of the types that are being brought and creating a copy of the original
ModuleScope
.This meant that in pretty much every test file of our testsuite we had to import
Test.Extensions
module.This fixes problem 2) in https://www.pivotaltracker.com/n/projects/2539304/stories/183833055
Important Notes
Note that one cannot
because of the 2-component name restriction that gets desugared to
Standard.Table.Main
and we have to writein a few places. Once we move
Json.to_table
extension this can be improved.Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.