[FIR] Bad test data fixes (around captured types)
This commit is contained in:
@@ -15,9 +15,9 @@ fun case_1(a: MutableList<out MutableList<MutableList<MutableList<MutableList<Mu
|
||||
if (f != null) {
|
||||
val g = f[0]
|
||||
if (g != null) {
|
||||
val h = g[0]
|
||||
val h = <!UNRESOLVED_REFERENCE!>g[0]<!>
|
||||
if (h != null) {
|
||||
h.inc()
|
||||
h.<!UNRESOLVED_REFERENCE!>inc<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,9 +43,9 @@ fun case_2(a: MutableList<out MutableList<MutableList<MutableList<out MutableLis
|
||||
if (f != null) {
|
||||
val g = f[0]
|
||||
if (g != null) {
|
||||
val h = g[0] // no SMARTCAST diagnostic
|
||||
val h = <!UNRESOLVED_REFERENCE!>g[0]<!> // no SMARTCAST diagnostic
|
||||
if (h != null) {
|
||||
h.inc()
|
||||
h.<!UNRESOLVED_REFERENCE!>inc<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class A<T> {
|
||||
List<String> getChildrenStubs() { return null; }
|
||||
void consume(T x) {}
|
||||
|
||||
T produce() { return null; }
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public class B<E extends A> {
|
||||
public E foo() { return null;}
|
||||
E field;
|
||||
}
|
||||
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test {
|
||||
static B rawB = null;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo(x: B<*>) {
|
||||
// TODO: x.foo() now is flexible type instead of raw, because of captured type approximation
|
||||
val q: MutableList<String> = x.foo().getChildrenStubs()
|
||||
|
||||
// Raw(B).field erased to A<Any!>..A<out Any!>?
|
||||
Test.rawB.field = A<String>()
|
||||
val anyA: A<Any> = Test.rawB.field
|
||||
|
||||
// FIR doesn't work here, because
|
||||
// field has a type of just 'A' and it's not clear why should it accept 'String' at consume
|
||||
// NB: some kind of BareTypeScope should be in use here
|
||||
Test.rawB.field.<!INAPPLICABLE_CANDIDATE!>consume<!>("")
|
||||
val y: Any = Test.rawB.field.produce()
|
||||
}
|
||||
+3
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
|
||||
@@ -34,6 +33,9 @@ fun foo(x: B<*>) {
|
||||
Test.rawB.field = A<String>()
|
||||
val anyA: A<Any> = Test.rawB.field
|
||||
|
||||
// FIR doesn't work here, because
|
||||
// field has a type of just 'A' and it's not clear why should it accept 'String' at consume
|
||||
// NB: some kind of BareTypeScope should be in use here
|
||||
Test.rawB.field.consume("")
|
||||
val y: Any = Test.rawB.field.produce()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user