diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso index 2988b1ae422f..57a4f11ff0cb 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso @@ -449,8 +449,8 @@ type Any ## PRIVATE Checks if both comparators of the given objects are both of same type and ordered. - If they are not of same type, a `Type_Error` is thrown. - If the comparators are either `Incomparable`, or unordered, `False` is returned. + If they are not of same type, a `Type_Error` is thrown. If the comparators are + either `Incomparable`, or unordered, `Incomparable_Values` is thrown. assert_ordered_comparators : Any -> (Any -> Any) -> Any ! (Type_Error | Incomparable_Values) assert_ordered_comparators this that ~action = comp_this = Comparable.from this diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso index 433d6b03dd2b..b17b8595fef1 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso @@ -60,7 +60,7 @@ from project.Data.Boolean import all - Symmetry: if x == y then y == x - Reflexivity: x == x - Transitivity: if x < y and y < z then x < z - - Antisymmetry (?): if x > y then y < x + - if x > y then y < x Users are responsible for the compliance to the aforementioned semantics. Should the semantics be violated, an unexpected behavior may be encountered, e.g., diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Polyglot.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Polyglot.enso index a0c778888639..3590c0d69b83 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Polyglot.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Polyglot.enso @@ -67,6 +67,8 @@ get_members object = @Builtin_Method "Polyglot.get_members" > Example Instantiate a new Java Integer with the value 1. + polyglot java import java.lang.Integer + Polyglot.new Integer [1] new : Any -> Vector -> Any new constructor arguments = @Builtin_Method "Polyglot.new" diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeConversionNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeConversionNode.java index 03757b1555b3..16fa61c8e4fa 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeConversionNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeConversionNode.java @@ -203,6 +203,31 @@ Object doConvertText( } } + @Specialization( + guards = { + "!typesLib.hasType(that)", + "!typesLib.hasSpecialDispatch(that)", + "interop.fitsInLong(that)" + }) + Object doConvertNumber( + VirtualFrame frame, + State state, + UnresolvedConversion conversion, + Object self, + Object that, + Object[] arguments, + @CachedLibrary(limit = "10") InteropLibrary interop, + @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Cached ConversionResolverNode conversionResolverNode) { + Function function = + conversionResolverNode.expectNonNull( + that, + extractConstructor(self), + EnsoContext.get(this).getBuiltins().number().getNumber(), + conversion); + return invokeFunctionNode.execute(function, frame, state, arguments); + } + @Specialization( guards = { "!typesLib.hasType(that)", diff --git a/test/Tests/src/Semantic/Equals_Spec.enso b/test/Tests/src/Semantic/Equals_Spec.enso index 7eb0d55ed225..da2ed072321f 100644 --- a/test/Tests/src/Semantic/Equals_Spec.enso +++ b/test/Tests/src/Semantic/Equals_Spec.enso @@ -5,6 +5,8 @@ import Standard.Test.Extensions polyglot java import java.nio.file.Path as JavaPath polyglot java import java.util.Random as Java_Random +polyglot java import java.lang.Integer +polyglot java import java.lang.Double type CustomEqType C1 f1 @@ -161,6 +163,14 @@ spec = four_field = FourFieldType.Value 1 2 3 4 (rect == four_field).should_be_false + Test.specify "should handle equality of numbers with Polyglot.new" <| + int = Polyglot.new Integer [42] + double = Polyglot.new Double [42.0] + int.should_equal 42 + double.should_equal 42 + int.should_equal double + + Test.specify "should handle `==` on types" <| (Child == Child).should_be_true (Child == Point).should_be_false