mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 14:25:04 +07:00
bad code green: reject return type constraint if unchecked conversion was applied during applicability check and return type is type parameter
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Foo<T extends Enum> {
|
||||
public T bar(Class<? extends T> type, String str) {
|
||||
<error descr="Incompatible types. Found: 'java.lang.Enum', required: 'T'">return Enum.valueOf(type, str);</error>
|
||||
return Enum.valueOf(<error descr="'valueOf(java.lang.Class<T>, java.lang.String)' in 'java.lang.Enum' cannot be applied to '(java.lang.Class<capture<? extends T>>, java.lang.String)'">type</error>, str);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ abstract class Group {
|
||||
}
|
||||
|
||||
public <T extends Category> T get(Key<T> key) {
|
||||
<error descr="Incompatible types. Found: 'Category', required: 'T'">return getCategory(key);</error>
|
||||
return getCategory<error descr="'getCategory(Key<R>)' in 'Group' cannot be applied to '(Key<T>)'">(key)</error>;
|
||||
}
|
||||
|
||||
public abstract <R extends Category<R>> R getCategory(Key<R> key);
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.List;
|
||||
|
||||
class Test {
|
||||
<T> T foo(List<T> l) {
|
||||
return l.get(0);
|
||||
}
|
||||
|
||||
void m(List l){
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'boolean'">boolean foo = foo(l);</error>
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">String s = foo(l);</error>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user