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

Replace duplicate symbol in owner #41737

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
import org.wso2.ballerinalang.compiler.semantics.model.Scope;
import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttachmentSymbol;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAttachedFunction;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.BObjectTypeSymbol;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.BOperatorSymbol;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructureTypeSymbol;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol;
import org.wso2.ballerinalang.compiler.semantics.model.symbols.Symbols;
Expand Down Expand Up @@ -852,6 +854,16 @@ public static BInvokableSymbol duplicateInvokableSymbol(BInvokableSymbol invokab
dupFuncSymbol.type = dupInvokableType;
dupFuncSymbol.dependentGlobalVars = invokableSymbol.dependentGlobalVars;

if (!Symbols.isFlagOn(invokableSymbol.flags, Flags.ATTACHED)) {
return dupFuncSymbol;
}
List<BAttachedFunction> attachedFuncs = ((BStructureTypeSymbol) invokableSymbol.owner).attachedFuncs;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this modifies the BIR. maybe we should add a BIR test case to verify this.

for (BAttachedFunction attachedFunc : attachedFuncs) {
if (attachedFunc.symbol == invokableSymbol) {
attachedFunc.symbol = dupFuncSymbol;
break;
}
}
return dupFuncSymbol;
}

Expand Down
Loading