Skip to content
← Back

src/ir/values/narrow_guard.ghul

1
namespace IR.Values is
2
use Semantic.Types.Type
3
4
// The check a narrowed value needs when the narrowing reached its
5
// type by eliminating every other alternative of a closed
6
// hierarchy. Nothing checked the value on the way, and in a
7
// session a later cell can add an alternative the elimination
8
// never saw, so the use is of a type the value may not have.
9
//
10
// Emitted at the load rather than at each kind of use, because
11
// every use - a call, a member read, passing it on, storing it -
12
// goes through one. An ordinary build knows the whole hierarchy
13
// and emits nothing.
14
class NARROW_GUARD is
15
is_needed(narrowed: Type?) -> bool static =>
16
IoC.CONTAINER.instance.build_flags.wants_session_guards /\
17
IoC.CONTAINER.instance.complement_singletons.contains(narrowed)
18
si
19
si