I have a very similar problem as described in this unanswered question: Nested lambda expressions lead to warning in Eclipse Luna
I am using Eclipse Luna (Service Release 1, 4.4.1) with Windows 7 and Java 8 (jdk 1.8.0_05). The following ( edited ) code:
Collections.sort(new LinkedList<>(), (c1, c2) -> { return c1.equals(c2)? 1 : 0; });
gives a warning:
(Recovered) Internal inconsistency detected during lambda shape analysis
A warning is assigned to this part of the code: "(c1, c2) →".
Note : interestingly, the shorter version omitting the return statement compiles without any warning:
Collections.sort(new LinkedList<>(), (c1, c2) -> c1.equals(c2)? 1 : 0);
The same is true for this code, where types c1 and c2 are explicitly specified
Collections.sort(new LinkedList<>(), (Object c1, Object c2) -> { return c1.equals(c2)? 1 : 0; });
What's going on here? (I do not think this suggestion is error: https://bugs.eclipse.org/bugs/show_bug.cgi?id=432110 (this comment in the corresponding question) has any help, since the warning occurs in the context of the error.)
EDIT: The above code is MWE, the source code that caused the problem is as follows:
Collections.sort(list, (c1, c2) -> { Method m1 = this.allMethods.get(c1); Method m2 = this.allMethods.get(c2); int c = new Integer(m1.getParameterCount()).compareTo( new Integer(m2.getParameterCount())); if (c == 0) { Integer i1 = 0; Integer i2 = 0; if (ConstructorFactory.isTypeAcceptable(m1.getReturnType())) { i1 = 1; } if (ConstructorFactory.isTypeAcceptable(m2.getReturnType())) { i2 = 1; } c = i1.compareTo(i2); } if (c == 0) { c = m1.getName().compareTo(m2.getName()); } return c; });
EDIT 2: Eclipse Kepler did NOT display this warning (same version of Java).