Skip to content

Make resolution of implements and extends types start with the parent…#4430

Merged
jlerbsc merged 3 commits intojavaparser:masterfrom
apiiro:fix-4427-resolution-of-extends-and-implements
May 22, 2024
Merged

Make resolution of implements and extends types start with the parent…#4430
jlerbsc merged 3 commits intojavaparser:masterfrom
apiiro:fix-4427-resolution-of-extends-and-implements

Conversation

@eldapiiro
Copy link
Copy Markdown
Contributor

… context of the class.

Fixes #4427.

className = classOrInterfaceType.getScope().get().toString() + "." + className;
}
SymbolReference<ResolvedTypeDeclaration> ref = solveType(className);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please comment on why, at this stage, type resolution should be delegated to the parent context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

toReferenceType is used to resolve reference to "extends" and "implements" types. These types should not be resolved against e.g types with the same name defined within the class.
As per the test case I included --

class A extends B { 
static class B ... {} 
}

The B in "extends B" should not resolve to the B in "static class B"... Hence we should resolve based on the context containing the class.. Does this make sense?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I meant adding comments to the code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added, thanks

@jlerbsc jlerbsc merged commit 1009e8e into javaparser:master May 22, 2024
@jlerbsc jlerbsc added this to the next release milestone May 22, 2024
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label May 22, 2024
@jlerbsc jlerbsc changed the title Make resoltuion of implements and extends types start with the parent… Make resolution of implements and extends types start with the parent… May 22, 2024
@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented May 22, 2024

Thank you for this contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect resolution of extends and implements types

2 participants