Rework "MethodTree.isOverriding()" to match the contract in case of unknowns in hierarchy

Description

The Javadoc of MethodTree.isOverriding() states that the method returns
— true if overriding, null if it cannot be decided (method symbol not resolved or lack of byte code for super types), false if not overriding.

However, the current implementation returns misleading results when the hierarchy of the class containing the method contains unknowns. In such cases, null should be returned, because it is not possible to reliably determine if the method is an override or not.

In addition, we should also make sure that the different rules using this method correctly deal with the null value.

Activity

Quentin JaquierMay 31, 2021 at 3:53 PM

As a first step, I opened https://github.com/SonarSource/sonar-java/pull/3625 to make sure we are correctly dealing with null values, as this change will increase the probability of facing null.

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Due date

Priority

Sentry

Created May 31, 2021 at 3:29 PM
Updated October 16, 2024 at 2:11 PM
Resolved June 7, 2021 at 8:24 AM