mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 22:10:15 +03:00
Allow ..Nothing to resolve to Nothing (#9746)
This commit is contained in:
parent
fa6b7f859f
commit
11dda5b9bc
@ -217,7 +217,7 @@ public final class UnresolvedConstructor implements EnsoObject {
|
||||
@Cached("buildApplication(prototype)") DirectCallNode callNode,
|
||||
@Cached("expectedType.getConstructors().get(prototype.getName())") AtomConstructor c) {
|
||||
if (c == null) {
|
||||
return null;
|
||||
return checkSingleton(expectedType, unresolved);
|
||||
} else {
|
||||
return invokeConstructor(c, prototype, unresolved, state, callNode);
|
||||
}
|
||||
@ -229,7 +229,7 @@ public final class UnresolvedConstructor implements EnsoObject {
|
||||
MaterializedFrame frame, State state, Type expectedType, UnresolvedConstructor unresolved) {
|
||||
var c = expectedType.getConstructors().get(unresolved.getName());
|
||||
if (c == null) {
|
||||
return null;
|
||||
return checkSingleton(expectedType, unresolved);
|
||||
}
|
||||
var callNode = buildApplication(unresolved);
|
||||
return invokeConstructor(c, unresolved.asPrototype(), unresolved, state, callNode);
|
||||
@ -249,6 +249,19 @@ public final class UnresolvedConstructor implements EnsoObject {
|
||||
var r = callNode.call(helper);
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Object checkSingleton(Type c, UnresolvedConstructor unresolved) {
|
||||
if (!c.isEigenType()) {
|
||||
return null;
|
||||
} else {
|
||||
return equalTypeAndConstructorName(c, unresolved) ? c : null;
|
||||
}
|
||||
}
|
||||
|
||||
@CompilerDirectives.TruffleBoundary
|
||||
private static boolean equalTypeAndConstructorName(Type c, UnresolvedConstructor unresolved) {
|
||||
return c.getName().equals(unresolved.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ExportMessage
|
||||
|
@ -507,6 +507,11 @@ add_specs suite_builder =
|
||||
|
||||
foo_vec vec . should_equal [3, 4, 5]
|
||||
|
||||
group_builder.specify "Autoscope Nothing" <|
|
||||
accept (n:Nothing) = n
|
||||
|
||||
accept ..Nothing . is_nothing . should_be_true
|
||||
|
||||
suite_builder.group "Polyglot Argument" group_builder->
|
||||
f1 (x : DateTimeFormatter) = x.to_text
|
||||
f2 (x : Text | DateTimeFormatter) = case x of
|
||||
|
Loading…
Reference in New Issue
Block a user