mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
invocation type inference: when unchecked conversion was performed - treat its results in return value checks as they were in bounds
This commit is contained in:
+1
-1
@@ -333,7 +333,7 @@ public class InferenceSession {
|
||||
final InferenceVariable inferenceVariable = getInferenceVariable(returnType);
|
||||
if (inferenceVariable != null) {
|
||||
if (targetType instanceof PsiPrimitiveType && hasPrimitiveWrapperBound(inferenceVariable) ||
|
||||
targetType instanceof PsiClassType && hasUncheckedBounds(inferenceVariable, (PsiClassType)targetType)) {
|
||||
targetType instanceof PsiClassType && (hasUncheckedBounds(inferenceVariable, (PsiClassType)targetType) || myErased)) {
|
||||
return inferenceVariable;
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
public class Sample {
|
||||
interface G<A> {}
|
||||
interface G1 extends G {}
|
||||
void foo(G1 g1) {
|
||||
bar(g1);
|
||||
}
|
||||
<B> B bar(G<B> gb) {return null;}
|
||||
|
||||
void f(G1 g1) {
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'Sample.G<java.lang.String>'">G<String> l11 = bar(g1);</error>
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">String l1 = bar(g1);</error>
|
||||
Object o = bar(g1);
|
||||
}
|
||||
}
|
||||
+4
@@ -46,6 +46,10 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testUncheckedBoundsWithErasure() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) {
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user