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

review1: fix generic type adapting #1275

Merged
merged 2 commits into from
Apr 29, 2017

Conversation

pvojtechovsky
Copy link
Collaborator

@pvojtechovsky pvojtechovsky commented Apr 27, 2017

Here are fixed other bugs found during implementing of CtMethod#isOverriding(CtMethod).
Following problems are tested and fixed by this PR:

  • The generic types are now adapted recursive into actual type arguments. E.g. List<List<T>> is adapted to List<List<M>>
  • The generic types are now adapted recursive into their bounds. E.g. List<? extendsT> is adapted to List<? extends M>
  • The adapting of wildcard type E.g. List<? extendsT> does not fail with NullPointerException
  • The MethodTypingContext correctly detects isOverriding for child method whose generic types are replaced by concrete types.

@pvojtechovsky pvojtechovsky changed the title fix generic type adapting review1: fix generic type adapting Apr 27, 2017
@spoon-bot
Copy link
Collaborator

Revapi Analysis results

Old API: fr.inria.gforge.spoon:spoon-core:jar:5.7.0-20170427.191244-62

New API: fr.inria.gforge.spoon:spoon-core:jar:5.7.0-SNAPSHOT

Detected changes: 0.

/**
* Implements common adapting algorithm of {@link ClassTypingContext} and {@link MethodTypingContext}
*/
abstract class AbstractTypingContext implements GenericTypeAdapter {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the package visibility

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, it was intentional. This class is internal

return typeParamRefAdapted;
}

protected abstract CtTypeReference<?> adaptTypeParameter(CtTypeParameter typeParam);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the contract of implementors?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is not expected that any client will implement this method, because all possible implementations ClassTypingContext and MethodTypingContext are already done.
I have added this comment

	/**
	 * adapts `typeParam` to the {@link CtTypeReference}
	 * of scope of this {@link GenericTypeAdapter}
	 * In can be {@link CtTypeParameterReference} again - depending actual type arguments of this {@link GenericTypeAdapter}.
	 *
	 * @param typeParam to be resolved {@link CtTypeParameter}
	 * @return {@link CtTypeReference} or {@link CtTypeParameterReference} adapted to scope of this {@link GenericTypeAdapter}
	 *  or null if `typeParam` cannot be adapted to target `scope`
	 */

@spoon-bot
Copy link
Collaborator

Revapi Analysis results

Old API: fr.inria.gforge.spoon:spoon-core:jar:5.7.0-20170427.224507-63

New API: fr.inria.gforge.spoon:spoon-core:jar:5.7.0-SNAPSHOT

Detected changes: 0.

@monperrus monperrus merged commit f993132 into INRIA:master Apr 29, 2017
@monperrus
Copy link
Collaborator

thanks Pavel

@pvojtechovsky pvojtechovsky deleted the fixGenericTypeAdapting branch April 30, 2017 18:11
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.

3 participants