[Improvement]: Inconsistent resource method names generated for call instruction #43050
Labels
needTriage
The issue has to be inspected and labeled manually
Priority/High
Team/CompilerFE
All issues related to Language implementation and Compiler, this exclude run times.
Type/Improvement
userCategory/Compilation
Description
$subject
Describe your problem(s)
When compiling a ballerina resource method, we generate new method names with the class/object-type name prefix. This is updated in the function invocation symbol name and several other fields contain the method names such as the expression name, and invocation symbol
originalName
.But we only need the method name without the type name for the method call. Therefore we filter out the redundant parts during the
BIRGen
andCodeGen
phases.ballerina-lang/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java
Line 892 in 10fc965
ballerina-lang/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmCodeGenUtil.java
Line 426 in 10fc965
When I checked these name fields, the values they assigned were inconsistent for different use cases.
Note that, to filter out the function name from the function symbol name, we use the
receiverSymbol
at BIRGen and theselfArg
argument at CodeGen. This is because in some cases, the receiver symbol becomesnull
and the type can only be derived from the self-argument.We need to have a more consistent way of providing the name. If we have a field that contains only the method name without the type prefix, we can directly use it without any filtering. It is not recommended to use string processing in the method names as they are error-prone (the user-defined name can contain special characters.) and can slow down the compilation as well.
Please find the log file with possible type name combinations here.
objectTypeFunctions.log
Describe your solution(s)
No response
Related area
-> Compilation
Related issue(s) (optional)
#42988
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: