diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetTypeMethodsNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetTypeMethodsNode.java index f140fe1a3674..d594c07150e0 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetTypeMethodsNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetTypeMethodsNode.java @@ -1,9 +1,5 @@ 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; @@ -11,6 +7,11 @@ 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", @@ -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 diff --git a/test/Tests/src/Semantic/Meta_Spec.enso b/test/Tests/src/Semantic/Meta_Spec.enso index 8119ea30703a..2cc8496de45c 100644 --- a/test/Tests/src/Semantic/Meta_Spec.enso +++ b/test/Tests/src/Semantic/Meta_Spec.enso @@ -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