-
-
Notifications
You must be signed in to change notification settings - Fork 349
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: fix PotentialVariableDeclarationFunction ignoring the static scope #1536
review: fix PotentialVariableDeclarationFunction ignoring the static scope #1536
Conversation
74b7293
to
794ae41
Compare
This PR is now based on #1541 because it was needed to debug problem of The implementation of this PR fixes two more problems
This PR is finished from my point of view too. |
@@ -19,7 +19,7 @@ public void spoonMavenLauncherTest() { | |||
// with the tests | |||
launcher = new MavenLauncher("./", MavenLauncher.SOURCE_TYPE.ALL_SOURCE); | |||
// 235 because of the sub folders of src/main/java and src/test/java | |||
assertEquals(235, launcher.getModelBuilder().getInputSources().size()); | |||
assertEquals(236, launcher.getModelBuilder().getInputSources().size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can remove this assertion because it will be horrible to maintain.
@@ -883,16 +884,16 @@ public void testClassCastExceptionOnForEach() throws Exception { | |||
{ | |||
Context context = new Context(); | |||
//contract: if the query produces elements which cannot be cast to forEach consumer, then they are ignored | |||
launcher.getFactory().Package().getRootPackage().filterChildren(f->{return true;}).forEach((CtType t)->{ | |||
launcher.getFactory().Package().getRootPackage().filterChildren(null).forEach((CtType t)->{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need to change this contract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not change. It is just shorter way how write the same: "no filter = return all children"
try { | ||
launcher.getFactory().Package().getRootPackage().filterChildren(f->{return true;}).forEach((CtType t)->{ | ||
launcher.getFactory().Package().getRootPackage().filterChildren(null).forEach((CtType t)->{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question
@@ -177,6 +178,9 @@ public void scan(CtElement element) { | |||
if (reference.getParameters().get(i) instanceof CtArrayTypeReference && ((CtArrayTypeReference) reference.getParameters().get(i)).getComponentType() instanceof CtTypeParameterReference) { | |||
continue; | |||
} | |||
if (executableDeclaration instanceof CtLambda) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a comment line to explain why we can not make the assertion for Lambdas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know whether we cannot make assertions about lambdas. Lambdas are too different (comparing to method) and they are not supported yet by this test. So may be there is necessary to write lambda specific assertion. But I did not understood the purpose of this test, so I would rather let You to fix it.
looks good, commented with minor questions. |
Or we can have something like
launcher.getModelBuilder().getInputSources().size() >= 230
|
edd126e
to
6565a07
Compare
I have removed commits which belongs to #1541, so this PR is simpler now. The minor problems were fixed. So it can be merged |
As reported in #1513 the
PotentialVariableDeclarationFunction
returns non static fieldtest
as potential variable declaration of local variable reference declared in static method.