Skip to content

Conversation

@dulajdilshan
Copy link
Contributor

@dulajdilshan dulajdilshan commented Sep 2, 2025

Purpose

$title

Addresses wso2/product-ballerina-integrator#779

Copy link
Contributor

Copilot AI left a 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 includedIn field 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.

Comment on lines +310 to +312
// Assume that type inclusion is always a type reference
TypeDefinitionSymbol typeDef =
(TypeDefinitionSymbol) ((TypeReferenceTypeSymbol) typeInclusion).definition();
Copy link

Copilot AI Sep 2, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +158 to +159
int studentId;
decimal universityCode;
Copy link

Copilot AI Sep 2, 2025

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.

Suggested change
int studentId;
decimal universityCode;
// studentId is inherited from Student; do not redeclare to avoid ambiguity
float|decimal universityCode;

Copilot uses AI. Check for mistakes.
Comment on lines +169 to +170
int|decimal id;
|};
Copy link

Copilot AI Sep 2, 2025

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.

Suggested change
int|decimal id;
|};
|};

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant