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

add codes for tricky parameters #46

Merged
merged 25 commits into from
Nov 27, 2023

Conversation

LoiNguyenCS
Copy link
Collaborator

No description provided.

@LoiNguyenCS
Copy link
Collaborator Author

Professor,

This is the PR to deal with tricky parameters, which hopefully will fix issue #43.

This one feels a bit like going down a rabbit hole. I know it's usually better to split changes into different PRs, but doing that might take a lot of time for me. To make up for it, I've added more comments to explain things better.

Please take a look. Thank you.

@LoiNguyenCS LoiNguyenCS requested a review from kelloggm November 16, 2023 02:48
@kelloggm
Copy link
Collaborator

kelloggm commented Nov 16, 2023 via email

@LoiNguyenCS
Copy link
Collaborator Author

Professor,

I have found a cool visit method of JavaParser that can help us deal with those class types and type variables recursively. That is the visit method for ClassOrInterfaceType. There is a weird bug accompanying this method, so I have to add a check to workaround.

I have also deleted the visit method for import statements. I think it is unsafe to assume that if there is no jar paths, every class imported must be unsolved.

@LoiNguyenCS LoiNguyenCS requested a review from kelloggm November 19, 2023 19:40
String paraTypeFullName =
paraType.asReferenceType().getTypeDeclaration().get().getQualifiedName();
usedClass.add(paraTypeFullName);
for (ResolvedType typeVariable : paraType.asReferenceType().typeParametersValues()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Following the API, I'd name the loop variable typeParameterValue rather than typeVariable. (I also suggest changing the associated variables, like typeVariableFullName -> typeParameterValueFullName.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also concerned that this code might be overspecialized to the case where classes that have type parameters are used as parameters. Can you add a test case where the target method also defines the type variable in use, such as:

<T> void foo(List<T> list) { ... }

In particular, I'd like a test like this so that we can be certain that this code won't be triggered (creating a class named "T"!) in that case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No extraneous class is created, but Specimin does crash in this case, because it looks for the class T (i.e., a class with the type variable's name). I'll commit the test on this branch. (I don't think I'll have time to actually fix the bug right now, but maybe I'll do that in a bit.)

@kelloggm
Copy link
Collaborator

@LoiNguyenCS since you aren't feeling well, I'm going to address my own comments on this PR

@LoiNguyenCS
Copy link
Collaborator Author

Thank you, Professor. I appreciate it.

@kelloggm
Copy link
Collaborator

@LoiNguyenCS I think I've fixed the issues I found with this PR. You should look over my changes; some of them are fairly extensive (I needed to add additional plumbing to keep track of what type variables are in scope at each point). If you don't have any concerns, I think this can be merged.

Copy link
Collaborator

@kelloggm kelloggm left a comment

Choose a reason for hiding this comment

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

LGTM (I wrote a lot of the code)

@kelloggm
Copy link
Collaborator

@LoiNguyenCS I've addressed your comments. Please take another look when you have a chance.

Copy link
Collaborator Author

@LoiNguyenCS LoiNguyenCS left a comment

Choose a reason for hiding this comment

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

Professor,

This changes look good to me. I think the CI should be able to run successfully after we merge #51.

update newest update from main
@kelloggm
Copy link
Collaborator

@LoiNguyenCS CI is still failing (Checker Framework is complaining about signature checker errors - I'm guessing a bad interaction with the removal of signature annotations in #51).

@LoiNguyenCS
Copy link
Collaborator Author

Professor, it was a consequence of removing annotations. But it's pretty simple to fix.

@LoiNguyenCS
Copy link
Collaborator Author

Professor,

Somehow the Anonymous test and TypeVarSimple test are failing. I will try to figure out the problems.

@kelloggm
Copy link
Collaborator

Regarding the failures in the AnonymousClass test - have you pulled the changes from #52 into this branch? If not, we should do that (that might be what's responsible).

@LoiNguyenCS
Copy link
Collaborator Author

have you pulled the changes from #52 into this branch? If not, we should do that (that might be what's responsible).

Yes, Professor. I have merged newest updates from the main branch into this branch.

@LoiNguyenCS
Copy link
Collaborator Author

LoiNguyenCS commented Nov 27, 2023

I've addressed the bug in the TypeVarSimple test and the AnonymousClass test. The failure in the AnonymousClass test was due to a modification I made on this branch before we discussed the issue of flaky tests. At that time, I reordered the methods in the AnonymousClass class, thinking the issue was related to the visit methods rather than the HashSet.

@LoiNguyenCS LoiNguyenCS requested a review from kelloggm November 27, 2023 17:19
Copy link
Collaborator

@kelloggm kelloggm left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

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