Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@joaobispo
Copy link
Member

Temporary pull request for experiment with join point hierarchy just to show a possibility, and that it passes the tests

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the CxxUnaryOp class to extend directly from CxxOp instead of wrapping an AOp instance, and similarly updates the abstract AUnaryOp class to extend from CxxOp rather than AOp. This simplifies the join point hierarchy by removing an unnecessary delegation layer.

Key Changes:

  • Simplified inheritance structure by extending CxxOp directly
  • Removed instance field and delegation pattern in favor of direct method calls
  • Updated method implementations to use getNode() instead of storing a field reference

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
CxxUnaryOp.java Refactored to extend from parent's node storage instead of maintaining a separate field; updated method implementations to call getNode()
AUnaryOp.java Changed from wrapping AOp to directly extending CxxOp, removing hundreds of lines of delegation code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

private final UnaryOperator unaryOp;
public class CxxUnaryOp extends AUnaryOp {

public CxxUnaryOp(UnaryOperator unaryOp) {
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The constructor accepts UnaryOperator but passes it to a parent constructor expecting Operator. While UnaryOperator likely extends Operator, the type signature is misleading. Consider updating the constructor parameter type to match the parent constructor's expected type for clarity.

Suggested change
public CxxUnaryOp(UnaryOperator unaryOp) {
public CxxUnaryOp(pt.up.fe.specs.clava.ast.expr.Operator unaryOp) {

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +28
public AUnaryOp(ClavaNode op) {
super((Operator) op);
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The constructor accepts ClavaNode but immediately casts it to Operator when calling the parent constructor. This introduces an unsafe cast that could fail at runtime if a non-Operator ClavaNode is passed. Consider changing the parameter type to Operator to make the type requirement explicit and move the type safety check to compile time.

Suggested change
public AUnaryOp(ClavaNode op) {
super((Operator) op);
public AUnaryOp(Operator op) {
super(op);

Copilot uses AI. Check for mistakes.
@lm-sousa lm-sousa marked this pull request as draft November 14, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants