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

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

Merged

Conversation

eldapiiro
Copy link
Contributor

… context of the class.

Fixes #4427.

@@ -465,17 +465,23 @@ private ResolvedReferenceType toReferenceType(ClassOrInterfaceType classOrInterf
// look for the qualified name (for example class of type Rectangle2D.Double)
className = classOrInterfaceType.getScope().get().toString() + "." + className;
}
SymbolReference<ResolvedTypeDeclaration> ref = solveType(className);

Copy link
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
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
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
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
34 of 38 checks passed
@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
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