Special treatment for ..True and ..False (#9767)

This commit is contained in:
Jaroslav Tulach 2024-04-23 15:26:41 +02:00 committed by GitHub
parent 4a97bfa31f
commit 96fdb67204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -241,6 +241,13 @@ public final class UnresolvedConstructor implements EnsoObject {
UnresolvedConstructor unresolved,
State state,
DirectCallNode callNode) {
var builtins = EnsoContext.get(callNode).getBuiltins();
if (c == builtins.bool().getTrue()) {
return true;
}
if (c == builtins.bool().getFalse()) {
return false;
}
var fn = c.getConstructorFunction();
var args = new Object[prototype.descs.length + 1];
System.arraycopy(unresolved.args, 0, args, 1, prototype.descs.length);

View File

@ -439,6 +439,13 @@ add_specs suite_builder =
foo = v:Foo
Foo.Value 10 . should_equal foo
group_builder.specify "..False can be autoscoped" <|
bool b:Boolean = b
f = bool ..False
f.not . should_be_true
group_builder.specify "Autoscope to two different values" <|
v = ..Value 10