-
Notifications
You must be signed in to change notification settings - Fork 758
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
Conversation
Codecov ReportAttention:
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. |
...s/ballerina-compiler-api-test/src/test/resources/test-src/symbols/error_type_symbol_test.bal
Show resolved
Hide resolved
@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)); |
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.
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.
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.
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.
Line 5619 in 9e6acd2
intersectionFieldType, newTypeSymbol, lhsRecordField.pos, SOURCE); |
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.
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?
ee57954
} | ||
|
||
newTypeFields.put(key, new BField(name, recordFieldSymbol.pos, recordFieldSymbol)); | ||
newTypeFields.put(key, new BField(name, null, recordFieldSymbol)); |
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.
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.
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.
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.
0823dc9
into
ballerina-platform:master
Purpose
The current implementation sets
null
as the location when adding the fields to the new intersected record. This impacts thefieldDescriptors
API as it is unable to detect the line range when initializing the symbols.Fixes #42094
Check List