Skip to content
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

Add the locations to the field in an intersected record #42108

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

nipunayf
Copy link
Contributor

@nipunayf nipunayf commented Feb 2, 2024

Purpose

The current implementation sets null as the location when adding the fields to the new intersected record. This impacts the fieldDescriptors API as it is unable to detect the line range when initializing the symbols.

Fixes #42094

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@nipunayf nipunayf changed the title Add the locations to the field in an intersected record. Add the locations to the field in an intersected record Feb 2, 2024
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 44 lines in your changes are missing coverage. Please review.

Comparison is base (42cd8d6) 76.69% compared to head (f9b150a) 76.69%.
Report is 55 commits behind head on master.

Files Patch % Lines
.../ballerina/cli/launcher/CustomToolClassLoader.java 0.00% 32 Missing ⚠️
.../providers/changetype/FixReturnTypeCodeAction.java 40.00% 5 Missing and 4 partials ⚠️
...lerinalang/compiler/tree/BLangTestablePackage.java 50.00% 2 Missing ⚠️
...o2/ballerinalang/compiler/desugar/MockDesugar.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #42108   +/-   ##
=========================================
  Coverage     76.69%   76.69%           
  Complexity    53036    53036           
=========================================
  Files          2883     2883           
  Lines        199951   199958    +7     
  Branches      26034    26026    -8     
=========================================
+ Hits         153345   153353    +8     
- Misses        38144    38146    +2     
+ Partials       8462     8459    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nipunayf nipunayf added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Feb 2, 2024
KavinduZoysa
KavinduZoysa previously approved these changes Feb 6, 2024
@KavinduZoysa
Copy link
Contributor

@MaryamZi, Do we need to send this fix to 8.x branch?

@@ -5618,7 +5618,7 @@ private boolean populateFields(IntersectionContext intersectionContext, BRecordT
intersectionFieldType, newTypeSymbol, lhsRecordField.pos, SOURCE);
}

newTypeFields.put(key, new BField(name, null, recordFieldSymbol));
newTypeFields.put(key, new BField(name, recordFieldSymbol.pos, recordFieldSymbol));
Copy link
Member

@chiranSachintha chiranSachintha Feb 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is okay to set the position here. My concern is why we keep the position as a field of BField. Normally, we access the position from the symbol. Here as well, when we need to retrieve the position, we need to obtain it from the symbol.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we create the record field symbol of the resultant record symbol of the intersection, we use the position of this BField. Alternatively, we can use lhsRecordField.symbol.pos as well here.

intersectionFieldType, newTypeSymbol, lhsRecordField.pos, SOURCE);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. IMO, That is the best way to access the position. Shall we try whether we can remove pos in the BField without affecting the code?

}

newTypeFields.put(key, new BField(name, recordFieldSymbol.pos, recordFieldSymbol));
newTypeFields.put(key, new BField(name, null, recordFieldSymbol));
Copy link
Member

@chiranSachintha chiranSachintha Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you got what I said wrong. What I meant was, check whether we can remove the pos field from the BField. If we can't, then let's just use recordFieldSymbol.pos for pos here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, there are multiple usages that use the pos field of the BField. We may require a separate issue to evaluate and refactor this change if applicable.

@KavinduZoysa KavinduZoysa merged commit 0823dc9 into ballerina-platform:master Feb 8, 2024
17 of 18 checks passed
@nipunayf nipunayf added this to the 2201.9.0 milestone Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: RecordTypeSymbol.fieldDescriptors() returns NPE
5 participants