Skip to content
← Back

src/semantic/lambda_return_constraint.ghul

1
namespace Semantic is
2
use Types.Type;
3
4
// Decides whether a call slot's Func/Action return-type argument is a
5
// real enough type to push down onto a lambda-literal body as its
6
// expected type.
7
class LAMBDA_RETURN_CONSTRAINT is
8
// False for a sentinel (INFERRED_RETURN_TYPE, INFERRED_VARIABLE_TYPE,
9
// ERROR), a provisional composite still carrying one of those, void,
10
// and a slot that still mentions the callee's own not-yet-bound
11
// method-level type argument (`U` in `map[U](f: T -> U)`, or a
12
// composite like `Tasks.TASK[U]`) - pushing that down would have the
13
// body's type-check against the raw, unresolved type argument
14
// instead of letting the body's own type drive inference. A
15
// class-level type parameter that is already bound in its own
16
// context (e.g. a generic class's own `T`) is not excluded here.
17
should_push(candidate: Type?) -> bool static =>
18
candidate? /\
19
!candidate.is_inferred /\
20
!candidate.is_error /\
21
!candidate.is_void /\
22
!candidate.is_sentinel /\
23
!candidate.contains_function_generic_argument;
24
si
25
si