Class SafeGenericContainers
java.lang.Object
org.ek9lang.compiler.phase5.SafeGenericContainers
THE shared "which of Result, Optional or Iterator is this symbol" (the containers whose unwrapping method
ok()/error(), get() or next() must be preceded by a check, E08030), and the three-way
dispatch onto SymbolsAndScopes' record, is-safe and mark operations. It was a trio of
HasTypeOfGeneric plus an if/else-if chain built in five places; use this, never a fourth.
The test is always Result, then Optional, then Iterator (exclusive by construction: a type has one generic base).
A Result has two guarded accessors, so only the OK accessor is recorded, marked and tested here; the error
accessor is handled by name in SafeSymbolAccess and SafeAccessConjuncts.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumThe container a symbol's type is a parameterisation of. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) booleanisAccessSafe(ISymbol symbol) Is the (OK for a Result) unwrapping access of this symbol safe in the scope it is used in.(package private) booleanisContainer(ISymbol symbol) Is the symbol a Result, Optional or Iterator.(package private) voidmarkAccessSafe(ISymbol symbol, IScope scopeMadeSafe) Mark the (OK for a Result) unwrapping access of this symbol safe in the scope; nothing for other symbols.(package private) Optional<SafeGenericContainers.Container> (package private) voidrecordDeclaration(ISymbol symbol) Record the declaration of a variable of a container type, so that its unwrapping call needs a check.
-
Constructor Details
-
SafeGenericContainers
SafeGenericContainers(SymbolsAndScopes symbolsAndScopes)
-
-
Method Details
-
of
-
isContainer
Is the symbol a Result, Optional or Iterator. -
recordDeclaration
Record the declaration of a variable of a container type, so that its unwrapping call needs a check. -
isAccessSafe
Is the (OK for a Result) unwrapping access of this symbol safe in the scope it is used in. False for a symbol that is not a container. -
markAccessSafe
-