Open lochana-chathura opened 1 month ago
isSimpleNode()
where AllOrNothingSubtype
instance checks are carried out instead of BddAllOrNothing
instance checks. This resulted in not giving correct values for Core.mappingAtomicType()
.Optional<List<MappingAtomicType>> mappingAtomicTypesInUnion(Context, SemType)
introduced to implement isLaxType()
check using semtypes.Fixed with 4f137ee
When converting isSameType() usages to semtypes, here at https://github.com/ballerina-platform/ballerina-lang/blob/d93ec613f5e22f67a868593a66493119d860f201/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java#L271
the same BObjectType instance with one inside a BUnionType wrapper, evaluate not to be the same type, in the current compiler.
We are comparing BUnionType 5262 to BObjectType 5231
With semTypes, they both identified to be the same type, causing NPE at later stage
When rewriting isDistinctAllowedOnType()
using semtypes, it was found that the same method is called twice for an BObjectType
causing the wrong resolution of distinct type IDs for the semtype. When calling [1], BTypeIdSet
info is not available, resulting in the wrong semtype resolution.
Removing [1] fixed the issue.
Found another issue related to isDistinctAllowedOnType()
. When calling it at Symbol Resolver, the BObject type's symbol does not have the attachedFuncs
values updated, causing a wrong resolution of semtype for the object type.
type Obj0 distinct object {
function apply() returns int;
};
type Obj2 object {
function apply() returns int;
};
function foo(Obj0 x) {
Obj2 y = x; // Should have no error
}
After rewriting isAllReadonlyTypes()
using semtypes at,
https://github.com/ballerina-platform/ballerina-lang/blob/fe0509bed414ca8e1014f0bbb28e1f7a492de09d/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java#L3588
the following test that used compile will now give an error,
class P1 {
Q1 q;
string p1;
function init() {
self.q = new;
self.p1 = "P1";
}
}
class Q1 {
P1 p;
string q1;
function init() {
self.p = new;
self.q1 = "Q1";
}
}
function testArraysOfCyclicDependentTypes3() returns P1[] {
P1[] arr = [];
arr[3] = new; // ERROR [test_parser.bal:(23:5,23:11)] cannot update 'readonly' value of type 'P1[]'
return arr;
}
function testArraysOfCyclicDependentTypes4() returns Q1[] {
Q1[] arr = [];
arr[3] = new; // ERROR [test_parser.bal:(29:5,29:11)] cannot update 'readonly' value of type 'Q1[]'
return arr;
}
This is because in semtype P1
and Q1
are considered to have an empty value space making them equivalent to never
const int[2]|[int, int] ERR_TUPLE5 = []; // ambiguous types
With the use of isSameType()
semtype based API, the above will no longer give the ambiguous type error.
Sample:
function testBitWiseOperationsForNullable() {
byte? x = 251;
int:Signed8? y = -123;
var ans7 = x >> y;
}
Replacing the following isSameType()
with semtype-based API would crash as function (int:Unsigned8?,int:Signed8?) returns (int:Unsigned8?)
considered to be resolved operator symbol rather than function (byte?,int:Signed8?) returns (byte?)
.
BIR diff:
When replacing the types.isSameBIRShape()
call in BIRPackageSymbolEnter
with semtype based isSameType()
, encountered with the following crash.
public type Bdd Node|boolean;
public type Node readonly & record {|
int atom;
Bdd left;
Bdd middle;
Bdd right;
|};
The reason is in the Node
record type, the referred types for left
, middle
and right
are null
when calling at BIRPackageSymbolEnter
. However, via the previous API since we don't access the type(referred type's symbol is used instead) it was not a problem.
Failing test: TypeNameWithSpecialCharsBalaTest
The reason is in the Node record type, the referred types for left, middle and right are null when calling at BIRPackageSymbolEnter. However, via the previous API since we don't access the type(referred type's symbol is used instead) it was not a problem.
The reason for null
was that the type was still resolving. For BReferenceType
we update the referredType after creating the instance. It turned out isSameBIRShape()
was a temporary workaround(See: https://github.com/ballerina-platform/ballerina-lang/issues/35872#issuecomment-1108144686) and the original issue has been fixed with PR #36168.
Hence, isSameBIRShape()
call was removed.
BSameTypeVisitor
and BIRSameShapeVisitor
visitors have now been removed. The former was replaced with the isSameType()
API from semtype module.BOrderedTypeVisitor
has been removed. Used comparable()
API instead, from nBallerina. For that needed to port extra few APIs from there. Additionally, in the nBallerina API, there was a missing part, because of that the following is considered comparable in nBallerina. ("There must be an ordered type to which the static type of both operands belong" part from spec was not implemented in nBallerina) We need to check whether the accumulated types belong to the same ordered type if the lengths are different.type X [(), (), (), (), int, (), (), string];
type Y [5.0];
Description
$subject. We need to get rid of
getMemberTypes()
andgetOriginalMemberTypes()
usages in the current compiler, in order to do #43343.This issue depends on #43126 which is in PR sent state now.