Skip to content

Commit

Permalink
Meta.meta Integer . methods (#6740)
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach authored May 18, 2023
1 parent 0055973 commit 8c37000
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 8c37000

Please sign in to comment.