-
Notifications
You must be signed in to change notification settings - Fork 326
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
Static, but instance, but static #3764
Conversation
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.
Just eight changed files? So small PR!
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.
pls remove the print statement, I also wonder whether we can bring back that test?
class ImportsTest extends PackageTest { | ||
"Atoms and methods" should "be available for import" in { | ||
evalTestProject("TestSimpleImports") shouldEqual 20 | ||
Try(evalTestProject("TestSimpleImports")) | ||
println(consumeOut) |
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.
println(consumeOut) |
#3764 introduced static wrappers for instance methods. Except it had a limitation to only be allowed for types with at least a single constructor. That excluded builtin types as well which, by default, don't have them. This limitation is problematic for Array/Vector consolidation and makes builtin types somehow second-citizens. This change lifts the limitation for builtin types only. Note that we do not want to share the implementatin of the generated builtin methods. At the same time due to the additional argument we have to adjust the starting index of the arguments. This change avoids messing with the existing dispatch logic, to avoid unnecessary complexity. As a result it is now possible to call builtin types' instance methods, statically: ``` arr = Array.new_1 42 Array.length arr ``` That would previously lead to missing method exception in runtime. The only exception is `Nothing`. Primarily because it requires `Nothing` to have a proper eigentype (`Nothing.type`) which would messed up a lot of existing logic.
#3764 introduced static wrappers for instance methods. Except it had a limitation to only be allowed for types with at least a single constructor. That excluded builtin types as well which, by default, don't have them. This limitation is problematic for Array/Vector consolidation and makes builtin types somehow second-citizens. This change lifts the limitation for builtin types only. Note that we do not want to share the implementatin of the generated builtin methods. At the same time due to the additional argument we have to adjust the starting index of the arguments. This change avoids messing with the existing dispatch logic, to avoid unnecessary complexity. As a result it is now possible to call builtin types' instance methods, statically: ``` arr = Array.new_1 42 Array.length arr ``` That would previously lead to missing method exception in runtime. The only exception is `Nothing`. Primarily because it requires `Nothing` to have a proper eigentype (`Nothing.type`) which would messed up a lot of existing logic.
#3764 introduced static wrappers for instance methods. Except it had a limitation to only be allowed for types with at least a single constructor. That excluded builtin types as well which, by default, don't have them. This limitation is problematic for Array/Vector consolidation and makes builtin types somehow second-citizens. This change lifts the limitation for builtin types only. Note that we do not want to share the implementatin of the generated builtin methods. At the same time due to the additional argument we have to adjust the starting index of the arguments. This change avoids messing with the existing dispatch logic, to avoid unnecessary complexity. As a result it is now possible to call builtin types' instance methods, statically: ``` arr = Array.new_1 42 Array.length arr ``` That would previously lead to missing method exception in runtime. The only exception is `Nothing`. Primarily because it requires `Nothing` to have a proper eigentype (`Nothing.type`) which would messed up a lot of existing logic.
#3764 introduced static wrappers for instance methods. Except it had a limitation to only be allowed for types with at least a single constructor. That excluded builtin types as well which, by default, don't have them. This limitation is problematic for Array/Vector consolidation and makes builtin types somehow second-citizens. This change lifts the limitation for builtin types only. Note that we do want to share the implementation of the generated builtin methods. At the same time due to the additional argument we have to adjust the starting index of the arguments. This change avoids messing with the existing dispatch logic, to avoid unnecessary complexity. As a result it is now possible to call builtin types' instance methods, statically: ``` arr = Array.new_1 42 Array.length arr ``` That would previously lead to missing method exception in runtime. # Important Notes The only exception is `Nothing`. Primarily because it requires `Nothing` to have a proper eigentype (`Nothing.type`) which would messed up a lot of existing logic for no obvious benefit (no more calling of `foo=Nothing` in parameters being one example).
Pull Request Description
Adds the ability to write
Foo.method (Mk_Foo 123)
as a synonym of(Mk_Foo 123).method
because Rust.Important Notes
Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.