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

feat: add support for analyzing whether a type reference is generic or not (method isGeneric) #1562

Merged
merged 2 commits into from
Sep 29, 2017

Conversation

monperrus
Copy link
Collaborator

No description provided.

@spoon-bot
Copy link
Collaborator

Revapi Analysis results

Old API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-20170926.224458-46

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

Detected changes: 1.

Change 1

Name Element
Old none
New method boolean spoon.reflect.reference.CtTypeReference::isGeneric()
Code java.method.addedToInterface
Description Method was added to an interface.
Breaking binary: non_breaking,

@pvojtechovsky
Copy link
Collaborator

Hi Martin, there is already CtTypeInformation#isGenerics() with similar contract. May be we should implement your new method as CtTypeInformation#isGenerics(boolean recursive) ... or at least use more expressive name, because actually there are

  • boolean isGenerics()
  • boolean isGeneric()

with different behavior

@monperrus
Copy link
Collaborator Author

You're right thanks.

For now, I propose to keep this new behavior, and to reuse the existing signature.
This new behavior subsumes the older and also enables to know whether a type can be instantiated or not. In
particular, it makes it possible to test and enforce an interesting contract.

typeRef.isGenerics() == false <=> typeRef.getSignature()== typeRef.getDeclaration().getSignature()

WDYT?

@pvojtechovsky
Copy link
Collaborator

For now, I propose to keep this new behavior, and to reuse the existing signature.

do you mean to change behavior of isGenerics()?

I checked how this method is used in spoon and it is only needed in two tests.
It is OK for me to change this behavior.

What about adding another method isParametrized(), with this contract

Type isParametrized() isGenerics()
Integer false false
List<Integer> true false
List<T> true true

At the beginning I had problem to understand your change because I understood the behavior as isParametrized

@monperrus
Copy link
Collaborator Author

It is OK for me to change this behavior.

Cool, then we may merge.

What about adding another method isParametrized(), with this contract

Good idea! #1565

@pvojtechovsky pvojtechovsky merged commit c6bb2ec into INRIA:master Sep 29, 2017
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