[Improvement]: Integrate future and typedesc semtypes into jBallerina type engine
lochana-chathura opened this issue · comments
Description
$sbuject.
future type:
since future is a mutable type future<T1>|future<T2> <: future<T1|T2>
, therefore we have to wrap the constraint in either a map or a list as map<T1>|map<T2> <: map<T1|T2>
has the same behavior.
typedesc type
Unlike future, typedesc is immutable, therefore, typedesc<T1>|typedesc<T2> = typdesc<T1|T2>
. So the subtyping can be modeled from the constraint itself. We have two options,
-
Introduce
TypedescSubtypeData
which has a semtype field.
TypedescOps.isEmpty()
will beisEmpty(typedescSubtypeData.semType)
-
Model subtypedate as readonly mapping as
readonly & map<T1>|readonly & map<T2>
=readonly & map<T1|T2>
Note: In the current jBallerina implementation typedesc<typedesc<T1>|typedesc<T2> <: typdesc<T1|T2>
which I think is wrong. They should be equivalent since typedesc is readonly.
Closing with #42992