|
|
|
|
@ -559,7 +559,7 @@ follows.
@@ -559,7 +559,7 @@ follows.
|
|
|
|
|
} |
|
|
|
|
throw new UnsupportedOperationException( |
|
|
|
|
"No overload for operation %s and operands [%s] and [%s]" |
|
|
|
|
.formatted(operation.name(), left, right)); |
|
|
|
|
.formatted(operation, left, right)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
---- |
|
|
|
|
@ -578,7 +578,7 @@ Java::
@@ -578,7 +578,7 @@ Java::
|
|
|
|
|
context.setOperatorOverloader(new ListConcatenation()); |
|
|
|
|
|
|
|
|
|
// evaluates to a new list: [1, 2, 3, 4, 5] |
|
|
|
|
parser.parseExpression("{1, 2, 3} + {4, 5}").getValue(context, List.class); |
|
|
|
|
parser.parseExpression("{1, 2, 3} + {2 + 2, 5}").getValue(context, List.class); |
|
|
|
|
---- |
|
|
|
|
|
|
|
|
|
Kotlin:: |
|
|
|
|
@ -589,8 +589,19 @@ Kotlin::
@@ -589,8 +589,19 @@ Kotlin::
|
|
|
|
|
context.setOperatorOverloader(ListConcatenation()) |
|
|
|
|
|
|
|
|
|
// evaluates to a new list: [1, 2, 3, 4, 5] |
|
|
|
|
parser.parseExpression("{1, 2, 3} + {4, 5}").getValue(context, List::class.java) |
|
|
|
|
parser.parseExpression("{1, 2, 3} + {2 + 2, 5}").getValue(context, List::class.java) |
|
|
|
|
---- |
|
|
|
|
====== |
|
|
|
|
|
|
|
|
|
[NOTE] |
|
|
|
|
==== |
|
|
|
|
An `OperatorOverloader` does not change the default semantics for an operator. For |
|
|
|
|
example, `2 + 2` in the above example still evaluates to `4`. |
|
|
|
|
==== |
|
|
|
|
|
|
|
|
|
[CAUTION] |
|
|
|
|
==== |
|
|
|
|
Any expression that uses an overloaded operator cannot be compiled. See |
|
|
|
|
xref:core/expressions/evaluation.adoc#expressions-compiler-limitations[Compiler Limitations] |
|
|
|
|
for details. |
|
|
|
|
==== |
|
|
|
|
|