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

Hint: “Convert Explicit Type to Var” shouldn’t be reported for method references or lambda expressions #3466

Closed
1 of 3 tasks
ExE-Boss opened this issue Jan 16, 2022 · 2 comments · Fixed by #3471
Labels
good first issue Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix
Milestone

Comments

@ExE-Boss
Copy link

ExE-Boss commented Jan 16, 2022

Apache NetBeans version

Latest release

What happened

Convert Explicit Type to Var is reported for method references and lambda expressions, e.g.:

final Consumer<String> println = System.out::println;

But it's invalid to replace the above with:

final var println = System.out::println;

which results in the compile error:

error: cannot infer type for local variable println
final var println = System.out::println;
          ^
  (method reference needs an explicit target-type)

How to reproduce

See above

Did this work correctly in an earlier version?

  • This used to work!

Operating System

Windows 10

JDK

OpenJDK Runtime Environment Temurin-17.0.1+12 (build 17.0.1+12)

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

  • Yes I am willing to submit a PR!

Code of Conduct

@ExE-Boss ExE-Boss added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Jan 16, 2022
@ExE-Boss ExE-Boss changed the title “Convert Explicit Type to Var” shouldn’t be reported for method references or lambda expressions Hint: “Convert Explicit Type to Var” shouldn’t be reported for method references or lambda expressions Jan 16, 2022
@mbien mbien added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Jan 16, 2022
@neilcsmith-net neilcsmith-net removed the needs:triage Requires attention from one of the committers label Jan 17, 2022
@neilcsmith-net
Copy link
Member

Thanks for the report. Can reproduce. Definitely a bug.

@mbien
Copy link
Member

mbien commented Jan 17, 2022

the hint is here:
https://github.com/apache/netbeans/blob/master/java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToVarHint.java

potentially easy to fix. But maybe someone else can do it since I don't use 'var' at all :)

adding the good-first-issue label.

@neilcsmith-net neilcsmith-net added this to the NB13 milestone Jan 19, 2022
neilcsmith-net added a commit that referenced this issue Jan 19, 2022
[#3466]  do not show Convert Type to Var hint for method references
@apache apache deleted a comment Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants