The following code does not compile:
import java.nio.file.*;
public final class _DiamondSyntaxErrors {
public interface InterfaceA<T> {
}
public abstract static class ClassA<T>
implements InterfaceA<T> {
protected ClassA() {
}
}
public static void main(String... args) {
// no error
InterfaceA<Path> classA = new ClassA<>() {
};
// error: cannot infer type arguments for SimpleFileVisitor<>
FileVisitor<Path> visitor = new SimpleFileVisitor<>() {
};
}
}
Javac prints the following output:
Test.java:5: cannot infer type arguments for SimpleFileVisitor<>
FileVisitor<Path> visitor = new SimpleFileVisitor<>() {
^
1 error