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

review: refactor: SignaturePrinter prints type parameter bounds, no name #2410

Merged
merged 2 commits into from
Aug 29, 2018

Conversation

pvojtechovsky
Copy link
Collaborator

Signature shouldn't contain name of type parameter reference, because these three methods declarations:

<T extends String> void m(T a);
<S extends String> void m(S b);
void m(String c)

Should have the same signature: m(String)

WDYT?

@pvojtechovsky pvojtechovsky changed the title WiP: refactor: SignaturePrinter prints type parameter bounds, no name review: refactor: SignaturePrinter prints type parameter bounds, no name Aug 27, 2018
@surli
Copy link
Collaborator

surli commented Aug 27, 2018

What if the type parameter is defined at the class level? Such as:

class Foo<T> {
 void m(T a);
}

or

class Bar<T extends String> {
 void m(T a);
}

@pvojtechovsky
Copy link
Collaborator Author

What if the type parameter is defined at the class level?

It should be same - the super class of the type parameter should be used.

@surli
Copy link
Collaborator

surli commented Aug 27, 2018

It should be same - the super class of the type parameter should be used.

But in case of Foo you don't know that T extends String... So it would be:
m(Object) or m(T)?

@pvojtechovsky
Copy link
Collaborator Author

in case of

class Foo<T> {
 void m(T a);
}

m has signature m(Object)

Copy link
Collaborator

@monperrus monperrus left a comment

Choose a reason for hiding this comment

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

OK for me. Thanks Pavel.

@pvojtechovsky
Copy link
Collaborator Author

I see now, more cases, which are probably not handled well too.

<T extends List<String>> void m(T a);
<T extends List<Integer>> void m(T b);
<T extends List> void m(T c);
void m(List<String> d);
void m(List<?> e);
void m(List f);

all of them should have same signature: m(List)

WDYT?

If you agree than we should use CtTypeReference#getTypeErasure() during signature printing too. May be it is task for another small PR.

@surli
Copy link
Collaborator

surli commented Aug 29, 2018

I'm ok with the other changes you propose. For me they could be implemented in the same PR or in another one, as you prefer.

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

Successfully merging this pull request may close these issues.

3 participants