Skip to content

Copilot/fix type hierarchy sorting#2779

Closed
carstenartur wants to merge 38 commits into
eclipse-jdt:masterfrom
carstenartur:copilot/fix-type-hierarchy-sorting
Closed

Copilot/fix type hierarchy sorting#2779
carstenartur wants to merge 38 commits into
eclipse-jdt:masterfrom
carstenartur:copilot/fix-type-hierarchy-sorting

Conversation

@carstenartur
Copy link
Copy Markdown
Contributor

@carstenartur carstenartur commented Feb 3, 2026

Implements a fix for issue #1865 to detect when moving a method would change which overloaded method gets called due to method resolution changes.

Problem

When moving a method to a class that has a superclass with a method of the same name but different parameter types, the refactoring could silently change which method gets called, leading to incorrect behavior.

Example from issue #1865:

  • Class A has m(Object)
  • Class B extends A
  • Class C has m(String) to be moved to B
  • In B.f(), the call m("1") currently resolves to A.m(Object)
  • After moving C.m(String) to B, the call would resolve to B.m(String) instead

This is a semantic change that should be detected and reported as an error.

Solution Implemented

Added a new check method checkOverloadResolutionChanges() in MoveInstanceMethodProcessor that:

  1. Examines the target type's hierarchy for methods with the same name as the method being moved
  2. Detects when parameter types differ (indicating potential overload resolution changes)
  3. Reports an error when such a conflict is found, preventing the refactoring
  4. Includes progress monitoring for large type hierarchies
  5. Provides proper error handling with warning messages if hierarchy analysis fails

Changes Made

  1. MoveInstanceMethodProcessor.java:

    • Added checkOverloadResolutionChanges() method with progress monitoring
    • Integrated the check into checkFinalConditions() with proper progress tracking
    • Added error handling for hierarchy analysis failures
  2. RefactoringCoreMessages.java & refactoring.properties:

    • Added error message: MoveInstanceMethodProcessor_overload_resolution_change
    • Added warning message: MoveInstanceMethodProcessor_hierarchy_not_available
  3. Test Resources:

The fix now correctly prevents the move method refactoring when it would change which overloaded method gets called, addressing the exact scenario described in issue #1865.

What it does

How to test

Author checklist

carstenartur and others added 30 commits October 14, 2025 22:06
* Bump codacy/codacy-analysis-cli-action from 1.1.0 to 4.4.0 (#19)

* Formaster3 (#20)

* Update maven.yml (#9)

* Formaster4 (#8)

* Create dependabot.yml

* Update dependabot.yml

* Update dependabot.yml

* Update dependabot.yml

* Create codacy.yml

* Update pom.xml

* Bump tycho.version from 2.3.0 to 2.7.3

Bumps `tycho.version` from 2.3.0 to 2.7.3.

Updates `tycho-surefire-plugin` from 2.3.0 to 2.7.3

Updates `tycho-source-plugin` from 2.3.0 to 2.7.3
- [Release notes](https://github.com/eclipse/tycho/releases)
- [Changelog](https://github.com/eclipse/tycho/blob/master/RELEASE_NOTES.md)
- [Commits](eclipse-tycho/tycho@tycho-2.3.0...tycho-2.7.3)

Updates `tycho-p2-plugin` from 2.3.0 to 2.7.3

---
updated-dependencies:
- dependency-name: org.eclipse.tycho:tycho-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.eclipse.tycho:tycho-source-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.eclipse.tycho:tycho-p2-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Create codeql.yml

* Create maven.yml

* Update README.md

* Update README.md

* Update README.md

* Bump tycho.version from 2.7.3 to 2.7.4

Bumps `tycho.version` from 2.7.3 to 2.7.4.

Updates `tycho-surefire-plugin` from 2.7.3 to 2.7.4

Updates `tycho-source-plugin` from 2.7.3 to 2.7.4
- [Release notes](https://github.com/eclipse/tycho/releases)
- [Changelog](https://github.com/eclipse/tycho/blob/tycho-2.7.4/RELEASE_NOTES.md)
- [Commits](eclipse-tycho/tycho@tycho-2.7.3...tycho-2.7.4)

Updates `tycho-p2-plugin` from 2.7.3 to 2.7.4

---
updated-dependencies:
- dependency-name: org.eclipse.tycho:tycho-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.eclipse.tycho:tycho-source-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.eclipse.tycho:tycho-p2-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump tycho.version from 2.7.4 to 2.7.5

Bumps `tycho.version` from 2.7.4 to 2.7.5.

Updates `tycho-surefire-plugin` from 2.7.4 to 2.7.5

Updates `tycho-source-plugin` from 2.7.4 to 2.7.5
- [Release notes](https://github.com/eclipse/tycho/releases)
- [Changelog](https://github.com/eclipse-tycho/tycho/blob/tycho-2.7.5/RELEASE_NOTES.md)
- [Commits](eclipse-tycho/tycho@tycho-2.7.4...tycho-2.7.5)

Updates `tycho-p2-plugin` from 2.7.4 to 2.7.5

---
updated-dependencies:
- dependency-name: org.eclipse.tycho:tycho-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.eclipse.tycho:tycho-source-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.eclipse.tycho:tycho-p2-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update README.md

* Update maven.yml

* Update codeql.yml

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update dependabot.yml

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update maven.yml

* Update maven.yml (#10)

* Update maven.yml for java 20 (#11)

* Update codeql.yml (#12)

* Update maven.yml

* Update codeql.yml

* Update codeql.yml

* Bump actions/setup-java from 2 to 4 (#17)

Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2 to 4.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](actions/setup-java@v2...v4)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github/codeql-action from 2 to 3 (#16)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump codacy/codacy-analysis-cli-action from 1.1.0 to 4.3.0 (#15)

Bumps [codacy/codacy-analysis-cli-action](https://github.com/codacy/codacy-analysis-cli-action) from 1.1.0 to 4.3.0.
- [Release notes](https://github.com/codacy/codacy-analysis-cli-action/releases)
- [Commits](codacy/codacy-analysis-cli-action@d840f88...5cc54a7)

---
updated-dependencies:
- dependency-name: codacy/codacy-analysis-cli-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump cirrus-actions/rebase from 1.7 to 1.8 (#14)

Bumps [cirrus-actions/rebase](https://github.com/cirrus-actions/rebase) from 1.7 to 1.8.
- [Release notes](https://github.com/cirrus-actions/rebase/releases)
- [Commits](cirrus-actions/rebase@1.7...1.8)

---
updated-dependencies:
- dependency-name: cirrus-actions/rebase
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update codeql.yml

* Update codacy.yml

* Bump actions/checkout from 3 to 4 (#13)

* Update codacy.yml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump stCarolas/setup-maven from 4.5 to 5 (#22)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Copilot AI and others added 8 commits February 3, 2026 04:29
…pe enabled

Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
…d refactoring, not Type Hierarchy sorting

Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
…ing (issue eclipse-jdt#1865)

Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
… error handling

Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
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