Skip to content
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

Meta.meta Integer . methods #6740

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package org.enso.interpreter.node.expression.builtin.meta;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.data.Array;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.error.PanicException;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;

@BuiltinMethod(
type = "Meta",
name = "get_type_methods",
Expand All @@ -26,8 +27,8 @@ static GetTypeMethodsNode build() {
@Specialization
@CompilerDirectives.TruffleBoundary
Array allMethods(Type type) {
var methodNames = type.getDefinitionScope().getMethods().get(type).keySet();
return new Array(methodNames.toArray());
var methods = type.getDefinitionScope().getMethods().get(type);
return methods == null ? Array.empty() : new Array(methods.keySet().toArray());
}

@Fallback
Expand Down
3 changes: 3 additions & 0 deletions test/Tests/src/Semantic/Meta_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ spec =

methods.sort . should_equal ['bar', 'baz', 'first_method', 'foo', 'my_method', 'other_method', 'second_method']

Test.specify "methods of Integer" <|
Meta.meta Integer . methods . should_equal []

Test.specify "should correctly handle Java values" <|
java_meta = Meta.meta Random.new
java_meta . should_be_a Meta.Polyglot
Expand Down