Reputation: 671
Consider the following code I attached as an image:
The code does an infinite loop but that's not the point. The point is that if I make the recursion inside a for
loop then IDEA can show that at the left with a sign.
If I make the recursion inside a forEach
lambda expression then there are no sign.
It would be much comfortable if it can be shown in both cases. Is it a bug, or is there any reason for that?
Upvotes: 1
Views: 1421
Reputation: 97268
As correctly noted by @Jesper in his comment, not every lambda is called synchronously from the function to which it is passed as a parameter. Imagine that the function used in the example was invokeLater
and not forEach
.
Since IntelliJ is not aware of the semantics of specific library functions that take lambdas as parameters, it does not highlight recursive calls in any lambdas.
Upvotes: 1