I’m on Idea 14.1.1 build #IC141.178 developing cross interfaces between Java and Scala (this is a Java 8 syntax check issue, so please don’t send me to the Scala forum). Oracle jdk1.8.0_45 and Scala 2.11.6. We’re trying to provide an API call wrapper into the Scala library passing a lambda.
Lets start with the problem display:
Image:Screen Shot 2015-04-21 at 3.35.21 PM.png
There are two signatures of execDAL in the class hierarchy. One is using Scala's Function0. Since Java lambdas are not yet compatible with Scala Function0 - hopefully will be fixed by Scala 2.12, one choice is to wrap it with the Scala compat function func(). This is OK for general use. But as a library developer, we want to provide a better experience. So we subclass and provide the same method taking a DALFunction as input. Here is the DALFunction:
public interface DALFunction new TestDO());
However, the code compiles and runs just fine without the cast. The compiler does not even give out any warning pointing to confusion. It is clear to the compiler that Function0 is not a Java8 @FunctionalInterface, although it looks similar to one. But IntelliJ seems to not be able to segregate between the two.
Original message URL: https://devnet.jetbrains.com/message/5540321#5540321