Move callable reference diagnostic tests to non-stdlib

This commit is contained in:
Alexander Udalov
2015-04-20 11:01:07 +03:00
parent 51684b3fe1
commit 90097d7e8b
144 changed files with 465 additions and 465 deletions
@@ -0,0 +1,36 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
interface Base {
val x: Any
}
class A : Base {
override val x: String = ""
}
open class B : Base {
override val x: Number = 1.0
}
class C : B() {
override val x: Int = 42
}
fun test() {
val base = Base::x
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
checkSubtype<KMemberProperty<A, String>>(a)
checkSubtype<String>(a.get(A()))
checkSubtype<Number>(<!TYPE_MISMATCH!>a.get(<!TYPE_MISMATCH!>B()<!>)<!>)
val b = B::x
checkSubtype<KMemberProperty<B, Number>>(b)
checkSubtype<Int>(<!TYPE_MISMATCH!>b.get(C())<!>)
}
@@ -0,0 +1,34 @@
package
internal fun test(): kotlin.Unit
internal final class A : Base {
public constructor A()
internal open override /*1*/ val x: kotlin.String = ""
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal open class B : Base {
public constructor B()
internal open override /*1*/ val x: kotlin.Number = 1.0.toDouble()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal interface Base {
internal abstract val x: kotlin.Any
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class C : B {
public constructor C()
internal open override /*1*/ val x: kotlin.Int = 42
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,15 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
open class Base {
val foo: Int = 42
}
open class Derived : Base()
fun test() {
val o = Base::foo
checkSubtype<KMemberProperty<Base, Int>>(o)
checkSubtype<Int>(o.get(Derived()))
}
@@ -0,0 +1,19 @@
package
internal fun test(): kotlin.Unit
internal open class Base {
public constructor Base()
internal final val foo: kotlin.Int = 42
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal open class Derived : Base {
public constructor Derived()
internal final override /*1*/ /*fake_override*/ val foo: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
import kotlin.reflect.*
class A(var g: A) {
val f: Int = 0
fun test() {
val fRef: KMemberProperty<A, Int> = ::f
val gRef: KMutableMemberProperty<A, A> = ::g
}
}
@@ -0,0 +1,11 @@
package
internal final class A {
public constructor A(/*0*/ g: A)
internal final val f: kotlin.Int = 0
internal final var g: A
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
internal final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
import kotlin.reflect.*
class A {
fun test() {
val fooRef: KExtensionProperty<A, String> = ::foo
val barRef: KMutableExtensionProperty<A, Int> = ::bar
}
}
val A.foo: String get() = ""
var A.bar: Int
get() = 42
set(value) { }
@@ -0,0 +1,12 @@
package
internal var A.bar: kotlin.Int
internal val A.foo: kotlin.String
internal final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
internal final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,29 @@
// !CHECK_TYPE
import kotlin.reflect.*
val String.countCharacters: Int
get() = length()
var Int.meaning: Long
get() = 42L
set(value) {}
fun test() {
val f = String::countCharacters
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!>set<!>("abc", 0)
val g = Int::meaning
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)
}
@@ -0,0 +1,5 @@
package
internal val kotlin.String.countCharacters: kotlin.Int
internal var kotlin.Int.meaning: kotlin.Long
internal fun test(): kotlin.Unit
@@ -0,0 +1,10 @@
// !CHECK_TYPE
val Any?.meaning: Int
get() = 42
fun test() {
val f = Any?::meaning
checkSubtype<Int>(f.get(null))
checkSubtype<Int>(f.get(""))
}
@@ -0,0 +1,4 @@
package
internal val kotlin.Any?.meaning: kotlin.Int
internal fun test(): kotlin.Unit
@@ -0,0 +1,16 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
class A<T>(val t: T) {
val foo: T = t
}
fun bar() {
val x = A<String>::foo
checkSubtype<KMemberProperty<A<String>, String>>(x)
checkSubtype<KMemberProperty<A<String>, Any?>>(x)
val y = A<*>::foo
checkSubtype<KMemberProperty<A<*>, Any?>>(y)
}
@@ -0,0 +1,12 @@
package
internal fun bar(): kotlin.Unit
internal final class A</*0*/ T> {
public constructor A</*0*/ T>(/*0*/ t: T)
internal final val foo: T
internal final val t: T
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,26 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
// FILE: JavaClass.java
public class JavaClass {
public final int publicFinal;
public long publicMutable;
protected final double protectedFinal;
protected char protectedMutable;
private final String privateFinal;
private Object privateMutable;
}
// FILE: test.kt
import kotlin.reflect.*
fun test() {
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<!>
}
@@ -0,0 +1,16 @@
package
internal fun test(): kotlin.Unit
public open class JavaClass {
public constructor JavaClass()
private final val privateFinal: kotlin.String!
private final var privateMutable: kotlin.Any!
protected/*protected and package*/ final val protectedFinal: kotlin.Double
protected/*protected and package*/ final var protectedMutable: kotlin.Char
public final val publicFinal: kotlin.Int
public final var publicMutable: kotlin.Long
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,29 @@
// !CHECK_TYPE
// !DIAGNOSTICS:-UNUSED_VARIABLE
// FILE: JavaClass.java
public class JavaClass {
public static final String publicFinal;
public static volatile Object publicMutable;
protected static final double protectedFinal;
protected static char protectedMutable;
private static final JavaClass privateFinal;
private static Throwable privateMutable;
}
// FILE: test.kt
import JavaClass.*
import kotlin.reflect.*
fun test() {
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<!>
}
@@ -0,0 +1,18 @@
package
internal fun test(): kotlin.Unit
public open class JavaClass {
public constructor JavaClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
private final val privateFinal: JavaClass!
private final var privateMutable: kotlin.Throwable!
protected/*protected static*/ final val protectedFinal: kotlin.Double
protected/*protected static*/ final var protectedMutable: kotlin.Char
public final val publicFinal: kotlin.String!
public final var publicMutable: kotlin.Any!
}
@@ -0,0 +1,12 @@
import kotlin.reflect.*
fun <T> checkSubtype(t: T) = t
class A(var g: A) {
val f: Int = 0
fun test() {
checkSubtype<KMemberProperty<A, Int>>(::f)
checkSubtype<KMutableMemberProperty<A, A>>(::g)
}
}
@@ -0,0 +1,13 @@
package
internal fun </*0*/ T> checkSubtype(/*0*/ t: T): T
internal final class A {
public constructor A(/*0*/ g: A)
internal final val f: kotlin.Int = 0
internal final var g: A
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
internal final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun test(param: String) {
val a = ::<!UNSUPPORTED!>param<!>
val local = "local"
val b = ::<!UNSUPPORTED!>local<!>
val lambda = { -> }
val g = ::<!UNSUPPORTED!>lambda<!>
}
@@ -0,0 +1,3 @@
package
internal fun test(/*0*/ param: kotlin.String): kotlin.Unit
@@ -0,0 +1,23 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
val foo: Unit = Unit
var bar: String = ""
var self: A
get() = this
set(value) { }
}
fun A.test() {
val x = ::foo
val y = ::bar
val z = ::self
checkSubtype<KMemberProperty<A, Unit>>(x)
checkSubtype<KMutableMemberProperty<A, String>>(y)
checkSubtype<KMutableMemberProperty<A, A>>(z)
y.set(z.get(A()), x.get(A()).toString())
}
@@ -0,0 +1,13 @@
package
internal fun A.test(): kotlin.Unit
internal final class A {
public constructor A()
internal final var bar: kotlin.String
internal final val foo: kotlin.Unit
internal final var self: A
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,25 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
val foo: Int = 42
var bar: String = ""
}
fun test() {
val p = A::foo
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!>set<!>(A(), 239)
val q = A::bar
checkSubtype<KMemberProperty<A, String>>(q)
checkSubtype<KMutableMemberProperty<A, String>>(q)
checkSubtype<String>(q.get(A()))
q.set(A(), "q")
}
@@ -0,0 +1,12 @@
package
internal fun test(): kotlin.Unit
internal final class A {
public constructor A()
internal final var bar: kotlin.String
internal final val foo: kotlin.Int = 42
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,13 @@
// !CHECK_TYPE
import kotlin.reflect.KMemberProperty
class C {
val baz: Int = 12
}
fun Int.baz() {}
fun test() {
C::baz checkType { _<KMemberProperty<C, Int>>() }
}
@@ -0,0 +1,12 @@
package
internal fun test(): kotlin.Unit
internal fun kotlin.Int.baz(): kotlin.Unit
internal final class C {
public constructor C()
internal final val baz: kotlin.Int = 12
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,35 @@
// !CHECK_TYPE
import kotlin.reflect.*
var x: Int = 42
val y: String get() = "y"
fun testX() {
val xx = ::x
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)
checkSubtype<String>(xx.name)
checkSubtype<Int>(xx.get())
xx.set(239)
}
fun testY() {
val yy = ::y
checkSubtype<KMutableTopLevelProperty<String>>(<!TYPE_MISMATCH!>yy<!>)
checkSubtype<KTopLevelVariable<String>>(yy)
checkSubtype<KMutableProperty<String>>(<!TYPE_MISMATCH!>yy<!>)
checkSubtype<KProperty<String>>(yy)
checkSubtype<KCallable<String>>(yy)
checkSubtype<String>(yy.name)
checkSubtype<String>(yy.get())
yy.<!UNRESOLVED_REFERENCE!>set<!>("yy")
}
@@ -0,0 +1,6 @@
package
internal var x: kotlin.Int
internal val y: kotlin.String
internal fun testX(): kotlin.Unit
internal fun testY(): kotlin.Unit