-
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
Members on Atom and Type include inherited methods from Any #12099
base: develop
Are you sure you want to change the base?
Conversation
vector_methods = Hashset.from_vector <| Meta.meta Vector . methods | ||
array_methods = Hashset.from_vector <| Meta.meta Array . methods | ||
diff = array_methods.difference vector_methods | ||
Test.with_clue "The difference should be empty, but was: "+diff.to_text <| |
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.
Would a simple .should_equal
work here?
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.
No, because Vector
's methods are a superset of Array
's methods, which is expected. For example, there is Vector.from_array
and Vector.from_polyglot_array
which is not on Array
, and that is fine.
# Conflicts: # engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetTypeMethodsNode.java
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.
I am surprised the code in Type
isn't using allTypes(...)
, but hardcodes anyMethods
. I'd expect more generic code.
var member = myTypeAtom.getMember(memberName); | ||
assertThat("Member " + memberName + " should be readable", member, is(notNullValue())); | ||
assertThat("All fields are numbers", member.isNumber(), is(true)); | ||
assertThat("Has at least two fields", memberNames.size(), is(greaterThan(2))); |
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.
assertThat("Has at least two fields", memberNames.size(), is(greaterThan(2))); | |
assertThat("Has more than two fields", memberNames.size(), is(greaterThan(2))); |
@@ -2428,7 +2428,7 @@ class RuntimeErrorsTest | |||
contextId, | |||
mainResId, | |||
Api.ExpressionUpdate.Payload.Panic( | |||
"Compile_Error", | |||
"Compile_Error.Error", |
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.
Why has this changed?
|
||
/** | ||
* Returns methods (both instance and static) defined on this type, including the ones inherited | ||
* from Any. Instance methods are defined on this type, static methods are defined on its {@link |
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.
Does this work properly for Any
, Number
, Integer
or Float
hierarchy? E.g. are methods from Number
(if any) also included?
@TruffleBoundary | ||
public Map<String, Function> getMethods(boolean includeStaticMethods) { | ||
var ctx = EnsoContext.get(null); | ||
var allMethods = new HashMap<>(methodsFromAny(ctx)); |
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.
There is method allTypes()
which returns "All types this type represents including super types." - I guess it should be used here somehow to handle the "numbers hierarchy".
|
||
group_builder.specify "methods of Integer" <| | ||
Meta.meta Integer . methods . sort . should_equal ['%', '*', '+', '-', '/', '<', '<=', '>', '>=', '^', 'abs', 'bit_and', 'bit_not', 'bit_or', 'bit_shift', 'bit_shift_l', 'bit_shift_r', 'bit_xor', 'ceil', 'div', 'fits_in_long', 'floor', 'negate', 'round', 'to_decimal', 'to_float', 'truncate'] | ||
expected_methods = ['%', '*', '+', '-', '/', '<', '<=', '>', '>=', '^', 'abs', 'bit_and', 'bit_not', 'bit_or', 'bit_shift', 'bit_shift_l', 'bit_shift_r', 'bit_xor', 'ceil', 'div', 'fits_in_long', 'floor', 'negate', 'round', 'to_decimal', 'to_float', 'truncate'] |
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.
Can you concatenate the expected_methods
from three parts?
- those coming from
Any
- those coming from
Number
- those coming from
Integer
Fixes #12045 and #6303
Pull Request Description
Important Notes
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.