-
Notifications
You must be signed in to change notification settings - Fork 743
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
[Draft] Fix BIRPackage.importModules
containing duplicate elements
#42346
[Draft] Fix BIRPackage.importModules
containing duplicate elements
#42346
Conversation
compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dedup-birpkg-imports #42346 +/- ##
==========================================================
+ Coverage 76.50% 78.07% +1.56%
- Complexity 53177 58685 +5508
==========================================================
Files 2892 3492 +600
Lines 201001 232268 +31267
Branches 26189 32768 +6579
==========================================================
+ Hits 153776 181336 +27560
- Misses 38765 41432 +2667
- Partials 8460 9500 +1040 ☔ View full report in Codecov by Sentry. |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
Closed PR due to inactivity for more than 18 days. |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
Closed PR due to inactivity for more than 18 days. |
BIRPackage.importModules
containing duplicate elementsBIRPackage.importModules
containing duplicate elements
90b8860
into
ballerina-platform:dedup-birpkg-imports
Purpose
Fixes #42343
Approach
Restricted the addition of duplicate elements by the usage of a HashSet instead of an ArrayList and setting up the necessary
equals()
andhashCode()
functions for theBIRImportModule
class. This will filter the duplicate imports after the BIR Gen phase.Samples
Remarks
The root cause of the duplicate imports is in the AST level. The duplicate imports originally derive from the
import
statements in.bal
files. Since a ballerina project can have more than one.bal
file it produces more than oneBLangImportPackage
.These AST level imports are used by the DataflowAnalyzer to detect unused imports. Therefore duplicates are needed in AST level.
Due to above reasoning, the safe choice is to omit them during the BIR Gen phase.
Check List