deprecating types after colon

This commit is contained in:
Dmitry Jemerov
2015-04-21 18:32:31 +02:00
parent b7a4b3c17d
commit f374eec8f1
268 changed files with 1055 additions and 769 deletions
@@ -1,9 +1,9 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
fun foo(x: Int, <!UNUSED_PARAMETER!>y<!>: Any) = x
fun foo(<!UNUSED_PARAMETER!>x<!>: Any, y: Int) = y
fun main() {
::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> : (Int, Any) -> Unit
}
val fooRef: (Int, Any) -> Unit = ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
}
@@ -1,10 +1,12 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction0
class A {
fun main() {
val x = ::A
x : KFunction0<A>
checkSubtype<KFunction0<A>>(x)
}
}
@@ -12,6 +14,6 @@ class SomeOtherClass {
fun main() {
val x = ::A
x : KFunction0<A>
checkSubtype<KFunction0<A>>(x)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction0
class A
@@ -7,6 +9,6 @@ fun A.ext() {
val x = ::A
val y = ::B
x : KFunction0<A>
y : KFunction0<B>
checkSubtype<KFunction0<A>>(x)
checkSubtype<KFunction0<B>>(y)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction0
class A
@@ -7,15 +9,15 @@ class B {
val x = ::A
val y = ::B
x : KFunction0<A>
y : KFunction0<B>
checkSubtype<KFunction0<A>>(x)
checkSubtype<KFunction0<B>>(y)
}
fun B.ext() {
val x = ::A
val y = ::B
x : KFunction0<A>
y : KFunction0<B>
checkSubtype<KFunction0<A>>(x)
checkSubtype<KFunction0<B>>(y)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction0
class A
@@ -5,5 +7,5 @@ class A
fun main() {
val x = ::A
x : KFunction0<A>
checkSubtype<KFunction0<A>>(x)
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// FILE: a.kt
package first
@@ -21,7 +22,7 @@ fun main() {
val y = first.A::bar
val z = A::baz
x : KMemberFunction0<A, Unit>
y : KMemberFunction1<A, Int, Unit>
z : KMemberFunction0<A, String>
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// FILE: a.kt
@@ -23,5 +24,5 @@ fun main() {
first.A::<!UNRESOLVED_REFERENCE!>bar<!>
A::<!UNRESOLVED_REFERENCE!>baz<!>
x : KExtensionFunction0<A, Unit>
checkSubtype<KExtensionFunction0<A, Unit>>(x)
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// FILE: a.kt
package first
@@ -21,7 +22,7 @@ fun main() {
val y = ::bar
val z = ::baz
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
@@ -6,9 +8,9 @@ class A {
val y = ::bar
val z = ::baz
x : KExtensionFunction0<A, Unit>
y : KExtensionFunction1<A, Int, Unit>
z : KExtensionFunction0<A, String>
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A
@@ -7,9 +9,9 @@ fun A.main() {
val y = ::bar
val z = ::baz
x : KExtensionFunction0<A, Unit>
y : KExtensionFunction1<A, Int, Unit>
z : KExtensionFunction0<A, String>
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
}
fun A.foo() {}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class B
@@ -8,9 +10,9 @@ class A {
val y = ::bar
val z = ::baz
x : KExtensionFunction0<A, Unit>
y : KExtensionFunction1<A, Int, Unit>
z : KExtensionFunction0<A, String>
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A
@@ -11,7 +13,7 @@ fun main() {
val y = A::bar
val z = A::baz
x : KExtensionFunction0<A, Unit>
y : KExtensionFunction1<A, Int, Unit>
z : KExtensionFunction0<A, String>
checkSubtype<KExtensionFunction0<A, Unit>>(x)
checkSubtype<KExtensionFunction1<A, Int, Unit>>(y)
checkSubtype<KExtensionFunction0<A, String>>(z)
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
import kotlin.reflect.*
class A {
@@ -6,5 +8,5 @@ class A {
fun A?.foo() {}
val f = A::foo : KMemberFunction0<A, Unit>
val g = A?::foo : KExtensionFunction0<A, Unit>
val f: KMemberFunction0<A, Unit> = A::foo
val g: KExtensionFunction0<A, Unit> = A?::foo
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberFunction0
class A<T>(val t: T) {
@@ -7,5 +9,5 @@ class A<T>(val t: T) {
fun bar() {
val x = A<String>::foo
x : KMemberFunction0<A<String>, String>
checkSubtype<KMemberFunction0<A<String>, String>>(x)
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KMemberFunction0
@@ -8,8 +9,8 @@ class A {
val x = ::Inner
val y = A::Inner
x : KMemberFunction0<A, A.Inner>
y : KMemberFunction0<A, Inner>
checkSubtype<KMemberFunction0<A, A.Inner>>(x)
checkSubtype<KMemberFunction0<A, Inner>>(y)
}
companion object {
@@ -17,7 +18,7 @@ class A {
::<!INACCESSIBLE_OUTER_CLASS_EXPRESSION!>Inner<!>
val y = A::Inner
y : KMemberFunction0<A, A.Inner>
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
}
}
}
@@ -27,6 +28,6 @@ class B {
::<!UNRESOLVED_REFERENCE!>Inner<!>
val y = A::Inner
y : KMemberFunction0<A, A.Inner>
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
}
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KMemberFunction0
@@ -9,13 +10,13 @@ fun A.main() {
val x = ::Inner
val y = A::Inner
x : KMemberFunction0<A, A.Inner>
y : KMemberFunction0<A, A.Inner>
checkSubtype<KMemberFunction0<A, A.Inner>>(x)
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
}
fun Int.main() {
::<!UNRESOLVED_REFERENCE!>Inner<!>
val y = A::Inner
y : KMemberFunction0<A, A.Inner>
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KMemberFunction0
@@ -9,5 +10,5 @@ fun main() {
::<!UNRESOLVED_REFERENCE!>Inner<!>
val y = A::Inner
y : KMemberFunction0<A, A.Inner>
checkSubtype<KMemberFunction0<A, A.Inner>>(y)
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// FILE: test/A.java
package test
@@ -17,7 +18,7 @@ import test.A
fun foo(args: Array<String>) {
val main2 = A::main
main2 : KFunction1<Array<String>, Unit>
checkSubtype<KFunction1<Array<String>, Unit>>(main2)
main2(args)
(A::main)(args)
}
@@ -1,8 +1,10 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction0
fun main() {
class A
val x = ::A
x : KFunction0<A>
checkSubtype<KFunction0<A>>(x)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction0
fun main() {
@@ -6,11 +8,11 @@ fun main() {
class B {
fun Int.foo() {
val x = ::A
x : KFunction0<A>
checkSubtype<KFunction0<A>>(x)
}
fun A.foo() {
val x = ::A
x : KFunction0<A>
checkSubtype<KFunction0<A>>(x)
}
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction0
fun main() {
@@ -5,11 +7,11 @@ fun main() {
fun A.foo() {
val x = ::A
x : KFunction0<A>
checkSubtype<KFunction0<A>>(x)
}
fun Int.foo() {
val x = ::A
x : KFunction0<A>
checkSubtype<KFunction0<A>>(x)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
fun main() {
@@ -9,7 +11,7 @@ fun main() {
val y = ::bar
val z = ::baz
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A
@@ -13,9 +15,9 @@ fun main() {
val y = ::bar
val z = ::baz
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
fun main() {
@@ -11,9 +13,9 @@ fun main() {
val z = ::baz
fun main() {
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A
@@ -12,8 +14,8 @@ fun main() {
val y = ::bar
val z = ::baz
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// FILE: a.kt
package a.b.c
@@ -13,5 +14,5 @@ import kotlin.reflect.KMemberFunction0
fun main() {
val x = a.b.c.D::foo
x : KMemberFunction0<a.b.c.D, Int>
checkSubtype<KMemberFunction0<a.b.c.D, Int>>(x)
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// FILE: a.kt
package a.b.c
@@ -13,5 +14,5 @@ import kotlin.reflect.KMemberFunction2
fun main() {
val x = a.b.c.D<String, Int>::foo
x : KMemberFunction2<a.b.c.D<String, Int>, String, Int, a.b.c.D<String, Int>>
checkSubtype<KMemberFunction2<a.b.c.D<String, Int>, String, Int, a.b.c.D<String, Int>>>(x)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
@@ -10,8 +12,8 @@ class A {
val y = ::bar
val z = ::baz
x : KMemberFunction0<A, Unit>
y : KMemberFunction1<A, Int, Unit>
z : KMemberFunction0<A, String>
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
@@ -11,7 +13,7 @@ fun A.main() {
val y = ::bar
val z = ::baz
x : KMemberFunction0<A, Unit>
y : KMemberFunction1<A, Int, Unit>
z : KMemberFunction0<A, String>
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
@@ -12,8 +14,8 @@ class B {
val y = ::bar
val z = ::baz
x : KMemberFunction0<A, Unit>
y : KMemberFunction1<A, Int, Unit>
z : KMemberFunction0<A, String>
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
@@ -11,7 +13,7 @@ fun main() {
val y = A::bar
val z = A::baz
x : KMemberFunction0<A, Unit>
y : KMemberFunction1<A, Int, Unit>
z : KMemberFunction0<A, String>
checkSubtype<KMemberFunction0<A, Unit>>(x)
checkSubtype<KMemberFunction1<A, Int, Unit>>(y)
checkSubtype<KMemberFunction0<A, String>>(z)
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KFunction0
@@ -8,8 +9,8 @@ class A {
val x = ::Nested
val y = A::Nested
x : KFunction0<Nested>
y : KFunction0<Nested>
checkSubtype<KFunction0<Nested>>(x)
checkSubtype<KFunction0<Nested>>(y)
}
companion object {
@@ -17,7 +18,7 @@ class A {
::Nested
val y = A::Nested
y : KFunction0<A.Nested>
checkSubtype<KFunction0<A.Nested>>(y)
}
}
}
@@ -27,6 +28,6 @@ class B {
::<!UNRESOLVED_REFERENCE!>Nested<!>
val y = A::Nested
y : KFunction0<A.Nested>
checkSubtype<KFunction0<A.Nested>>(y)
}
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KFunction0
@@ -9,12 +10,12 @@ fun A.main() {
::<!NESTED_CLASS_SHOULD_BE_QUALIFIED!>Nested<!>
val y = A::Nested
y : KFunction0<A.Nested>
checkSubtype<KFunction0<A.Nested>>(y)
}
fun Int.main() {
::<!UNRESOLVED_REFERENCE!>Nested<!>
val y = A::Nested
y : KFunction0<A.Nested>
checkSubtype<KFunction0<A.Nested>>(y)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KFunction0
class A {
@@ -7,5 +9,5 @@ class A {
fun main() {
val x = A::Nested
x : KFunction0<A.Nested>
checkSubtype<KFunction0<A.Nested>>(x)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberFunction0
class A {
@@ -9,5 +11,5 @@ fun A.foo() {}
fun main() {
val x = A::foo
x : KMemberFunction0<A, Int>
checkSubtype<KMemberFunction0<A, Int>>(x)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberFunction0
fun foo() {}
@@ -8,6 +10,6 @@ class A {
fun main() {
val x = ::foo
x : KMemberFunction0<A, Unit>
checkSubtype<KMemberFunction0<A, Unit>>(x)
}
}
@@ -1,3 +1,4 @@
// !CHECK_TYPE
// FILE: a.kt
package other
@@ -23,7 +24,7 @@ fun main() {
val y = AA::bar
val z = AA::bazbaz
x : KFunction0<Unit>
y : KMemberFunction0<AA, Int>
z : KExtensionFunction1<AA, String, Unit>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KMemberFunction0<AA, Int>>(y)
checkSubtype<KExtensionFunction1<AA, String, Unit>>(z)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
fun foo() {}
@@ -10,8 +12,8 @@ class A {
val y = ::bar
val z = ::baz
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A
@@ -11,7 +13,7 @@ fun A.main() {
val y = ::bar
val z = ::baz
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A
@@ -12,8 +14,8 @@ class B {
val y = ::bar
val z = ::baz
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
fun foo() {}
@@ -9,7 +11,7 @@ fun main() {
val y = ::bar
val z = ::baz
x : KFunction0<Unit>
y : KFunction1<Int, Unit>
z : KFunction0<String>
checkSubtype<KFunction0<Unit>>(x)
checkSubtype<KFunction1<Int, Unit>>(y)
checkSubtype<KFunction0<String>>(z)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
trait Base {
@@ -18,17 +20,17 @@ class C : B() {
fun test() {
val base = Base::x
base : KMemberProperty<Base, Any>
base.get(A()) : Any
<!TYPE_MISMATCH!>base.get(B())<!> : Number
<!TYPE_MISMATCH!>base.get(C())<!> : Int
checkSubtype<KMemberProperty<Base, Any>>(base)
checkSubtype<Any>(base.get(A()))
checkSubtype<Number>(<!TYPE_MISMATCH!>base.get(B())<!>)
checkSubtype<Int>(<!TYPE_MISMATCH!>base.get(C())<!>)
val a = A::x
a : KMemberProperty<A, String>
a.get(A()) : String
<!TYPE_MISMATCH!>a.get(<!TYPE_MISMATCH!>B()<!>)<!> : Number
checkSubtype<KMemberProperty<A, String>>(a)
checkSubtype<String>(a.get(A()))
checkSubtype<Number>(<!TYPE_MISMATCH!>a.get(<!TYPE_MISMATCH!>B()<!>)<!>)
val b = B::x
b : KMemberProperty<B, Number>
<!TYPE_MISMATCH!>b.get(C())<!> : Int
checkSubtype<KMemberProperty<B, Number>>(b)
checkSubtype<Int>(<!TYPE_MISMATCH!>b.get(C())<!>)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
open class Base {
@@ -8,6 +10,6 @@ open class Derived : Base()
fun test() {
val o = Base::foo
o : KMemberProperty<Base, Int>
o.get(Derived()) : Int
checkSubtype<KMemberProperty<Base, Int>>(o)
checkSubtype<Int>(o.get(Derived()))
}
@@ -1,10 +1,12 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
import kotlin.reflect.*
class A(var g: A) {
val f: Int = 0
fun test() {
::f : KMemberProperty<A, Int>
::g : KMutableMemberProperty<A, A>
val fRef: KMemberProperty<A, Int> = ::f
val gRef: KMutableMemberProperty<A, A> = ::g
}
}
@@ -1,9 +1,11 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
import kotlin.reflect.*
class A {
fun test() {
::foo : KExtensionProperty<A, String>
::bar : KMutableExtensionProperty<A, Int>
val fooRef: KExtensionProperty<A, String> = ::foo
val barRef: KMutableExtensionProperty<A, Int> = ::bar
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
val String.countCharacters: Int
@@ -10,18 +12,18 @@ var Int.meaning: Long
fun test() {
val f = String::countCharacters
f : KTopLevelExtensionProperty<String, Int>
f : KExtensionProperty<String, Int>
<!TYPE_MISMATCH!>f<!> : KMutableExtensionProperty<String, Int>
f.get("abc") : Int
checkSubtype<KTopLevelExtensionProperty<String, Int>>(f)
checkSubtype<KExtensionProperty<String, Int>>(f)
checkSubtype<KMutableExtensionProperty<String, Int>>(<!TYPE_MISMATCH!>f<!>)
checkSubtype<Int>(f.get("abc"))
f.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>set<!>("abc", 0)
val g = Int::meaning
g : KTopLevelExtensionProperty<Int, Long>
g : KExtensionProperty<Int, Long>
g : KMutableTopLevelExtensionProperty<Int, Long>
g : KMutableExtensionProperty<Int, Long>
g.get(0) : Long
checkSubtype<KTopLevelExtensionProperty<Int, Long>>(g)
checkSubtype<KExtensionProperty<Int, Long>>(g)
checkSubtype<KMutableTopLevelExtensionProperty<Int, Long>>(g)
checkSubtype<KMutableExtensionProperty<Int, Long>>(g)
checkSubtype<Long>(g.get(0))
g.set(1, 0L)
}
@@ -1,8 +1,10 @@
// !CHECK_TYPE
val Any?.meaning: Int
get() = 42
fun test() {
val f = Any?::meaning
f.get(null) : Int
f.get("") : Int
checkSubtype<Int>(f.get(null))
checkSubtype<Int>(f.get(""))
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
class A<T>(val t: T) {
@@ -6,9 +8,9 @@ class A<T>(val t: T) {
fun bar() {
val x = A<String>::foo
x : KMemberProperty<A<String>, String>
x : KMemberProperty<A<String>, Any?>
checkSubtype<KMemberProperty<A<String>, String>>(x)
checkSubtype<KMemberProperty<A<String>, Any?>>(x)
val y = A<*>::foo
y : KMemberProperty<A<*>, Any?>
checkSubtype<KMemberProperty<A<*>, Any?>>(y)
}
@@ -1,3 +1,4 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
// FILE: JavaClass.java
public class JavaClass {
@@ -16,10 +17,10 @@ public class JavaClass {
import kotlin.reflect.*
fun test() {
JavaClass::publicFinal : KMemberProperty<JavaClass, Int>
JavaClass::publicMutable : KMutableMemberProperty<JavaClass, Long>
JavaClass::protectedFinal : KMemberProperty<JavaClass, Double>
JavaClass::protectedMutable : KMutableMemberProperty<JavaClass, Char>
JavaClass::<!INVISIBLE_MEMBER!>privateFinal<!> : KMemberProperty<JavaClass, String?>
JavaClass::<!INVISIBLE_MEMBER!>privateMutable<!> : KMutableMemberProperty<JavaClass, Any?>
val pubFinRef: KMemberProperty<JavaClass, Int> = JavaClass::publicFinal
val pubMutRef: KMutableMemberProperty<JavaClass, Long> = JavaClass::publicMutable
val protFinRef: KMemberProperty<JavaClass, Double> = JavaClass::protectedFinal
val protMutRef: KMutableMemberProperty<JavaClass, Char> = JavaClass::protectedMutable
val privFinRef: KMemberProperty<JavaClass, String?> = JavaClass::<!INVISIBLE_MEMBER!>privateFinal<!>
val privMutRef: KMutableMemberProperty<JavaClass, Any?> = JavaClass::<!INVISIBLE_MEMBER!>privateMutable<!>
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
// !DIAGNOSTICS:-UNUSED_VARIABLE
// FILE: JavaClass.java
public class JavaClass {
@@ -18,10 +20,10 @@ import JavaClass.*
import kotlin.reflect.*
fun test() {
::publicFinal : KTopLevelProperty<String>
::publicMutable : KMutableTopLevelProperty<Any?>
::protectedFinal : KProperty<Double>
::protectedMutable : KMutableProperty<Char>
::<!INVISIBLE_MEMBER!>privateFinal<!> : KProperty<JavaClass?>
::<!INVISIBLE_MEMBER!>privateMutable<!> : KMutableProperty<Throwable?>
val pubFinRef: KTopLevelProperty<String> = ::publicFinal
val pubMutRef: KMutableTopLevelProperty<Any?> = ::publicMutable
val protFinRef: KProperty<Double> = ::protectedFinal
val protMutRef: KMutableProperty<Char> = ::protectedMutable
val privFinRef: KProperty<JavaClass?> = ::<!INVISIBLE_MEMBER!>privateFinal<!>
val privMutRef: KMutableProperty<Throwable?> = ::<!INVISIBLE_MEMBER!>privateMutable<!>
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
@@ -13,9 +15,9 @@ fun A.test() {
val y = ::bar
val z = ::self
x : KMemberProperty<A, Unit>
y : KMutableMemberProperty<A, String>
z : KMutableMemberProperty<A, A>
checkSubtype<KMemberProperty<A, Unit>>(x)
checkSubtype<KMutableMemberProperty<A, String>>(y)
checkSubtype<KMutableMemberProperty<A, A>>(z)
y.set(z.get(A()), x.get(A()).toString())
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
@@ -8,16 +10,16 @@ class A {
fun test() {
val p = A::foo
p : KMemberProperty<A, Int>
<!TYPE_MISMATCH!>p<!> : KMutableMemberProperty<A, Int>
p.get(A()) : Int
checkSubtype<KMemberProperty<A, Int>>(p)
checkSubtype<KMutableMemberProperty<A, Int>>(<!TYPE_MISMATCH!>p<!>)
checkSubtype<Int>(p.get(A()))
p.get(<!NO_VALUE_FOR_PARAMETER!>)<!>
p.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>set<!>(A(), 239)
val q = A::bar
q : KMemberProperty<A, String>
q : KMutableMemberProperty<A, String>
q.get(A()): String
checkSubtype<KMemberProperty<A, String>>(q)
checkSubtype<KMutableMemberProperty<A, String>>(q)
checkSubtype<String>(q.get(A()))
q.set(A(), "q")
}
@@ -9,5 +9,5 @@ class C {
fun Int.baz() {}
fun test() {
C::baz checkType { it : _<KMemberProperty<C, Int>>}
C::baz checkType { _<KMemberProperty<C, Int>>() }
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
import kotlin.reflect.*
var x: Int = 42
@@ -5,29 +7,29 @@ val y: String get() = "y"
fun testX() {
val xx = ::x
xx : KMutableTopLevelProperty<Int>
xx : KMutableTopLevelVariable<Int>
xx : KTopLevelProperty<Int>
xx : KTopLevelVariable<Int>
xx : KMutableProperty<Int>
xx : KMutableVariable<Int>
xx : KProperty<Int>
xx : KCallable<Int>
checkSubtype<KMutableTopLevelProperty<Int>>(xx)
checkSubtype<KMutableTopLevelVariable<Int>>(xx)
checkSubtype<KTopLevelProperty<Int>>(xx)
checkSubtype<KTopLevelVariable<Int>>(xx)
checkSubtype<KMutableProperty<Int>>(xx)
checkSubtype<KMutableVariable<Int>>(xx)
checkSubtype<KProperty<Int>>(xx)
checkSubtype<KCallable<Int>>(xx)
xx.name : String
xx.get() : Int
checkSubtype<String>(xx.name)
checkSubtype<Int>(xx.get())
xx.set(239)
}
fun testY() {
val yy = ::y
<!TYPE_MISMATCH!>yy<!> : KMutableTopLevelProperty<String>
yy : KTopLevelVariable<String>
<!TYPE_MISMATCH!>yy<!> : KMutableProperty<String>
yy : KProperty<String>
yy : KCallable<String>
checkSubtype<KMutableTopLevelProperty<String>>(<!TYPE_MISMATCH!>yy<!>)
checkSubtype<KTopLevelVariable<String>>(yy)
checkSubtype<KMutableProperty<String>>(<!TYPE_MISMATCH!>yy<!>)
checkSubtype<KProperty<String>>(yy)
checkSubtype<KCallable<String>>(yy)
yy.name : String
yy.get() : String
checkSubtype<String>(yy.name)
checkSubtype<String>(yy.get())
yy.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>set<!>("yy")
}