#Why isn't intellij suggesting to replace a lambda expression with method reference?

16 messages · Page 1 of 1 (latest)

crimson timber
earnest furnaceBOT
#

This post has been reserved for your question.

Hey @crimson timber! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

crimson timber
#

Even thought it's valid syntax to use the method reference, i just don't get why it's not suggesting for line 1 to use a method reference like line 2

#

Line 1 and 2 do the exact same thing, only 2 uses the method reference and 1 is just a normal lambda

random frost
#

Are there 2 hasPermissions?

crimson timber
#

There's only 1 hasPermission function, and it takes 1 parameter which takes the same type as source

#

the where function is defined as <T> Linq<E> where(T param, BiFunction<E, T> func), the extra T parameter is only there as a tiny micro optimisation so that a lambda class isn't allocated in order to capture source

crimson timber
#

oh wait i think i figured it out...

#

there was 2 but one was static

#

and took a string as a 2nd parameter

#

so maybe it was ambiguous enough

random frost
pallid dawn
#

yes, the compiler needs proper inference in order to use a method reference, I had a discussion about this recently in another server

#

The rules about inference and variance in type parameters is quite intricate