diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/SortVectorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/SortVectorNode.java index ac8d1401a78a..7576168fa6f4 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/SortVectorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/SortVectorNode.java @@ -719,8 +719,6 @@ private class CompareFromUnresolvedSymbol extends Compare { private final MethodResolverNode methodResolverNode; private final TypesLibrary typesLibrary; - private @CompilerDirectives.CompilationFinal Function resolvedFunction; - private CompareFromUnresolvedSymbol(UnresolvedSymbol unresolvedSymbol, MethodResolverNode methodResolvedNode, TypesLibrary typesLibrary) { @@ -732,7 +730,7 @@ private CompareFromUnresolvedSymbol(UnresolvedSymbol unresolvedSymbol, @Override boolean hasFunctionSelfArgument(Object definedOn) { - ensureSymbolIsResolved(definedOn); + var resolvedFunction = methodResolverNode.expectNonNull(definedOn, typesLibrary.getType(definedOn), unresolvedSymbol); return resolvedFunction.getSchema().getArgumentsCount() > 0 && resolvedFunction.getSchema().getArgumentInfos()[0].getName().equals("self"); @@ -740,14 +738,7 @@ boolean hasFunctionSelfArgument(Object definedOn) { @Override Function get(Object arg) { - ensureSymbolIsResolved(arg); - return resolvedFunction; - } - - private void ensureSymbolIsResolved(Object definedOn) { - if (resolvedFunction == null) { - resolvedFunction = methodResolverNode.expectNonNull(definedOn, typesLibrary.getType(definedOn), unresolvedSymbol); - } + return methodResolverNode.expectNonNull(arg, typesLibrary.getType(arg), unresolvedSymbol); } } diff --git a/test/Tests/src/Data/Vector_Spec.enso b/test/Tests/src/Data/Vector_Spec.enso index c844666da260..bb01775904ca 100644 --- a/test/Tests/src/Data/Vector_Spec.enso +++ b/test/Tests/src/Data/Vector_Spec.enso @@ -765,6 +765,12 @@ type_spec name alter = Test.group name <| Test.specify "should return a vector containing only unique elements up to some criteria" <| alter [Pair.new 1 "a", Pair.new 2 "b", Pair.new 1 "c"] . distinct (on = _.first) . should_equal [Pair.new 1 "a", Pair.new 2 "b"] + Test.specify "should be able to sort a heterogenous vector" <| + arr = [ 1, 1.3, "hi", Date.today, Date_Time.now, [ 0 ] ] + (arr.sort on=(.to_text) . map .to_text) . should_equal (arr.map .to_text . sort) + (arr.sort on=(_.to_text) . map .to_text) . should_equal (arr.map .to_text . sort) + (arr.sort on=(x-> x.to_text) . map .to_text) . should_equal (arr.map .to_text . sort) + Test.specify "should be able to sort a polyglot vector" <| input = "beta".utf_8 expected = "abet".utf_8