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: feat: Add support to Java 10 'var' keyword #2054

Merged
merged 37 commits into from
Jun 21, 2018

Conversation

surli
Copy link
Collaborator

@surli surli commented Jun 11, 2018

This PR add the support to Java 10 var keyword for local type inference.

@surli surli changed the title WiP: feat: Add support to Java 10 'var' keyword review: feat: Add support to Java 10 'var' keyword Jun 15, 2018
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.

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;
Copy link
Collaborator

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) {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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);
Copy link
Collaborator

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?

Copy link
Collaborator Author

@surli surli Jun 18, 2018

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.

@spoon-bot
Copy link
Collaborator

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

Method was added to an interface.
Old none
New method CtLocalVariable#isInferred()
Breaking binary: non_breaking,
Method was added to an interface.
Old none
New method CtLocalVariable#setInferred(boolean)
Breaking binary: non_breaking,

@surli surli mentioned this pull request Jun 20, 2018
@monperrus monperrus merged commit 8350c88 into INRIA:master Jun 21, 2018
@monperrus
Copy link
Collaborator

That's great, thanks Simon!

@surli surli mentioned this pull request Jun 21, 2018
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