[FIR] Fix missing receiver type if anonymous function without label
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ fun test() {
|
||||
} else {
|
||||
::foo
|
||||
}
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction0<Int>>() }
|
||||
a checkType { _<KFunction0<Int>>() }
|
||||
}
|
||||
|
||||
fun foo(): Int = 0
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ fun take(f: (A) -> Unit) {}
|
||||
fun take(f: () -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
B::foo checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction1<B, Unit>>() }
|
||||
B::foo checkType { _<KFunction1<B, Unit>>() }
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>take<!>(B::foo)
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ class B : A() {
|
||||
|
||||
|
||||
fun test() {
|
||||
B::foo checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction2<B, String, String>>() }
|
||||
B::foo checkType { _<KFunction2<B, String, String>>() }
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>(B::hashCode)("No.")<!>
|
||||
}
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
class C {
|
||||
val baz: Int = 12
|
||||
}
|
||||
|
||||
fun Int.baz() {}
|
||||
|
||||
fun test() {
|
||||
C::baz checkType { <!UNRESOLVED_REFERENCE!>_<!><KProperty1<C, Int>>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ fun fas(i: Int = 1) {}
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>B::foo<!> // todo KT-9601 Chose maximally specific function in callable reference
|
||||
|
||||
B::bar checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction1<B, Unit>>() }
|
||||
B::bar checkType { _<KFunction1<B, Unit>>() }
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>B::bas<!>
|
||||
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ interface B : A
|
||||
interface C : B
|
||||
|
||||
fun test(b: B) {
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><B>() }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><A>() }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><C>() }
|
||||
b checkType { _<B>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><C>() }
|
||||
}
|
||||
|
||||
+4
-4
@@ -14,11 +14,11 @@ fun test() {
|
||||
}
|
||||
|
||||
fun check() {
|
||||
[1, 2] checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<Int>>() }
|
||||
[""] checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<String>>() }
|
||||
[1, 2] checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Array<Int>>() }
|
||||
[""] checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Array<String>>() }
|
||||
|
||||
val f: IntArray = [1]
|
||||
[f] checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<IntArray>>() }
|
||||
[f] checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Array<IntArray>>() }
|
||||
|
||||
[1, ""] checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<Any>>() }
|
||||
[1, ""] checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Array<Any>>() }
|
||||
}
|
||||
+2
-2
@@ -9,7 +9,7 @@ class None<T> : Option<T>
|
||||
fun <T> bind(r: Option<T>): Option<T> {
|
||||
return if (r is Some) {
|
||||
// Ideally we should infer Option<T> here (see KT-10896)
|
||||
(if (true) None() else r) checkType { <!UNRESOLVED_REFERENCE!>_<!><Option<T>>() }
|
||||
(if (true) None() else r) checkType { _<Option<T>>() }
|
||||
// Works correctly
|
||||
if (true) None() else r
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class SimpleNone : SimpleOption
|
||||
|
||||
fun bindNoGeneric(r: SimpleOption): SimpleOption {
|
||||
return if (r is SimpleSome) {
|
||||
(if (true) SimpleNone() else r) checkType { <!UNRESOLVED_REFERENCE!>_<!><SimpleOption>() }
|
||||
(if (true) SimpleNone() else r) checkType { _<SimpleOption>() }
|
||||
if (true) SimpleNone() else r
|
||||
}
|
||||
else r
|
||||
|
||||
+4
-4
@@ -12,10 +12,10 @@ fun <T: Any> exclExcl(t: T?): T = t!!
|
||||
|
||||
fun test11() {
|
||||
// not 'String!'
|
||||
exclExcl(A.foo()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
exclExcl(A.foo()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
exclExcl(A.foo()) checkType { _<String>() }
|
||||
exclExcl(A.foo()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String?>() }
|
||||
|
||||
// not 'String!'
|
||||
A.foo()!! checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
A.foo()!! checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
A.foo()!! checkType { _<String>() }
|
||||
A.foo()!! checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String?>() }
|
||||
}
|
||||
+1
-1
@@ -7,5 +7,5 @@ import kotlin.reflect.KSuspendFunction0
|
||||
suspend fun foo() {}
|
||||
|
||||
fun test() {
|
||||
::foo checkType { <!UNRESOLVED_REFERENCE!>_<!><KSuspendFunction0<Unit>>() }
|
||||
::foo checkType { <!INAPPLICABLE_CANDIDATE!>_<!><KSuspendFunction0<Unit>>() }
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -37,7 +37,7 @@ fun test() {
|
||||
y: Int -> fun(): Int {return 1}
|
||||
}
|
||||
|
||||
x4 checkType { <!UNRESOLVED_REFERENCE!>_<!><Function1<Int, Function0<Int>>>() }
|
||||
x4 checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Int, Function0<Int>>>() }
|
||||
|
||||
{ y: Int -> fun(): Int {return 1} }
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -42,7 +42,7 @@ fun test() {
|
||||
y: Int -> fun named12(): Int {return 1}
|
||||
}
|
||||
|
||||
x4 checkType { <!UNRESOLVED_REFERENCE!>_<!><Function1<Int, Unit>>() }
|
||||
x4 checkType { _<Function1<Int, Unit>>() }
|
||||
|
||||
{ y: Int -> fun named14(): Int {return 1} }
|
||||
val b = <!UNRESOLVED_REFERENCE!>(<!EXPRESSION_REQUIRED!>fun named15(): Boolean { return true }<!>)()<!>
|
||||
@@ -61,7 +61,7 @@ fun success() {
|
||||
run2 { fun named2() = 1 }
|
||||
|
||||
val x = run { fun named3() = 1 }
|
||||
x checkType { <!UNRESOLVED_REFERENCE!>_<!><Unit>() }
|
||||
x checkType { _<Unit>() }
|
||||
|
||||
val y = when (1) {
|
||||
0 -> {
|
||||
@@ -71,5 +71,5 @@ fun success() {
|
||||
fun named5(): Int {return 1}
|
||||
}
|
||||
}
|
||||
y checkType { <!UNRESOLVED_REFERENCE!>_<!><Unit>() }
|
||||
y checkType { _<Unit>() }
|
||||
}
|
||||
|
||||
Vendored
+7
-7
@@ -9,24 +9,24 @@ fun bar() {
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
x checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
x checkType { _<(A) -> Unit>() }
|
||||
|
||||
val y = { (<!UNRESOLVED_REFERENCE!>a: Int<!>, <!UNRESOLVED_REFERENCE!>b<!>): A ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
a checkType { _<Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
y checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
y checkType { _<(A) -> Unit>() }
|
||||
|
||||
val y2 = { (<!UNRESOLVED_REFERENCE!>a: Number<!>, <!UNRESOLVED_REFERENCE!>b<!>): A ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
y2 checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
y2 checkType { _<(A) -> Unit>() }
|
||||
|
||||
val z = { (<!UNRESOLVED_REFERENCE!>a: Int<!>, <!UNRESOLVED_REFERENCE!>b: String<!>) ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
fun test() {
|
||||
val a = if (true) {
|
||||
val x = 1
|
||||
({ x })
|
||||
} else {
|
||||
{ 2 }
|
||||
}
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><() -> Int>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
fun test() {
|
||||
val a = if (true) {
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
fun <T> id(t: T) = t
|
||||
|
||||
fun foo() {
|
||||
val i = id { 22 } //type inference error: no information for parameter
|
||||
i checkType { <!UNRESOLVED_REFERENCE!>_<!><()->Int>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
fun <T> id(t: T) = t
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
fun test(b: S) {
|
||||
b.collect(toList()) checkType { <!UNRESOLVED_REFERENCE!>_<!><Inv<String>>() }
|
||||
}
|
||||
|
||||
interface S {
|
||||
fun <R> collect(collector: C<in String, R>): R
|
||||
}
|
||||
|
||||
class C<X, Y>
|
||||
|
||||
fun <T> toList(): C<T, Inv<T>> = null!!
|
||||
|
||||
class Inv<Q>
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
fun test(b: S) {
|
||||
|
||||
Vendored
+2
-2
@@ -19,8 +19,8 @@ class A : Outer<Double, Short>() {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
Derived().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<String, Int>.Inner<Char>>() }
|
||||
Derived().foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<String, Int>.Inner<Char>>() }
|
||||
Derived().baz() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<Char, String>>() }
|
||||
A.B().bar() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Float, Long>.Inner<String>>() }
|
||||
A.B().bar() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<Float, Long>.Inner<String>>() }
|
||||
A.B().x() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<String, Float>>() }
|
||||
}
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ fun test() {
|
||||
var x = foobar<String>()
|
||||
x = foobar<String>()
|
||||
|
||||
x().foo().a() checkType { <!UNRESOLVED_REFERENCE!>_<!><A<String, Double, Short, Long>>() }
|
||||
x().foo().a() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A<String, Double, Short, Long>>() }
|
||||
x().bar() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><A<String, Double, Short, Char>>() }
|
||||
|
||||
x = foobar<Int>()
|
||||
@@ -50,6 +50,6 @@ fun test() {
|
||||
var y = noParameters()
|
||||
y = noParameters()
|
||||
|
||||
y().foo().a() checkType { <!UNRESOLVED_REFERENCE!>_<!><A<Any, Double, Short, Long>>() }
|
||||
y().foo().a() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A<Any, Double, Short, Long>>() }
|
||||
y().bar() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><A<Any, Double, Short, Char>>() }
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,6 +14,6 @@ class Derived : BaseDerived2<Int>() {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
Derived().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int, String>.Inner<Char>>() }
|
||||
Derived().foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<Int, String>.Inner<Char>>() }
|
||||
Derived().baz() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<Char, Int>>() }
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -14,5 +14,5 @@ class DerivedOuter : Outer<String>() {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
DerivedOuter().DerivedInner().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<String>.Inner<Int>.Inner2<Char>>() }
|
||||
DerivedOuter().DerivedInner().foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<String>.Inner<Int>.Inner2<Char>>() }
|
||||
}
|
||||
|
||||
@@ -24,23 +24,23 @@ fun <T> B<T>.bar() = ""
|
||||
|
||||
fun foo(l: A<String>?) {
|
||||
// No errors should be here
|
||||
foo(l?.bar()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
foo(l?.gav()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
foo(l?.bar()) checkType { _<String?>() }
|
||||
foo(l?.gav()) checkType { _<String?>() }
|
||||
if (l != null) {
|
||||
foo(l?.bar()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
foo(l?.gav()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
foo(l?.bar()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
foo(l?.gav()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
|
||||
fun fooNotNull(l: A<String>) {
|
||||
// No errors should be here
|
||||
foo(l?.bar()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
foo(l?.gav()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
foo(l?.bar()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
foo(l?.gav()) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
val l = B.create<String>()
|
||||
foo(l?.bar()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
foo(l?.gav()) checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
foo(l?.bar()) checkType { _<String?>() }
|
||||
foo(l?.gav()) checkType { _<String?>() }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public java.util.List<? extends CharSequence> foo() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo2(x: A, y: MutableList<out CharSequence>) {
|
||||
x.foo().isEmpty()
|
||||
x.foo().get(0) checkType { <!UNRESOLVED_REFERENCE!>_<!><CharSequence>() }
|
||||
x.foo().iterator() checkType { <!UNRESOLVED_REFERENCE!>_<!><MutableIterator<CharSequence>>() }
|
||||
|
||||
y.isEmpty()
|
||||
y.get(0) checkType { <!UNRESOLVED_REFERENCE!>_<!><CharSequence>() }
|
||||
y.iterator() checkType { <!UNRESOLVED_REFERENCE!>_<!><MutableIterator<CharSequence>>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
public abstract class A<E> {
|
||||
fun bar(): String = ""
|
||||
}
|
||||
|
||||
public class B<F> : A<B<F>>()
|
||||
|
||||
fun test(b: B<*>) {
|
||||
// Here `bar` could have dispatch receiver parameter type 'A<B<Captured(*)>>', but it wouldn't work as
|
||||
// since 'b' has type 'A<out B<*>>', so we should approximate dispatch receiver PARAMETER type to make it accept original receiver
|
||||
b.bar()
|
||||
b.bar() checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
public abstract class A<E> {
|
||||
|
||||
+1
-1
@@ -11,5 +11,5 @@ fun main() {
|
||||
val c : ListOfLists<*> = b
|
||||
val d : ArrayList<ArrayList<*>> = c.x
|
||||
|
||||
c.x checkType { <!UNRESOLVED_REFERENCE!>_<!><ArrayList<out ArrayList<*>>>() }
|
||||
c.x checkType { <!INAPPLICABLE_CANDIDATE!>_<!><ArrayList<out ArrayList<*>>>() }
|
||||
}
|
||||
|
||||
+5
-5
@@ -9,12 +9,12 @@ public class Clazz<T> {
|
||||
|
||||
// FILE: main.kt
|
||||
fun test(clazz: Clazz<*>) {
|
||||
clazz.t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
clazz.getSuperClass() checkType { <!UNRESOLVED_REFERENCE!>_<!><Clazz<*>?>() }
|
||||
clazz.getSuperClass().t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
clazz.t checkType { _<Any?>() }
|
||||
clazz.getSuperClass() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Clazz<*>?>() }
|
||||
clazz.getSuperClass().t checkType { _<Any?>() }
|
||||
|
||||
clazz.superClass checkType { <!UNRESOLVED_REFERENCE!>_<!><Clazz<*>?>() }
|
||||
clazz.superClass.t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
clazz.superClass checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Clazz<*>?>() }
|
||||
clazz.superClass.t checkType { _<Any?>() }
|
||||
|
||||
// See KT-9294
|
||||
if (clazz.superClass == null) {
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ fun acceptA(a: A) {
|
||||
}
|
||||
|
||||
fun main(i: I<*>) {
|
||||
i.foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><A?>() }
|
||||
i.foo() checkType { _<A?>() }
|
||||
<!INAPPLICABLE_CANDIDATE!>acceptA<!>(i.foo()) // i.foo() should be nullable but isn't
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -5,5 +5,5 @@ interface A<T : A<T?>?> {
|
||||
fun foo(): T?
|
||||
}
|
||||
fun testA(a: A<*>) {
|
||||
a.foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><A<*>?>() }
|
||||
a.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A<*>?>() }
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ interface Clazz<T> {
|
||||
}
|
||||
|
||||
fun test(clazz: Clazz<*>) {
|
||||
clazz.t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
clazz.getSuperClass() checkType { <!UNRESOLVED_REFERENCE!>_<!><Clazz<*>>() }
|
||||
clazz.getSuperClass().t checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
clazz.t checkType { _<Any?>() }
|
||||
clazz.getSuperClass() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Clazz<*>>() }
|
||||
clazz.getSuperClass().t checkType { _<Any?>() }
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@ class Inv2<T : Inv2<in T>>(val x: T)
|
||||
fun main(a: A<*>, j: JavaClass<*>, i2: Inv2<*>) {
|
||||
// Probably it's too restrictive to suppose star projection type here as Any?,
|
||||
// but looks like we can refine it later
|
||||
a.foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
j.foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
i2.x checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
a.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any?>() }
|
||||
j.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any?>() }
|
||||
i2.x checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any?>() }
|
||||
|
||||
j.<!INAPPLICABLE_CANDIDATE!>bar<!>(1, 2, Any())
|
||||
j.bar(null)
|
||||
|
||||
Vendored
+1
-1
@@ -6,5 +6,5 @@ interface Tr<T> {
|
||||
|
||||
fun test(t: Tr<*>) {
|
||||
t.v = t
|
||||
t.v checkType { <!UNRESOLVED_REFERENCE!>_<!><Tr<*>>() }
|
||||
t.v checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Tr<*>>() }
|
||||
}
|
||||
+1
-1
@@ -10,5 +10,5 @@ fun test(t: Tr<*>) {
|
||||
t.v = null!!
|
||||
t.v = ""
|
||||
t.v = null
|
||||
t.v checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
t.v checkType { _<Any?>() }
|
||||
}
|
||||
+2
-2
@@ -7,7 +7,7 @@ fun <T: Any> bar(a: Array<T>): Array<T?> = null!!
|
||||
fun test1(a: Array<out Int>) {
|
||||
val r: Array<out Int?> = bar(a)
|
||||
val t = bar(a)
|
||||
t checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<out Int?>>() }
|
||||
t checkType { _<Array<out Int?>>() }
|
||||
}
|
||||
|
||||
fun <T: Any> foo(l: Array<T>): Array<Array<T?>> = null!!
|
||||
@@ -15,5 +15,5 @@ fun <T: Any> foo(l: Array<T>): Array<Array<T?>> = null!!
|
||||
fun test2(a: Array<out Int>) {
|
||||
val r: Array<out Array<out Int?>> = foo(a)
|
||||
val t = foo(a)
|
||||
t checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<out Array<out Int?>>>() }
|
||||
t checkType { _<Array<out Array<out Int?>>>() }
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static <T> Class<T> foo(Class<T> clazz) {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public static <T> Class<Class<T>> bar(Class<T> clazz) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
fun test1(clazz: Class<out Int>) {
|
||||
val foo0: Class<out Int> = A.foo(clazz)
|
||||
val foo1 = A.foo(clazz)
|
||||
foo1 checkType { <!UNRESOLVED_REFERENCE!>_<!>< Class<out Int> >() }
|
||||
foo1 checkType { <!UNRESOLVED_REFERENCE!>_<!>< Class<out Int?> >() }
|
||||
}
|
||||
|
||||
fun tes2t(clazz: Class<in Int>) {
|
||||
val foo0: Class<out Class<in Int>> = A.bar(clazz)
|
||||
val foo1 = A.bar(clazz)
|
||||
foo1 checkType { <!UNRESOLVED_REFERENCE!>_<!>< Class<out Class<in Int>> >() }
|
||||
foo1 checkType { <!UNRESOLVED_REFERENCE!>_<!>< Class<out Class<in Int?>> >() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> foo(array: Array<T>): Array<T> = array
|
||||
|
||||
fun test1(a1: Array<out Int>) {
|
||||
val b1: Array<out Int> = foo(a1)
|
||||
val c1 = foo(a1)
|
||||
c1 checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<out Int>>() }
|
||||
}
|
||||
|
||||
fun test2(a2: Array<in Int>) {
|
||||
val b2: Array<in Int> = foo(a2)
|
||||
val c2 = foo(a2)
|
||||
c2 checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<in Int>>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> foo(a: Array<T>): Array<Array<T>> = throw Exception()
|
||||
|
||||
fun test1(a1: Array<out Int>) {
|
||||
val b1: Array<out Array<out Int>> = foo(a1)
|
||||
val c1 = foo(a1)
|
||||
c1 checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<out Array<out Int>>>() }
|
||||
}
|
||||
|
||||
fun test2(a2: Array<in Int>) {
|
||||
val b2: Array<out Array<in Int>> = foo(a2)
|
||||
val c2 = foo(a2)
|
||||
c2 checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<out Array<in Int>>>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> foo1(a1: Array<in T>, a2: Array<T>): T = null!!
|
||||
|
||||
fun test1(a1: Array<Int>, a2: Array<out Int>) {
|
||||
foo1(a1, a2) checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
}
|
||||
|
||||
fun <T> foo2(a1: Array<T>, a2: Array<out T>): T = null!!
|
||||
|
||||
fun test2(a1: Array<in Int>, a2: Array<Int>) {
|
||||
foo2(a1, a2) checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun <T> foo(l: MutableList<T>): MutableList<T> = l
|
||||
fun test(l: MutableList<out Int>) {
|
||||
val a: MutableList<out Int> = foo(l)
|
||||
val b = foo(l)
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!>< MutableList<out Int> >() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
|
||||
+2
-2
@@ -7,6 +7,6 @@ class A<T> {
|
||||
fun <E> A<E>.bar(): A<in E> = this
|
||||
|
||||
fun baz(x: A<out CharSequence>) {
|
||||
x.bar() checkType { <!UNRESOLVED_REFERENCE!>_<!><A<*>>() }
|
||||
x.bar().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() } // See KT-10448
|
||||
x.bar() checkType { _<A<*>>() }
|
||||
x.bar().foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any?>() } // See KT-10448
|
||||
}
|
||||
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> foo(a: Array<T>): T = null!!
|
||||
|
||||
fun test(a: Array<in Int>) {
|
||||
foo(a) checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> foo(a: Array<T>): T = null!!
|
||||
|
||||
fun test(a: Array<out Int>) {
|
||||
foo(a) checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ fun noCoercionLastExpressionUsedAsReturnArgument() {
|
||||
42
|
||||
}
|
||||
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><() -> Int>() }
|
||||
a checkType { _<() -> Int>() }
|
||||
}
|
||||
|
||||
fun noCoercionBlockHasExplicitType() {
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
// KT-3372 Use upper bound in type argument inference
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
fun <T, C: MutableCollection<T>> Iterable<T>.toCollection(result: C) : C = throw Exception()
|
||||
|
||||
fun test(list: List<Int>) {
|
||||
val set = list.toCollection(HashSet())
|
||||
set checkType { <!UNRESOLVED_REFERENCE!>_<!><HashSet<Int>>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
// KT-3372 Use upper bound in type argument inference
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T, R> Collection<T>.map(transform : (T) -> R) : List<R> = throw Exception()
|
||||
|
||||
fun test(list: List<List<Int>>) {
|
||||
|
||||
val list1 = list.map { it.map { "$it" } }
|
||||
list1 checkType { <!UNRESOLVED_REFERENCE!>_<!><List<List<String>>>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
val array = arrayOf(arrayOf(1))
|
||||
array checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<Array<Int>>>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ fun <K> invOut(y: K?): Inv<Out<K>> = TODO()
|
||||
fun <R> test(x: Inv<Out<R>>): R = TODO()
|
||||
|
||||
fun testNothing() {
|
||||
test(invOut(null)) checkType { <!UNRESOLVED_REFERENCE!>_<!><Nothing>() }
|
||||
test(invOut(null)) checkType { _<Nothing>() }
|
||||
}
|
||||
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
fun <T> foo(a: A<T>, aN: A<T?>): T = throw Exception("$a $aN")
|
||||
|
||||
fun <T> doA(a: A<T>): T = throw Exception("$a")
|
||||
|
||||
fun test(a: A<Int>, aN: A<Int?>) {
|
||||
val aa = doA(aN)
|
||||
aa checkType { <!UNRESOLVED_REFERENCE!>_<!><Int?>() }
|
||||
|
||||
val nullable = foo(aN, aN)
|
||||
//T = Int?, T? = Int? => T = Int?
|
||||
nullable checkType { <!UNRESOLVED_REFERENCE!>_<!><Int?>() }
|
||||
|
||||
val notNullable = foo(a, aN)
|
||||
//T = Int, T? = Int? => T = Int
|
||||
notNullable checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -15,7 +15,7 @@ fun test(out: Out<Int>, i: In<Int>, inv: A<Int>) {
|
||||
// T? >: Int => T = Int
|
||||
doT(1)
|
||||
val r = doOut(out)
|
||||
r checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
r checkType { _<Int>() }
|
||||
|
||||
// T? <: Int => error
|
||||
<!INAPPLICABLE_CANDIDATE!>doIn<!>(i)
|
||||
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
interface Out<out T>
|
||||
|
||||
fun <T> foo(a: A<T>, o: Out<T?>): T = throw Exception("$a $o")
|
||||
|
||||
fun <T> doOut(o: Out<T?>): T = throw Exception("$o")
|
||||
|
||||
fun test(a: A<Int>, aN: A<Int?>, o: Out<Int?>) {
|
||||
val out = doOut(o)
|
||||
//T? >: Int? => T >: Int
|
||||
out checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
|
||||
val nullable = foo(aN, o)
|
||||
//T = Int?, T? >: Int? => T = Int?
|
||||
nullable checkType { <!UNRESOLVED_REFERENCE!>_<!><Int?>() }
|
||||
|
||||
val notNullable = foo(a, o)
|
||||
//T = Int, T? >: Int? => T = Int
|
||||
notNullable checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
interface In<in T>
|
||||
|
||||
fun <T> foo(a: A<T>, i: In<T>): T = throw Exception("$a $i")
|
||||
|
||||
fun <T> doIn(i: In<T?>): T = throw Exception("$i")
|
||||
|
||||
fun test(a: A<Int>, aN: A<Int?>, i: In<Int?>) {
|
||||
val _in = doIn(i)
|
||||
//T? <: Int? => T <: Int?
|
||||
_in checkType { <!UNRESOLVED_REFERENCE!>_<!><Int?>() }
|
||||
|
||||
val notNullable = foo(a, i)
|
||||
//T = Int, T? <: Int? => T = Int
|
||||
notNullable checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
|
||||
val nullable = foo(aN, i)
|
||||
//T = Int?, T? <: Int? => T = Int?
|
||||
nullable checkType { <!UNRESOLVED_REFERENCE!>_<!><Int?>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
|
||||
Vendored
+5
-5
@@ -11,19 +11,19 @@ class State(val p1: Double, val p2: () -> Int, val p3: String?)
|
||||
|
||||
fun test(s: SelectorFor<State>): Double {
|
||||
val a = s { p1 }
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><AbstractSelector<State, Double>>() }
|
||||
a checkType { _<AbstractSelector<State, Double>>() }
|
||||
|
||||
val b = s { p2 }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><AbstractSelector<State, () -> Int>>()}
|
||||
b checkType { _<AbstractSelector<State, () -> Int>>()}
|
||||
|
||||
val c = s { p3 }
|
||||
c checkType { <!UNRESOLVED_REFERENCE!>_<!><AbstractSelector<State, String?>>() }
|
||||
c checkType { _<AbstractSelector<State, String?>>() }
|
||||
|
||||
val d = s { }
|
||||
d checkType { <!UNRESOLVED_REFERENCE!>_<!><AbstractSelector<State, Unit>>() }
|
||||
d checkType { _<AbstractSelector<State, Unit>>() }
|
||||
|
||||
val e = s { return p1 }
|
||||
e checkType { <!UNRESOLVED_REFERENCE!>_<!><AbstractSelector<State, Nothing>>() }
|
||||
e checkType { _<AbstractSelector<State, Nothing>>() }
|
||||
|
||||
return null!!
|
||||
}
|
||||
+2
-2
@@ -10,8 +10,8 @@ class TestClass {
|
||||
|
||||
fun test(s: String): String {
|
||||
val a = TestClass { "K" }
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
a checkType { _<String>() }
|
||||
|
||||
val b = TestClass { return s }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><Nothing>() }
|
||||
b checkType { _<Nothing>() }
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -8,8 +8,8 @@ object TestClass {
|
||||
|
||||
fun test(s: String): String {
|
||||
val a = TestClass { TestClass { TestClass } }
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><TestClass>() }
|
||||
a checkType { _<TestClass>() }
|
||||
|
||||
val b = TestClass { return s }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><Nothing>() }
|
||||
b checkType { _<Nothing>() }
|
||||
}
|
||||
Vendored
+4
-4
@@ -8,7 +8,7 @@ class TestClass {
|
||||
|
||||
fun <T> test(value: T, test: TestClass): T {
|
||||
val x = test { return value }
|
||||
x checkType { <!UNRESOLVED_REFERENCE!>_<!><Nothing>() }
|
||||
x checkType { _<Nothing>() }
|
||||
|
||||
return value
|
||||
}
|
||||
@@ -23,13 +23,13 @@ interface FutureCallback<E> {
|
||||
|
||||
fun test(cb: FutureCallback<String>) {
|
||||
val a = cb { it[0] }
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Future<Char>>() }
|
||||
a checkType { _<Future<Char>>() }
|
||||
|
||||
val b = cb { it }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><Future<String>>() }
|
||||
b checkType { _<Future<String>>() }
|
||||
|
||||
val c = cb {}
|
||||
c checkType { <!UNRESOLVED_REFERENCE!>_<!><Future<Unit>>() }
|
||||
c checkType { _<Future<Unit>>() }
|
||||
|
||||
cb.let { callback ->
|
||||
val d = callback { it.length }
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !LANGUAGE: +ExpectedTypeFromCast
|
||||
// !CHECK_TYPE
|
||||
// Issue: KT-30405
|
||||
|
||||
inline fun <reified T> foo(): T {
|
||||
TODO()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val fooCall = foo() as String // T in foo should be inferred to String
|
||||
fooCall checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
|
||||
val safeFooCall = foo() as? String
|
||||
safeFooCall checkType { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !LANGUAGE: +ExpectedTypeFromCast
|
||||
// !CHECK_TYPE
|
||||
|
||||
Vendored
+1
-1
@@ -13,7 +13,7 @@ fun test1(b: Boolean?) {
|
||||
false -> null
|
||||
null -> materialize<String>()
|
||||
}
|
||||
v checkType { <!UNRESOLVED_REFERENCE!>_<!><Inv<String>?>() }
|
||||
v checkType { _<Inv<String>?>() }
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// T is the immutable type
|
||||
interface Builder<out T> {
|
||||
fun build(): T
|
||||
}
|
||||
|
||||
// T is the immutable type, U is the builder
|
||||
interface Copyable<out T, out U : Builder<T>> {
|
||||
fun builder(): U
|
||||
}
|
||||
|
||||
fun <T : Copyable<T, U>, U : Builder<T>> T.copy(fn: U.() -> Unit): T = throw Exception()
|
||||
|
||||
open class Foo(val x: Int, val y: Int) : Copyable<Foo, Foo.FooBuilder> {
|
||||
override fun builder(): FooBuilder = FooBuilder(x, y)
|
||||
|
||||
open class FooBuilder(var x: Int, var y: Int): Builder<Foo> {
|
||||
override fun build(): Foo = Foo(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val foo1 = Foo(x = 1, y = 2)
|
||||
val foo2 = foo1.copy { y = 3 } // this doesn't work
|
||||
foo2 checkType { <!UNRESOLVED_REFERENCE!>_<!><Foo>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
//KT-4420 Type inference with type projections
|
||||
|
||||
class Foo<T>
|
||||
fun <T> Foo<T>.bar(): T = throw Exception()
|
||||
|
||||
fun main() {
|
||||
val f: Foo<out String> = Foo()
|
||||
f.bar() checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
//KT-4420 Type inference with type projections
|
||||
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
package g
|
||||
|
||||
import java.util.HashSet
|
||||
fun <T, C: Collection<T>> convert(src: Collection<T>, dest: C): C = throw Exception("$src $dest")
|
||||
|
||||
fun test(l: List<Int>) {
|
||||
//todo should be inferred
|
||||
val r = convert(l, HashSet())
|
||||
r checkType { <!UNRESOLVED_REFERENCE!>_<!><HashSet<Int>>() }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
package g
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ public fun <T> listOf(t: T): List<T> = TODO()
|
||||
|
||||
fun usage(c: List<String>) {
|
||||
val cn = c.ifEmpty { null }
|
||||
cn checkType { <!UNRESOLVED_REFERENCE!>_<!><List<String>?>() }
|
||||
cn checkType { _<List<String>?>() }
|
||||
|
||||
val cs = c.ifEmpty { listOf("x") }
|
||||
cs checkType { <!UNRESOLVED_REFERENCE!>_<!><List<String>>() }
|
||||
cs checkType { _<List<String>>() }
|
||||
}
|
||||
+3
-3
@@ -2,20 +2,20 @@ package f
|
||||
|
||||
object A {
|
||||
class LoginFormPage() : Request({
|
||||
val failed = <!UNRESOLVED_REFERENCE!>session<!>.<!UNRESOLVED_REFERENCE!>get<!>("LOGIN_FAILED")
|
||||
val failed = session.get("LOGIN_FAILED")
|
||||
})
|
||||
}
|
||||
|
||||
class B {
|
||||
companion object {
|
||||
class LoginFormPage() : Request({
|
||||
val failed = <!UNRESOLVED_REFERENCE!>session<!>.<!UNRESOLVED_REFERENCE!>get<!>("LOGIN_FAILED")
|
||||
val failed = session.get("LOGIN_FAILED")
|
||||
})
|
||||
}
|
||||
|
||||
class C {
|
||||
class LoginFormPage() : Request({
|
||||
val failed = <!UNRESOLVED_REFERENCE!>session<!>.<!UNRESOLVED_REFERENCE!>get<!>("LOGIN_FAILED")
|
||||
val failed = session.get("LOGIN_FAILED")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,5 @@ public class A<T> {
|
||||
|
||||
fun foo1(x: A<*>) = x.baz()
|
||||
fun foo2(x: A<*>) {
|
||||
x.baz() checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<out A<*>>>() }
|
||||
x.baz() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Array<out A<*>>>() }
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
// FULL_JDK
|
||||
|
||||
import java.util.stream.Collectors
|
||||
import java.util.stream.Stream
|
||||
|
||||
fun test(a: Stream<String>) {
|
||||
a.collect(Collectors.toList()) checkType { <!UNRESOLVED_REFERENCE!>_<!><MutableList<String>>() }
|
||||
// actually the inferred type is platform
|
||||
a.collect(Collectors.toList()) checkType { <!UNRESOLVED_REFERENCE!>_<!><List<String?>>() }
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ public class A<E> {
|
||||
// FILE: main.kt
|
||||
|
||||
fun test(x: List<Int>, y: List<String>) {
|
||||
A("", x) checkType { <!UNRESOLVED_REFERENCE!>_<!><A<Any?>>() }
|
||||
A("", y) checkType { <!UNRESOLVED_REFERENCE!>_<!><A<String?>>() }
|
||||
A("", x) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><A<Any?>>() }
|
||||
A("", y) checkType { _<A<String?>>() }
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>A<!><CharSequence, String>("", x)
|
||||
A<CharSequence, String>("", y)
|
||||
|
||||
+2
-2
@@ -10,9 +10,9 @@ public class Outer<T> {
|
||||
|
||||
// FILE: main.kt
|
||||
fun test(x: List<Int>, y: List<String>) {
|
||||
Outer<Int>().Inner("", y, 1) checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int>.Inner<String>>() }
|
||||
Outer<Int>().Inner("", y, 1) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<Int>.Inner<String>>() }
|
||||
Outer<Int>().<!INAPPLICABLE_CANDIDATE!>Inner<!><CharSequence, String, Int>("", y, 1) <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int>.Inner<CharSequence>>() }
|
||||
|
||||
Outer<Int>().Inner("", x, 1) checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int>.Inner<Any>>() }
|
||||
Outer<Int>().Inner("", x, 1) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Outer<Int>.Inner<Any>>() }
|
||||
Outer<Int>().<!INAPPLICABLE_CANDIDATE!>Inner<!><CharSequence, String, Int>("", x, 1)
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,6 +14,6 @@ class Foo<T>
|
||||
fun main(foo1: Foo<Boolean>, foo2: Foo<String>) {
|
||||
val x = object : Test() {} // FE exception is thrown here
|
||||
|
||||
x.with(foo1) checkType { <!UNRESOLVED_REFERENCE!>_<!><Boolean>() }
|
||||
x.with(foo2) checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
x.with(foo1) checkType { _<Boolean>() }
|
||||
x.with(foo2) checkType { _<String>() }
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ class In<in F> {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
A.foo().x() checkType { <!UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||
A.foo().x() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any?>() }
|
||||
A.bar().y(null)
|
||||
}
|
||||
|
||||
+7
-7
@@ -21,7 +21,7 @@ fun test() {
|
||||
checkSubtype<Int>(d)
|
||||
|
||||
val e = id(9223372036854775807)
|
||||
e checkType { <!UNRESOLVED_REFERENCE!>_<!><Long>() }
|
||||
e checkType { _<Long>() }
|
||||
|
||||
val f: Byte = either(1, 2)
|
||||
|
||||
@@ -32,7 +32,7 @@ fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>otherGeneric<!>(1)
|
||||
|
||||
val r = either(1, "")
|
||||
r checkType { <!UNRESOLVED_REFERENCE!>_<!><Any>() }
|
||||
r checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any>() }
|
||||
|
||||
use(a, b, c, d, e, f, g, r)
|
||||
}
|
||||
@@ -48,7 +48,7 @@ fun testExactBound(invS: Inv<String>, invI: Inv<Int>, invB: Inv<Byte>) {
|
||||
exactBound(1, invI)
|
||||
|
||||
val b = exactBound(1, invB)
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><Byte>() }
|
||||
b checkType { _<Byte>() }
|
||||
}
|
||||
|
||||
interface Cov<out T>
|
||||
@@ -57,10 +57,10 @@ fun <T> lowerBound(t: T, l : Cov<T>): T = throw Exception("$t $l")
|
||||
|
||||
fun testLowerBound(cov: Cov<String>, covN: Cov<Number>) {
|
||||
val r = lowerBound(1, cov)
|
||||
r checkType { <!UNRESOLVED_REFERENCE!>_<!><Any>() }
|
||||
r checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Any>() }
|
||||
|
||||
val n = lowerBound(1, covN)
|
||||
n checkType { <!UNRESOLVED_REFERENCE!>_<!><Number>() }
|
||||
n checkType { _<Number>() }
|
||||
}
|
||||
|
||||
interface Contr<in T>
|
||||
@@ -71,8 +71,8 @@ fun testUpperBound(contrS: Contr<String>, contrB: Contr<Byte>, contrN: Contr<Num
|
||||
<!INAPPLICABLE_CANDIDATE!>upperBound<!>(1, contrS)
|
||||
|
||||
val n = upperBound(1, contrN)
|
||||
n checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
n checkType { _<Int>() }
|
||||
|
||||
val b = upperBound(1, contrB)
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><Byte>() }
|
||||
b checkType { _<Byte>() }
|
||||
}
|
||||
|
||||
@@ -28,28 +28,28 @@ fun wrong(a: String = "", b: Int = 1) {}
|
||||
|
||||
fun test() {
|
||||
val a = simple()
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
a checkType { _<Int>() }
|
||||
|
||||
val b = simple(1)
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
b checkType { _<String>() }
|
||||
|
||||
val c = twoDefault()
|
||||
c checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
c checkType { _<Int>() }
|
||||
|
||||
val d = twoDefault(1)
|
||||
d checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
d checkType { _<Int>() }
|
||||
|
||||
val e = twoDefault(1, "")
|
||||
e checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
e checkType { _<String>() }
|
||||
|
||||
val f = withGeneric(3)
|
||||
f checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
f checkType { _<Int>() }
|
||||
|
||||
val g = discriminateGeneric(1)
|
||||
g checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
g checkType { _<String>() }
|
||||
|
||||
val h = withDefaultGeneric("")
|
||||
h checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
h checkType { _<Int>() }
|
||||
|
||||
withDefaults(1)
|
||||
|
||||
|
||||
+2
-2
@@ -22,6 +22,6 @@ fun <T> out(t: T): Out<MutableList<T>> = null!!
|
||||
|
||||
fun test(a: Out<Nothing>, b: Out<MutableList<J>>) {
|
||||
val v = f(a, b, out(J.j()))
|
||||
v checkType { <!UNRESOLVED_REFERENCE!>_<!><MutableList<J>>() }
|
||||
v checkType { <!UNRESOLVED_REFERENCE!>_<!><MutableList<J?>>() }
|
||||
v checkType { _<MutableList<J>>() }
|
||||
v checkType { <!INAPPLICABLE_CANDIDATE!>_<!><MutableList<J?>>() }
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: foo/Base.java
|
||||
|
||||
package foo;
|
||||
|
||||
public interface Base<T> {}
|
||||
|
||||
// FILE: foo/HS.java
|
||||
|
||||
package foo;
|
||||
|
||||
public class HS<T> extends Base<T> {}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import foo.*;
|
||||
|
||||
fun <T, C: Base<T>> convert(src: HS<T>, dest: C): C = throw Exception("$src $dest")
|
||||
|
||||
fun test(l: HS<Int>) {
|
||||
//todo should be inferred
|
||||
val r = convert(l, HS())
|
||||
r checkType { <!UNRESOLVED_REFERENCE!>_<!><HS<Int>>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: foo/Base.java
|
||||
|
||||
Vendored
+3
-3
@@ -12,7 +12,7 @@ fun <E> bar(): List<E> = null!!
|
||||
|
||||
|
||||
fun baz() {
|
||||
x checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
y checkType { <!UNRESOLVED_REFERENCE!>_<!><List<Int>>() }
|
||||
z checkType { <!UNRESOLVED_REFERENCE!>_<!><List<Int>>() }
|
||||
x checkType { _<String>() }
|
||||
y checkType { _<List<Int>>() }
|
||||
z checkType { _<List<Int>>() }
|
||||
}
|
||||
|
||||
+5
-5
@@ -12,11 +12,11 @@ fun <E> id(x: E) = x
|
||||
fun <E> l(x: E): List<E> = null!!
|
||||
|
||||
fun foo(a: A) {
|
||||
a.x checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
a.y checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
a.y2 checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
a.z checkType { <!UNRESOLVED_REFERENCE!>_<!><List<String>>() }
|
||||
a.z2 checkType { <!UNRESOLVED_REFERENCE!>_<!><List<List<String>>>() }
|
||||
a.x checkType { _<Int>() }
|
||||
a.y checkType { _<Int>() }
|
||||
a.y2 checkType { _<Int>() }
|
||||
a.z checkType { _<List<String>>() }
|
||||
a.z2 checkType { _<List<List<String>>>() }
|
||||
|
||||
with(a) {
|
||||
1.u checkType { _<Int>() }
|
||||
|
||||
+2
-2
@@ -4,6 +4,6 @@ val x get() = null
|
||||
val y get() = null!!
|
||||
|
||||
fun foo() {
|
||||
x checkType { <!UNRESOLVED_REFERENCE!>_<!><Nothing?>() }
|
||||
y checkType { <!UNRESOLVED_REFERENCE!>_<!><Nothing>() }
|
||||
x checkType { _<Nothing?>() }
|
||||
y checkType { _<Nothing>() }
|
||||
}
|
||||
|
||||
+5
-5
@@ -18,20 +18,20 @@ class C : B(), A {
|
||||
override var y
|
||||
get() = super.y
|
||||
set(value) {
|
||||
value checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
value checkType { _<String>() }
|
||||
}
|
||||
|
||||
override var z
|
||||
get() = ""
|
||||
set(value) {
|
||||
value checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
value checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(c: C) {
|
||||
c.x checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
c.y checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c.z checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c.x checkType { _<Int>() }
|
||||
c.y checkType { _<String>() }
|
||||
c.z checkType { _<String>() }
|
||||
|
||||
c.y = ""
|
||||
c.y = 1
|
||||
|
||||
+6
-6
@@ -11,11 +11,11 @@ fun <E> id(x: E) = x
|
||||
fun <E> l(x: E): List<E> = null!!
|
||||
|
||||
fun foo() {
|
||||
x checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
y checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
y2 checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
z checkType { <!UNRESOLVED_REFERENCE!>_<!><List<String>>() }
|
||||
z2 checkType { <!UNRESOLVED_REFERENCE!>_<!><List<List<String>>>() }
|
||||
x checkType { _<Int>() }
|
||||
y checkType { _<Int>() }
|
||||
y2 checkType { _<Int>() }
|
||||
z checkType { _<List<String>>() }
|
||||
z2 checkType { _<List<List<String>>>() }
|
||||
|
||||
1.u checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
1.u checkType { _<Int>() }
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user