Skip to content

Fix Crubit issue where friend functions declared in a class and then redefined outside are not imported correctly.#793

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
test_893141473
Open

Fix Crubit issue where friend functions declared in a class and then redefined outside are not imported correctly.#793
copybara-service[bot] wants to merge 1 commit intomainfrom
test_893141473

Conversation

@copybara-service
Copy link
Copy Markdown

Fix Crubit issue where friend functions declared in a class and then redefined outside are not imported correctly.

Previously, Crubit would try to import these functions via FriendDeclImporter as children of the class, and might also skip them when processing the outside definition due to canonicalization rules.

This change:

  1. Skips importing friend declarations in FriendDeclImporter if they are redeclared outside the class.
  2. Modifies CanonicalizeDecl to prefer the outside definition as the canonical one if the first declaration was inside a record. This ensures it is imported as a top-level free function.

This ensures that friend functions redefined outside are imported as normal top-level free functions.

…redefined outside are not imported correctly.

Previously, Crubit would try to import these functions via FriendDeclImporter as children of the class, and might also skip them when processing the outside definition due to canonicalization rules.

This change:
1. Skips importing friend declarations in FriendDeclImporter if they are redeclared outside the class.
2. Modifies CanonicalizeDecl to prefer the outside definition as the canonical one if the first declaration was inside a record. This ensures it is imported as a top-level free function.

This ensures that friend functions redefined outside are imported as normal top-level free functions.

PiperOrigin-RevId: 893141473
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.

1 participant