ballerina-platform / ballerina-lang

The Ballerina Programming Language

Home Page:https://ballerina.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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,

  1. Introduce TypedescSubtypeData which has a semtype field.
    TypedescOps.isEmpty() will be isEmpty(typedescSubtypeData.semType)

  2. 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