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: Pattern can match a Type #2555

Merged
merged 2 commits into from
Sep 27, 2018
Merged

Conversation

pvojtechovsky
Copy link
Collaborator

During writing test for #2530, I tried to make Pattern which matches whole type and have found that it doesn't work.

Reason: AST of type consists of at least 2 related parameters:

  1. String CtType#simpleName - in the name of the type
  2. CtTypeReference qualifiedName - in each self reference to the type

Until this PR Pattern made only one parameter with type CtTypeReference. It was ok as long as Pattern is used for generating of types, because generator is able to convert CtTypeReference to String simpleName.

But when we match such Pattern, it doesn't work/matches because there is no way how to create CtTypeReference (with fully qualified name) from the simple name of the type.

This PR contains solution which introduces new internal ParameterInfo ... ComputedParameterInfo, whose value is computed from primary parameter info. The computation algorithm is defined by interface ParameterComputer. There is also first implementation of that ParameterComputer interface: SimpleNameOfTypeReferenceParameterComputer, which returns simple name of CtTypeReference and during matching ignores simple type name, so type matching works.

@monperrus monperrus merged commit a1e8ee9 into INRIA:master Sep 27, 2018
@pvojtechovsky pvojtechovsky deleted the fixPatterMatchType branch September 27, 2018 17:35
@monperrus monperrus mentioned this pull request Oct 10, 2018
4 tasks
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