static interface methods: forbid on instance members, inheritors (IDEA-107794)

This commit is contained in:
Anna Kozlova
2013-05-30 15:46:53 +04:00
parent ed52a33e87
commit fb8144344c
4 changed files with 41 additions and 0 deletions
@@ -0,0 +1,25 @@
class Bug {
interface Function<T, R> {
public R apply(T t);
static <K> Function<K, K> identity() {
return k -> k;
}
}
interface IFunction extends Function<Integer, Integer> {
static void a() {
Function<Integer, Integer> identity = <error descr="Static method may be invoked on containing interface class only">identity();</error>
}
}
public void foo() {
Function<Integer, Integer> f = Function.identity();
Function<Integer, Integer> g = <error descr="Static method may be invoked on containing interface class only">f.identity();</error>
Function<Integer, Integer> h = <error descr="Static method may be invoked on containing interface class only">IFunction.identity();</error>
}
}