As stated by this blog, we are now able to write the following using local type inference (something, to my knowledge, that was previously impossible without introducing more code):
public static void main(String... args) {
var duck = (Quacks & Waddles) Mixin::create;
duck.quack();
duck.waddle();
}
interface Quacks extends Mixin {
default void quack() {
System.out.println("Quack");
}
}
interface Waddles extends Mixin {
default void waddle() {
System.out.println("Waddle");
}
}
interface Mixin {
void __noop__();
static void create() {}
}
This question may be either too broad or primarily opinion-based, but do there exist any useful applications when taking advantage of intersection types like this?