mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[java-incomplete-model] Assume that any unresolved class-type is assignable to java.lang.Object
Partially improves inference in incomplete mode GitOrigin-RevId: 1d9c7c75afd524ea02980be8f96c19fba1eaaf54
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5835df8dd6
commit
838cf2d73c
@@ -985,8 +985,7 @@ public final class TypeConversionUtil {
|
||||
PsiClass leftResultElement = leftResult.getElement();
|
||||
PsiClass rightResultElement = rightResult.getElement();
|
||||
if (leftResultElement == null || rightResultElement == null) {
|
||||
if (leftResultElement == null && rightResultElement != null &&
|
||||
left instanceof PsiClassType && left.equalsToText(JAVA_LANG_OBJECT)) {
|
||||
if (left instanceof PsiClassType && left.equalsToText(JAVA_LANG_OBJECT)) {
|
||||
return true;
|
||||
}
|
||||
if (leftResultElement != rightResultElement) return false;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
public class SomeClass {
|
||||
|
||||
{
|
||||
java.util.List<Unresolved> l;
|
||||
Unresolved[] a = l.toArray((Unresolved[]) <caret>expr);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,10 @@ import java.util.*;
|
||||
import <info descr="Not resolved until the project is fully loaded">foo</info>.<info descr="Not resolved until the project is fully loaded">bar</info>.<info descr="Not resolved until the project is fully loaded">baz</info>.*;
|
||||
|
||||
class Test {
|
||||
void testDiamond() {
|
||||
List<<info descr="Not resolved until the project is fully loaded">X</info>> list = new ArrayList<>();
|
||||
}
|
||||
|
||||
void test() {
|
||||
List<String> data = new ArrayList<>(
|
||||
Arrays.asList(<info descr="Not resolved until the project is fully loaded">a</info>.<info descr="Not resolved until the project is fully loaded">X</info>, <info descr="Not resolved until the project is fully loaded">a</info>.<info descr="Not resolved until the project is fully loaded">Y</info>));
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// "Cast argument to 'Map<Foo, Bar>'" "true-preview"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void run(Foo single) {}
|
||||
void run(Map<Foo, Bar> map) {}
|
||||
|
||||
void test(Bar bar) {
|
||||
run((Map<Foo, Bar>) Collections.singletonMap(getFoo(), bar));
|
||||
}
|
||||
|
||||
native Foo getFoo();
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// "Cast argument to 'Map<Foo, Bar>'" "true-preview"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void run(Foo single) {}
|
||||
void run(Map<Foo, Bar> map) {}
|
||||
|
||||
void test(Bar bar) {
|
||||
run((Map<Foo, Bar>) Collections.singletonMap(getFoo(), bar));
|
||||
}
|
||||
|
||||
native Foo getFoo();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Cast argument to 'Map<Foo, Bar>'" "true-preview"
|
||||
// "Cast argument to 'Map<Foo, Bar>'" "false"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Cast argument to 'Map<Foo, Bar>'" "true-preview"
|
||||
// "Cast argument to 'Map<Foo, Bar>'" "false"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public class Test {
|
||||
public static void main(String[] args) {
|
||||
for (String module : args) {
|
||||
VirtualFile[] sourceRoots = foo(module);
|
||||
Arrays.stream(sourceRoots).forEach((VirtualFile sourceRoot) -> sourceRoot.substring());
|
||||
Arrays.stream(sourceRoots).forEach(sourceRoot -> sourceRoot.substring());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class Main {
|
||||
|
||||
// Unresolved reference
|
||||
void f(Collection<? extends Foo> c) {
|
||||
R treeSet = new TreeSet();
|
||||
TreeSet treeSet = new TreeSet();
|
||||
for (Foo foo : c) {
|
||||
treeSet.add(foo);
|
||||
}
|
||||
|
||||
@@ -353,7 +353,8 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testFilterInaccessibleConstructors() { doAntiTest(); }
|
||||
|
||||
public void testCastInToArrayCallWithUnresolvedType() { doAntiTest(); }
|
||||
@NeedsIndex.ForStandardLibrary(reason = "java.util.List")
|
||||
public void testCastInToArrayCallWithUnresolvedType() { doTest(false); }
|
||||
|
||||
@NeedsIndex.ForStandardLibrary
|
||||
public void testNoDuplicateEmptyList() {
|
||||
|
||||
@@ -309,7 +309,6 @@ public class TypeMigrationTest extends TypeMigrationTestBase {
|
||||
}
|
||||
|
||||
// Set<String> f; foo(AbstractSet<String> s){f = s} -> Set<Integer>f; foo(AbstractSet<Integer> s){f = s}
|
||||
// TODO: This test produces incorrect result since Java 8
|
||||
public void testT49() {
|
||||
doTestFieldType("f",
|
||||
myFactory.createTypeFromText("java.util.Set<B>", null));
|
||||
@@ -317,7 +316,6 @@ public class TypeMigrationTest extends TypeMigrationTestBase {
|
||||
|
||||
//captured wildcard: Set<? extends JComponent> s; Set<? extends JComponent> c1 = s; ->
|
||||
// Set<? extends JButton> s; Set<? extends JButton> c1 = s;
|
||||
// TODO: This test produces incorrect result since Java 8
|
||||
public void testT50() {
|
||||
doTestFieldType("c1",
|
||||
myFactory.createTypeFromText("java.util.Set<? extends JButton>", null));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Types:
|
||||
PsiField:f : java.util.Set<B>
|
||||
PsiParameter:s : java.util.AbstractSet<E>
|
||||
PsiParameter:s : java.util.AbstractSet<B>
|
||||
PsiReferenceExpression:f : java.util.Set<B>
|
||||
PsiReferenceExpression:s : java.util.AbstractSet<E>
|
||||
PsiReferenceExpression:s : java.util.AbstractSet<B>
|
||||
|
||||
Conversions:
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import java.util.*;
|
||||
class Test {
|
||||
Set<B> f;
|
||||
void foo(AbstractSet<E> s) {
|
||||
void foo(AbstractSet<B> s) {
|
||||
f = s;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Types:
|
||||
PsiField:c : java.util.Set<E>
|
||||
PsiField:c : java.util.Set<JButton>
|
||||
PsiField:c1 : java.util.Set<? extends JButton>
|
||||
PsiReferenceExpression:c : java.util.Set<E>
|
||||
PsiReferenceExpression:c : java.util.Set<JButton>
|
||||
|
||||
Conversions:
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import java.util.*;
|
||||
class Test {
|
||||
Set<E> c;
|
||||
Set<JButton> c;
|
||||
Set<? extends JButton> c1 = c;
|
||||
}
|
||||
@@ -25,4 +25,3 @@ this.i.intValue() -> $
|
||||
|
||||
New expression type changes:
|
||||
Fails:
|
||||
i->java.util.concurrent.atomic.LongAdder
|
||||
|
||||
@@ -60,7 +60,7 @@ class FooEnum {
|
||||
<error descr="Cannot assign 'Object[]' to 'E'">e</error> = new Object[0]
|
||||
<error descr="Cannot assign 'Closure<Void>' to 'E'">e</error> = { int a, int t -> println(a + t) }
|
||||
<error descr="Cannot assign 'Object' to 'E'">e</error> = s
|
||||
<error descr="Cannot return 'Matcher' from method returning 'Object'"><error descr="Cannot assign 'Matcher' to 'E'">e</error> = "aaa" =~ /aaa/</error>
|
||||
<error descr="Cannot assign 'Matcher' to 'E'">e</error> = "aaa" =~ /aaa/
|
||||
}
|
||||
|
||||
def enumVariable() {
|
||||
|
||||
Reference in New Issue
Block a user