Skip to content

Conversation

@lm-sousa
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings January 18, 2026 22:54
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 adds a copy constructor to the BiFunctionClassMap class to support creating independent copies of map instances. The change enables creating a new map with all mappings from an existing map while maintaining full independence.

Changes:

  • Added a copy constructor to BiFunctionClassMap that creates a deep copy of the map and its internal ClassMapper
  • Added comprehensive test coverage for the new copy constructor including edge cases, independence verification, and hierarchy resolution
  • Updated GitHub Actions workflow to use actions/checkout@v6

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
SpecsUtils/src/pt/up/fe/specs/util/classmap/BiFunctionClassMap.java Adds copy constructor with covariant return type support, including deep copying of internal map and ClassMapper
SpecsUtils/test/pt/up/fe/specs/util/classmap/BiFunctionClassMapTest.java Adds 8 comprehensive test cases covering copy constructor behavior, independence, hierarchy resolution, and edge cases
.github/workflows/nightly.yml Updates checkout action from v4 to v6

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

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

Comment on lines +44 to +50
public <ER extends R> BiFunctionClassMap(BiFunctionClassMap<T, U, ER> other) {
this.map = new HashMap<>();
for (var keyPair : other.map.entrySet()) {
this.map.put(keyPair.getKey(), (BiFunction<T, U, R>) keyPair.getValue());
}
this.classMapper = new ClassMapper(other.classMapper);
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The copy constructor is missing Javadoc documentation. Please add documentation that explains:

  • The purpose of this constructor (creating a deep copy of another BiFunctionClassMap)
  • The generic type parameter ER and its constraint (ER extends R, allowing covariant copying)
  • The behavior regarding independence of the copy (changes to either map don't affect the other)
  • Example usage if appropriate

This would align with the documentation style of other constructors and methods in the class.

Copilot uses AI. Check for mistakes.
public <ER extends R> BiFunctionClassMap(BiFunctionClassMap<T, U, ER> other) {
this.map = new HashMap<>();
for (var keyPair : other.map.entrySet()) {
this.map.put(keyPair.getKey(), (BiFunction<T, U, R>) keyPair.getValue());
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The unchecked cast on line 47 should be documented with a @SuppressWarnings annotation to clarify why it's safe. The cast is necessary because of Java's generic type system limitations with wildcards, but it's safe because ER extends R, ensuring type compatibility. Consider adding @SuppressWarnings("unchecked") to the constructor method signature, similar to how it's used in the get() methods in this class (lines 71 and 87).

Copilot uses AI. Check for mistakes.
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