-
-
Notifications
You must be signed in to change notification settings - Fork 351
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: feat: Add support to Java 10 'var' keyword #2054
Conversation
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.
LGTM. That's really great you put some effort on the Java 10 support.
See my minor comments.
@@ -101,7 +101,8 @@ | |||
OPENED_PACKAGE(MODULE_DIRECTIVE), | |||
SERVICE_TYPE(MODULE_DIRECTIVE), | |||
IMPLEMENTATION_TYPE, | |||
PROVIDED_SERVICE(MODULE_DIRECTIVE); | |||
PROVIDED_SERVICE(MODULE_DIRECTIVE), | |||
INFERRED_VARIABLE; |
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 propose to name it IS_INFERRED
@@ -158,6 +161,18 @@ private boolean isNotCandidate(CtMethod<?> candidate) { | |||
|| notCandidates.contains(candidate.getDeclaringType().getSimpleName() + "#" + candidate.getSimpleName()); | |||
} | |||
|
|||
private boolean hasPrimitiveTypeForParameters(List<CtParameter<?>> parameters) { |
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 don't see the relation with this PR. Why was it working before?
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'm not sure. I suspect that on almost all other setters we were not using primitive types. I can extract it in another PR if you want: the relation here is that it fix a broken test resulting by the new setter.
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.
Bizarre. We have plenty of other setters with boolean (eg setImplicit, setShadow, etc). It would be much better to understand what happens here.
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'll have a look
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.
Good thing you insisted on that one: I forgot to call the model change listener... I updated the contract here because it was not clear enough.
@@ -749,6 +749,7 @@ public void testDocumentationContract() throws Exception { | |||
final Launcher launcher = new Launcher(); | |||
launcher.getEnvironment().setNoClasspath(true); | |||
launcher.getEnvironment().setCommentEnabled(true); | |||
launcher.getEnvironment().setComplianceLevel(10); |
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 is this required here?
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 added a new documentation snippet in CtLocalVariable with the following code:
var x = 10;
This won't compile if I do not use a compliance level to 10.
API changes: 2 (Detected by Revapi) Old API: fr.inria.gforge.spoon:spoon-core:jar:6.3.0-20180619.225448-155 / New API: fr.inria.gforge.spoon:spoon-core:jar:6.3.0-SNAPSHOT
|
That's great, thanks Simon! |
This PR add the support to Java 10
var
keyword for local type inference.