Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep track of declaring type for nested field accesses #5408

Merged
merged 5 commits into from
Aug 30, 2023

Conversation

SirYwell
Copy link
Collaborator

@SirYwell SirYwell commented Aug 28, 2023

Previously, nested field access led to null type references in case of array.length accesses. Passing the actual declaring type fixes that.

Fixes #5199

This commit enhances readability by restructuring how the input resource 'Example' class is added in the 'testArrayLengthDeclaringTypeNested' method within FieldTest. The addition process is now within a single method call to 'addInputResource', improving code clarity and maintainability without altering functionality.
This commit addresses a potential null pointer exception in JDTTreeBuilderHelper.java. It occurred due to 'no classpath mode' which may cause variable 'b' to be null. By adding a null check, it ensures 'b' is not null before accessing its properties, increasing the stability of the program.
Added @nullable annotation to two functions in ReferenceBuilder.java and JDTTreeBuilderHelper.java. These functions are getVariableReference() in ReferenceBuilder and declaringType variable in JDTTreeBuilderHelper. The Nullable annotation is useful as the TypeBinding parameter can at times be null, particularly when running the program in 'no classpath' mode. This reduces the risk of throwing a null pointer exception and increases overall code robustness.
Disabled the AssignmentToNull check in qodana.yaml due to its lack of support for nullability annotations. Commented out the line to maintain code clarity for future reference. This change enhances program performance when running in 'no classpath' mode and prevents potential NullPointerException. It contributes to the overall robustness of the code.
@SirYwell SirYwell marked this pull request as ready for review August 29, 2023 14:26
@I-Al-Istannen I-Al-Istannen merged commit ec757f7 into INRIA:master Aug 30, 2023
11 checks passed
@SirYwell SirYwell deleted the fix/nested-array-length-access branch August 30, 2023 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants