-
Notifications
You must be signed in to change notification settings - Fork 27
Add support to identify fields from which type-inclusion in record types #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support to identify fields from which type inclusion they originate in record types. This helps track the source of inherited fields when record types include other types using the *TypeName syntax in Ballerina.
Key changes:
- Added
includedInfield to Member class to track type inclusion source - Modified TypeTransformer to map fields to their inclusion types
- Updated test data to reflect the new field information
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Member.java | Added includedIn parameter to Member record and MemberBuilder |
| TypeTransformer.java | Implemented logic to track field-to-inclusion mapping |
| types.bal | Added test cases for complex type inclusions |
| *.json | Updated test expectations with includedIn field values |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Assume that type inclusion is always a type reference | ||
| TypeDefinitionSymbol typeDef = | ||
| (TypeDefinitionSymbol) ((TypeReferenceTypeSymbol) typeInclusion).definition(); |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsafe cast operation without type checking. The code assumes typeInclusion is always a TypeReferenceTypeSymbol, but this should be verified before casting to prevent ClassCastException.
| int studentId; | ||
| decimal universityCode; |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field studentId in EngineeringStudent conflicts with the inherited field from Student. Field universityCode overrides the one from UndergraduateStudent with a different type (decimal vs float|decimal). This creates ambiguity and should be documented or reconsidered.
| int studentId; | |
| decimal universityCode; | |
| // studentId is inherited from Student; do not redeclare to avoid ambiguity | |
| float|decimal universityCode; |
| int|decimal id; | ||
| |}; |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field id in Rec2 has the same name and type as the inherited field from Rec1. This creates redundancy and potential confusion about field precedence.
| int|decimal id; | |
| |}; | |
| |}; |
Purpose
$title
Addresses wso2/product-ballerina-integrator#779