[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fun f1() = Map::hashCode
|
||||
fun f2() = Map.Entry::hashCode
|
||||
|
||||
class Outer<T> {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun f3() = Outer.Inner::hashCode
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package a
|
||||
|
||||
import b.B.*
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class Companion
|
||||
|
||||
val f: KClass<a.Companion> = Companion::class
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package b
|
||||
|
||||
class B {
|
||||
companion object Companion
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package a
|
||||
|
||||
import b.*
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class A
|
||||
object B
|
||||
|
||||
val f: KClass<a.A> = A::class
|
||||
val g: KClass<a.B> = B::class
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package b
|
||||
|
||||
object A
|
||||
object B
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
fun foo(): String = "companion"
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
fun foo(): Int = 0
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val r1 = C::foo
|
||||
checkSubtype<(C) -> Int>(r1)
|
||||
|
||||
val r2 = test.C::foo
|
||||
checkSubtype<(C) -> Int>(r2)
|
||||
|
||||
val r3 = C.Companion::foo
|
||||
checkSubtype<() -> String>(r3)
|
||||
|
||||
val r4 = test.C.Companion::foo
|
||||
checkSubtype<() -> String>(r4)
|
||||
|
||||
val r5 = (C)::foo
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><() -> String>(r5)
|
||||
|
||||
val r6 = (test.C)::foo
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><() -> String>(r6)
|
||||
|
||||
val c = C.Companion
|
||||
val r7 = c::foo
|
||||
checkSubtype<() -> String>(r7)
|
||||
|
||||
C::bar
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
fun unusedExpression(s: String) {
|
||||
s::hashCode
|
||||
s::class
|
||||
}
|
||||
|
||||
fun noUnusedParameter(s: String): Int {
|
||||
val f = s::hashCode
|
||||
return f()
|
||||
}
|
||||
|
||||
fun unreachableCode(): Int {
|
||||
(if (true) return 1 else return 0)::toString
|
||||
return 0
|
||||
}
|
||||
|
||||
fun unreachableCodeInLoop(): Int {
|
||||
while (true) {
|
||||
(break)::toString
|
||||
return 1
|
||||
}
|
||||
return 2
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
fun f1(x: String?): String {
|
||||
x!!::hashCode
|
||||
return x
|
||||
}
|
||||
|
||||
fun f2(y: String?): String {
|
||||
val f: KClass<*> = (y ?: return "")::class
|
||||
return y
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
fun test(s: String) {
|
||||
val f: () -> Int = s::hashCode
|
||||
val g: () -> String = s::toString
|
||||
val h: (Any?) -> Boolean = s::equals
|
||||
|
||||
val k: KClass<out String> = s::class
|
||||
val l: KClass<*> = s::class
|
||||
val m: KClass<String> = String::class
|
||||
val n: KClass<Unit> = Unit::class
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// FILE: J.java
|
||||
|
||||
public interface J {
|
||||
String platformString();
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun f1(x: Int?): Any = x::hashCode
|
||||
fun <T> f2(t: T): Any = t::hashCode
|
||||
fun <S : String?> f3(s: S): Any = s::hashCode
|
||||
fun <U : Any> f4(u: U?): Any = u::hashCode
|
||||
fun f5(c: List<*>): Any = c[0]::hashCode
|
||||
|
||||
fun f6(j: J): Any = j.platformString()::hashCode
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
fun test() = ("").<!UNRESOLVED_REFERENCE!>hashCode<!>::hashCode
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Outer {
|
||||
class Nested
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun test() {
|
||||
Outer()::Inner
|
||||
Outer()::Nested
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
fun bar() {}
|
||||
fun f() = <!UNRESOLVED_REFERENCE!>Unresolved<!>()::bar
|
||||
}
|
||||
|
||||
val f: () -> Unit = <!UNRESOLVED_REFERENCE!>Unresolved<!>()::foo
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
open class A(val x: Any)
|
||||
|
||||
class B : A(this::class)
|
||||
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
object Obj {
|
||||
fun foo() {}
|
||||
val bar = 2
|
||||
}
|
||||
|
||||
fun test() {
|
||||
checkSubtype<() -> Unit>(Obj::foo)
|
||||
checkSubtype<() -> Int>(Obj::bar)
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
class Foo<out T>(name: T) {
|
||||
private var prop: T = name
|
||||
private set
|
||||
|
||||
fun testProp() {
|
||||
val ok1 = this::prop
|
||||
val ok2 = this@Foo::prop
|
||||
val ok3 = object { val y: Any = this@Foo::prop }
|
||||
|
||||
val fail1 = Foo(prop)::prop
|
||||
}
|
||||
|
||||
fun testFunc() {
|
||||
val ok1 = this::func
|
||||
val ok2 = this@Foo::func
|
||||
val ok3 = object { val y: Any = this@Foo::func }
|
||||
|
||||
val fail1 = Foo(prop)::func
|
||||
}
|
||||
|
||||
private fun func(t: T): T = t
|
||||
}
|
||||
compiler/testData/diagnostics/tests/callableReference/bound/referenceToStaticMethodOnInstance.fir.kt
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public static void test() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
enum class E { EN }
|
||||
|
||||
fun test() {
|
||||
A()::test
|
||||
E.EN::valueOf
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
package test
|
||||
|
||||
object ClassMemberMarker
|
||||
|
||||
class a<T> {
|
||||
fun foo() = ClassMemberMarker
|
||||
}
|
||||
|
||||
class b<T1, T2> {
|
||||
fun foo() = ClassMemberMarker
|
||||
}
|
||||
|
||||
fun Int.foo() {}
|
||||
|
||||
class Test {
|
||||
val <T> List<T>.a: Int get() = size
|
||||
val <T> List<T>.b: Int? get() = size
|
||||
|
||||
fun <T> List<T>.testCallable1(): () -> Unit = a<T>::foo
|
||||
fun <T> List<T>.testCallable2(): () -> Unit = b?::foo
|
||||
fun <T> List<T>.testCallable3(): () -> Unit = b<T, Any>::foo
|
||||
fun <T> List<T>.testCallable4(): () -> Unit = b<T>?::foo
|
||||
|
||||
fun <T> List<T>.testClassLiteral1() = a<T>::class
|
||||
fun <T> List<T>.testClassLiteral2() = b?::class
|
||||
fun <T> List<T>.testClassLiteral3() = b<T, Any>::class
|
||||
|
||||
fun <T> List<T>.testUnresolved1() = <!UNRESOLVED_REFERENCE!>unresolved<!><T>::foo
|
||||
fun <T> List<T>.testUnresolved2() = a<unresolved>::foo
|
||||
fun <T> List<T>.testUnresolved3() = a<<!SYNTAX!><!>>::foo
|
||||
fun <T> List<T>.testUnresolved4() = <!UNRESOLVED_REFERENCE!>unresolved<!>?::foo
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
package test
|
||||
|
||||
fun nullableFun(): Int? = null
|
||||
fun Int.foo() {}
|
||||
|
||||
val test1 = nullableFun()?::foo
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
package test
|
||||
|
||||
object Wrong
|
||||
object Right
|
||||
|
||||
class a {
|
||||
class b<T> {
|
||||
class c {
|
||||
fun foo() = Wrong
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Int.foo() = Right
|
||||
|
||||
class Test {
|
||||
val a: List<Int> = null!!
|
||||
|
||||
val <T> List<T>.b: Int get() = 42
|
||||
|
||||
val Int.c: Int get() = 42
|
||||
|
||||
val test1: () -> Right = a.b<Int>.c::foo
|
||||
val test1a: () -> Right = a.b.c::foo
|
||||
|
||||
val test2: () -> Right = a.b<Int>.c?::foo
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// FILE: A.java
|
||||
|
||||
class A {
|
||||
public CharSequence getFoo() { return null; }
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
with (A()) {
|
||||
foo::toString
|
||||
}
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun <T: Any> get(t: T): () -> String {
|
||||
return t::toString
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun test() {
|
||||
val a = if (true) {
|
||||
val x = 1
|
||||
"".length
|
||||
<!UNRESOLVED_REFERENCE!>::foo<!>
|
||||
} else {
|
||||
<!UNRESOLVED_REFERENCE!>::foo<!>
|
||||
}
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction0<Int>>() }
|
||||
}
|
||||
|
||||
fun foo(): Int = 0
|
||||
@@ -0,0 +1,24 @@
|
||||
// MODULE: m1
|
||||
// FILE: 1.kt
|
||||
|
||||
package a
|
||||
|
||||
class b {
|
||||
class c
|
||||
}
|
||||
|
||||
// MODULE: m2
|
||||
// FILE: 2.kt
|
||||
|
||||
package a.b
|
||||
|
||||
class c {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
// MODULE: m3(m1, m2)
|
||||
// FILE: test.kt
|
||||
|
||||
package test
|
||||
|
||||
fun test() = a.b.c::foo
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
interface A
|
||||
inline val <T : A> T.bla get() = 1
|
||||
|
||||
class B<T>
|
||||
fun <K, V> B<K>.foo(p: KProperty1<in K, V>): B<V> = TODO()
|
||||
|
||||
fun <K, V> B<out K>.bar(p: KProperty1<out K, V>): B<V> = TODO()
|
||||
|
||||
fun <K, V> B<K>.baz(p: KProperty1<out K, V>): B<V> = TODO()
|
||||
|
||||
fun <K, V> B<K>.star(p: KProperty1<*, V>): B<V> = TODO()
|
||||
|
||||
|
||||
fun <R : A> B<R>.test(){
|
||||
foo(A::bla)
|
||||
bar(A::bla)
|
||||
<!INAPPLICABLE_CANDIDATE!>baz<!>(A::bla)
|
||||
star(A::bla)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
class DTO {
|
||||
val q: Int = 0
|
||||
operator fun get(prop: KProperty1<*, Int>): Int = 0
|
||||
}
|
||||
|
||||
fun foo(intDTO: DTO?, p: KProperty1<*, Int>) {
|
||||
if (intDTO != null) {
|
||||
intDTO[DTO::q]
|
||||
intDTO.q
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// Different modules are important for this test because otherwise everything is analyzed at once and some errors
|
||||
// already exist in the binding context when we're analyzing "User::surname".
|
||||
// (The assertion at DoubleColonExpressionResolver.checkNoExpressionOnLHS is only performed when there are no errors in the binding context)
|
||||
|
||||
// MODULE: m1
|
||||
// FILE: bar.kt
|
||||
|
||||
fun <T> bar(ff: Err.() -> Unit) {
|
||||
}
|
||||
|
||||
// MODULE: m2(m1)
|
||||
// FILE: foo.kt
|
||||
|
||||
data class User(val surname: String)
|
||||
|
||||
fun foo() {
|
||||
bar<String> {
|
||||
User::surname
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION, -EXTENSION_SHADOWED_BY_MEMBER
|
||||
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
|
||||
|
||||
val topLevelVal = 1
|
||||
fun topLevelFun() = 2
|
||||
|
||||
val A.extensionVal: Int get() = 3
|
||||
fun A.extensionFun(): Int = 4
|
||||
|
||||
class A {
|
||||
val memberVal = 5
|
||||
fun memberFun() = 6
|
||||
|
||||
val ok1 = ::topLevelVal
|
||||
val ok2 = ::topLevelFun
|
||||
|
||||
fun fail1() {
|
||||
::extensionVal
|
||||
::extensionFun
|
||||
}
|
||||
|
||||
fun fail2() {
|
||||
::memberVal
|
||||
::memberFun
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
val ok1 = ::topLevelVal
|
||||
val ok2 = ::topLevelFun
|
||||
|
||||
fun A.fail1() {
|
||||
::extensionVal
|
||||
::extensionFun
|
||||
}
|
||||
|
||||
fun A.fail2() {
|
||||
::memberVal
|
||||
::memberFun
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
abstract class SubFunction : kotlin.Function0<Unit>
|
||||
|
||||
fun <T> takeIt(x: T, f: SubFunction) {}
|
||||
|
||||
fun cr() {}
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>takeIt<!>(42, ::cr)
|
||||
<!INAPPLICABLE_CANDIDATE!>takeIt<!>(42, { })
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
interface A
|
||||
abstract class B
|
||||
annotation class C
|
||||
enum class D
|
||||
|
||||
fun main() {
|
||||
::A
|
||||
::B
|
||||
::C // KT-3465
|
||||
::D
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
|
||||
fun foo(x: Int, y: Any) = x
|
||||
fun foo(x: Any, y: Int) = y
|
||||
|
||||
fun main() {
|
||||
<!UNRESOLVED_REFERENCE!>::foo<!>
|
||||
|
||||
val fooRef: (Int, Any) -> Unit = <!UNRESOLVED_REFERENCE!>::foo<!>
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
annotation class Ann(val prop: String)
|
||||
|
||||
val annCtorRef = ::Ann
|
||||
val annClassRef = Ann::class
|
||||
val annPropRef = Ann::prop
|
||||
compiler/testData/diagnostics/tests/callableReference/function/callableRefrenceOnNestedObject.fir.kt
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
open class A {
|
||||
fun foo() = 42
|
||||
|
||||
object B: A()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
(A::foo)(A.B)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// FILE: Foo.kt
|
||||
|
||||
package test
|
||||
|
||||
class Foo {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
import test.Foo
|
||||
|
||||
fun Foo(): String = ""
|
||||
|
||||
val f = Foo::bar
|
||||
val g = Foo::length
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A {
|
||||
fun main() {
|
||||
val x = ::A
|
||||
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
}
|
||||
|
||||
class SomeOtherClass {
|
||||
fun main() {
|
||||
val x = ::A
|
||||
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// FILE: A.kt
|
||||
|
||||
open class A<T>(val x: T)
|
||||
|
||||
// FILE: AFactory.kt
|
||||
|
||||
abstract class AFactory {
|
||||
abstract fun create(): A<Int>?
|
||||
}
|
||||
|
||||
// FILE: Util.kt
|
||||
|
||||
inline fun <reified T> createWith(x: T, f: (T) -> A<T>?)
|
||||
= f(x)
|
||||
|
||||
// FILE: B.kt
|
||||
|
||||
class B(x: Int) : A<Int>(x) {
|
||||
companion object : AFactory() {
|
||||
override fun create(): A<Int>? = createWith(0, ::B)
|
||||
}
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A
|
||||
class B
|
||||
|
||||
fun A.ext() {
|
||||
val x = ::A
|
||||
val y = ::B
|
||||
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
checkSubtype<KFunction0<B>>(y)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A
|
||||
|
||||
class B {
|
||||
fun A.ext() {
|
||||
val x = ::A
|
||||
val y = ::B
|
||||
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
checkSubtype<KFunction0<B>>(y)
|
||||
}
|
||||
|
||||
fun B.ext() {
|
||||
val x = ::A
|
||||
val y = ::B
|
||||
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
checkSubtype<KFunction0<B>>(y)
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
val x = ::A
|
||||
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// KT-15951 Callable reference to class constructor from object is not resolved
|
||||
|
||||
object A {
|
||||
class Wrapper
|
||||
}
|
||||
|
||||
class Outer {
|
||||
companion object {
|
||||
class Wrapper
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
A::Wrapper
|
||||
(A)::Wrapper
|
||||
|
||||
Outer.Companion::Wrapper
|
||||
(Outer.Companion)::Wrapper
|
||||
Outer::Wrapper
|
||||
(Outer)::Wrapper
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: a.kt
|
||||
|
||||
package first
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package other
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
import first.A
|
||||
|
||||
fun main() {
|
||||
val x = first.A::foo
|
||||
val y = first.A::bar
|
||||
val z = A::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
// FILE: a.kt
|
||||
|
||||
package first
|
||||
|
||||
class A
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar() {}
|
||||
fun A.baz() {}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package other
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
import first.A
|
||||
import first.foo
|
||||
|
||||
fun main() {
|
||||
val x = first.A::foo
|
||||
first.A::bar
|
||||
A::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: a.kt
|
||||
|
||||
package first
|
||||
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package other
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
import first.foo
|
||||
import first.bar
|
||||
import first.baz
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
val x = :: <!SYNTAX!><!>;
|
||||
val y = A::
|
||||
<!SYNTAX!><!>}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar(x: Int) {}
|
||||
fun A.baz() = "OK"
|
||||
|
||||
fun main() {
|
||||
val x = A::foo
|
||||
val y = A::bar
|
||||
val z = A::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<Unit>>(x)
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<Unit>>(y)
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<String>>(z)
|
||||
}
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
class A {
|
||||
fun Int.extInt() = 42
|
||||
fun A.extA(x: String) = x
|
||||
|
||||
fun main() {
|
||||
Int::extInt
|
||||
A::extA
|
||||
|
||||
eat(Int::extInt)
|
||||
eat(A::extA)
|
||||
}
|
||||
}
|
||||
|
||||
fun eat(value: Any) {}
|
||||
|
||||
fun main() {
|
||||
A::extInt
|
||||
A::extA
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !DIAGNOSTICS:-UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun A?.foo() {}
|
||||
|
||||
val f: KFunction1<A, Unit> = A::foo
|
||||
val g: KFunction1<A, Unit> = A?::foo
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
interface A
|
||||
interface B : A
|
||||
|
||||
fun A.foo() {}
|
||||
|
||||
fun take(f: (A) -> Unit) {}
|
||||
fun take(f: () -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
B::foo checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction1<B, Unit>>() }
|
||||
|
||||
take(B::foo)
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
open class A {
|
||||
fun foo(s: String): String = s
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
}
|
||||
|
||||
|
||||
fun test() {
|
||||
B::foo checkType { <!UNRESOLVED_REFERENCE!>_<!><KFunction2<B, String, String>>() }
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>(B::hashCode)("No.")<!>
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
class A<T>(val t: T) {
|
||||
fun foo(): T = t
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
val x = A<String>::foo
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction1<A<String>, String>>(x)
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
import A.Inner
|
||||
|
||||
class A {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun main() {
|
||||
::Inner
|
||||
}
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
class A {
|
||||
inner class Inner
|
||||
|
||||
fun main() {
|
||||
::Inner
|
||||
val y = A::Inner
|
||||
|
||||
checkSubtype<KFunction1<A, Inner>>(y)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun main() {
|
||||
::Inner
|
||||
val y = A::Inner
|
||||
|
||||
checkSubtype<KFunction1<A, A.Inner>>(y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun main() {
|
||||
::Inner
|
||||
val y = A::Inner
|
||||
|
||||
checkSubtype<KFunction1<A, A.Inner>>(y)
|
||||
}
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
class A {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun A.main() {
|
||||
::Inner
|
||||
val y = A::Inner
|
||||
|
||||
checkSubtype<KFunction1<A, A.Inner>>(y)
|
||||
}
|
||||
|
||||
fun Int.main() {
|
||||
::Inner
|
||||
val y = A::Inner
|
||||
|
||||
checkSubtype<KFunction1<A, A.Inner>>(y)
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
class A {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun main() {
|
||||
::Inner
|
||||
val y = A::Inner
|
||||
|
||||
checkSubtype<KFunction1<A, A.Inner>>(y)
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: test/A.java
|
||||
|
||||
package test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class A {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Arrays.asList(args));
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import test.A
|
||||
|
||||
fun foo(args: Array<String>) {
|
||||
val main2 = A::main
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction1<Array<String>, Unit>>(main2)
|
||||
<!INAPPLICABLE_CANDIDATE!>main2<!>(args)
|
||||
<!INAPPLICABLE_CANDIDATE!>(A::main)(args)<!>
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class A<T, U : Any> {
|
||||
fun foo() = <!OTHER_ERROR!>T<!>::toString
|
||||
|
||||
fun bar() = <!OTHER_ERROR!>U<!>::toString
|
||||
}
|
||||
|
||||
fun <T> foo() = <!OTHER_ERROR!>T<!>::toString
|
||||
|
||||
fun <U : Any> bar() = <!OTHER_ERROR!>U<!>::toString
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
val x = ::A
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
class B {
|
||||
fun Int.foo() {
|
||||
val x = ::A
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
fun A.foo() {
|
||||
val x = ::A
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
}
|
||||
}
|
||||
compiler/testData/diagnostics/tests/callableReference/function/localConstructorFromLocalClass.fir.kt
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
class B {
|
||||
val x = ::A
|
||||
val f: KFunction0<A> = x
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
fun A.foo() {
|
||||
val x = ::A
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
|
||||
fun Int.foo() {
|
||||
val x = ::A
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun main() {
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
class B {
|
||||
fun A.ext() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun main() {
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
class A {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
fun main() {
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
fun A.ext() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: a.kt
|
||||
|
||||
package a.b.c
|
||||
|
||||
class D {
|
||||
fun foo() = 42
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
fun main() {
|
||||
val x = a.b.c.D::foo
|
||||
|
||||
checkSubtype<KFunction1<a.b.c.D, Int>>(x)
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: a.kt
|
||||
|
||||
package a.b.c
|
||||
|
||||
class D<E, F> {
|
||||
fun foo(e: E, f: F) = this
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
import kotlin.reflect.KFunction3
|
||||
|
||||
fun main() {
|
||||
val x = a.b.c.D<String, Int>::foo
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction3<a.b.c.D<String, Int>, String, Int, a.b.c.D<String, Int>>>(x)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x = A::foo
|
||||
val y = A::bar
|
||||
val z = A::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<Unit>>(x)
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<Unit>>(y)
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction<String>>(z)
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A {
|
||||
class Nested
|
||||
|
||||
fun main() {
|
||||
val x = ::Nested
|
||||
val y = A::Nested
|
||||
|
||||
checkSubtype<KFunction0<Nested>>(x)
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction0<Nested>>(y)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun main() {
|
||||
::Nested
|
||||
val y = A::Nested
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction0<A.Nested>>(y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun main() {
|
||||
::Nested
|
||||
val y = A::Nested
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction0<A.Nested>>(y)
|
||||
}
|
||||
}
|
||||
compiler/testData/diagnostics/tests/callableReference/function/nestedConstructorFromExtension.fir.kt
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A {
|
||||
class Nested
|
||||
}
|
||||
|
||||
fun A.main() {
|
||||
::Nested
|
||||
val y = A::Nested
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction0<A.Nested>>(y)
|
||||
}
|
||||
|
||||
fun Int.main() {
|
||||
::Nested
|
||||
val y = A::Nested
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction0<A.Nested>>(y)
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A {
|
||||
class Nested
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x = A::Nested
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><KFunction0<A.Nested>>(x)
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
fun bar() = 42
|
||||
|
||||
fun main() {
|
||||
fun bar() = 239
|
||||
|
||||
::bar
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
class A {
|
||||
fun foo() = 42
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
|
||||
fun main() {
|
||||
val x = A::foo
|
||||
|
||||
checkSubtype<KFunction1<A, Int>>(x)
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// !CHECK_TYPE
|
||||
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun expectFunction0Unit(f: () -> Unit) = f
|
||||
fun expectFunction0String(f: () -> String) = f
|
||||
fun expectFunction1Unit(f: (A) -> Unit) = f
|
||||
fun expectFunction1String(f: (A) -> String) = f
|
||||
|
||||
fun foo(): String = ""
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
|
||||
expectFunction0Unit(x)
|
||||
<!INAPPLICABLE_CANDIDATE!>expectFunction0String<!>(x)
|
||||
<!INAPPLICABLE_CANDIDATE!>expectFunction1Unit<!>(x)
|
||||
<!INAPPLICABLE_CANDIDATE!>expectFunction1String<!>(x)
|
||||
|
||||
expectFunction0Unit(::foo)
|
||||
expectFunction0String(::foo)
|
||||
<!INAPPLICABLE_CANDIDATE!>expectFunction1Unit<!>(::foo)
|
||||
<!INAPPLICABLE_CANDIDATE!>expectFunction1String<!>(::foo)
|
||||
}
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// SKIP_TXT
|
||||
// FILE: A.java
|
||||
class A {
|
||||
private static void foo() {}
|
||||
public String foo(int x) {}
|
||||
}
|
||||
// FILE: main.kt
|
||||
fun main() {
|
||||
(A::foo)(A(), 1)
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: a.kt
|
||||
|
||||
package other
|
||||
|
||||
fun foo() {}
|
||||
|
||||
class A {
|
||||
fun bar() = 42
|
||||
}
|
||||
|
||||
fun A.baz(x: String) {}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
import other.foo as foofoo
|
||||
import other.A as AA
|
||||
import other.baz as bazbaz
|
||||
|
||||
fun main() {
|
||||
val x = ::foofoo
|
||||
val y = AA::bar
|
||||
val z = AA::bazbaz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<AA, Int>>(y)
|
||||
checkSubtype<KFunction2<AA, String, Unit>>(z)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
class A {
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A
|
||||
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A
|
||||
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
class B {
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction0<Unit>>(x)
|
||||
checkSubtype<KFunction1<Int, Unit>>(y)
|
||||
checkSubtype<KFunction0<String>>(z)
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION, -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
class A
|
||||
|
||||
fun test1() {
|
||||
val foo = ::foo
|
||||
|
||||
::bar
|
||||
|
||||
A::bar
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>B<!>::bar
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
fun foo(x: Any) {}
|
||||
fun foo() {}
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>Unresolved<!>::foo
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(<!UNRESOLVED_REFERENCE!>Unresolved<!>::foo)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(<!UNRESOLVED_REFERENCE!>Unresolved<!>::unresolved)
|
||||
::unresolved
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
fun foo(a: String, b: Int = 5): String {
|
||||
return a + b
|
||||
}
|
||||
|
||||
fun bar1(body: (String) -> String): String {
|
||||
return body("something")
|
||||
}
|
||||
|
||||
fun bar2(body: (String, Int) -> String): String {
|
||||
return body("something", 0)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>bar1<!>(::foo)
|
||||
bar2(::foo)
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType
|
||||
|
||||
fun foo(a: String, b: Int = 5): String {
|
||||
return a + b
|
||||
}
|
||||
|
||||
fun bar1(body: (String) -> String): String {
|
||||
return body("something")
|
||||
}
|
||||
|
||||
fun bar2(body: (String, Int) -> String): String {
|
||||
return body("something", 0)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>bar1<!>(::foo)
|
||||
bar2(::foo)
|
||||
}
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
|
||||
|
||||
fun <T, R> foo(x: T): R = TODO()
|
||||
|
||||
fun <T> fooReturnInt(x: T): Int = 1
|
||||
fun <T> fooTakeString(x: String): T = TODO()
|
||||
|
||||
fun <T, R> bar(x: T, y: R, f: (T) -> R): Pair<T, R> = TODO()
|
||||
fun <T, R> baz(f: (T) -> R, g: (T) -> R): Pair<T, R> = TODO()
|
||||
|
||||
class Pair<A, B>(val a: A, val b: B)
|
||||
|
||||
fun test1() {
|
||||
bar("", 1, ::foo).checkType { _<Pair<String, Int>>() }
|
||||
bar("", 1, ::fooReturnInt).checkType { _<Pair<String, Int>>() }
|
||||
bar("", 1, ::fooTakeString).checkType { _<Pair<String, Int>>() }
|
||||
bar("", "", ::fooReturnInt).checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Pair<String, Any>>() }
|
||||
|
||||
val x: String = bar("", "", ::fooReturnInt)
|
||||
|
||||
baz(Int::toString, ::foo).checkType { _<Pair<Int, String>>() }
|
||||
}
|
||||
|
||||
fun <T> listOf(): List<T> = TODO()
|
||||
fun <T> setOf(): Set<T> = TODO()
|
||||
|
||||
fun <T> test2(x: T) {
|
||||
bar(x, x, ::foo).checkType { _<Pair<T, T>>() }
|
||||
bar(x, 1, ::foo).checkType { _<Pair<T, Int>>() }
|
||||
bar(1, x, ::foo).checkType { _<Pair<Int, T>>() }
|
||||
|
||||
bar(listOf<T>(), setOf<T>(), ::foo).checkType { _<Pair<List<T>, Set<T>>> () }
|
||||
bar(listOf<T>(), 1, ::foo).checkType { _<Pair<List<T>, Int>>() }
|
||||
bar(1, listOf<T>(), ::foo).checkType { _<Pair<Int, List<T>>>() }
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class Case<T>
|
||||
fun <T> test(case: Case<T>) {}
|
||||
fun runTest(method: (Case<Any>) -> Unit) {}
|
||||
|
||||
fun <T> runTestGeneric(f: (Case<T>) -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
runTest(::test)
|
||||
runTestGeneric<Int>(::test)
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +SamConversionPerArgument +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public static void invokeLater(Runnable doRun) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun <T> foo(t: T, x: (() -> Unit) -> Unit) {}
|
||||
|
||||
fun <T> bar(s: T) {}
|
||||
fun <T> complex(t: T, f: (T) -> Unit) {}
|
||||
|
||||
fun test1() {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(1, A::invokeLater) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(1, ::bar)
|
||||
|
||||
complex(1, ::bar)
|
||||
}
|
||||
|
||||
fun <R> test2(x: R) {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(x, A::invokeLater) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
|
||||
foo(x, ::bar)
|
||||
|
||||
complex(x, ::bar)
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A1 {
|
||||
fun <T> a1(t: T): Unit {}
|
||||
fun test1(): (String) -> Unit = A1()::a1
|
||||
}
|
||||
|
||||
class A2 {
|
||||
fun <K, V> a2(key: K): V = TODO()
|
||||
|
||||
fun test1(): (String) -> Unit = A2()::a2
|
||||
fun <T3> test2(): (T3) -> T3 = A2()::a2
|
||||
}
|
||||
|
||||
class A3<T> {
|
||||
fun <V> a3(key: T): V = TODO()
|
||||
|
||||
fun test1(): (T) -> Int = this::a3
|
||||
fun test2(): (T) -> Unit = A3<T>()::a3
|
||||
fun test3(): (Int) -> String = A3<Int>()::a3
|
||||
|
||||
fun <R> test4(): (R) -> Unit = this::a3
|
||||
fun <R> test5(): (T) -> R = this::a3
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
|
||||
|
||||
fun <T> takeFun(f: (T) -> Unit) {}
|
||||
fun <T, R> callFun(f: (T) -> R): R = TODO()
|
||||
|
||||
fun <T> foo(s: T) {}
|
||||
fun <T : Int> fooInt(s: T) {}
|
||||
|
||||
open class Wrapper<T>(val value: T)
|
||||
fun <T, R : Wrapper<in T>> createWrapper(s: T): R = TODO()
|
||||
|
||||
fun <T> Wrapper<T>.baz(transform: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
takeFun<String>(::foo)
|
||||
<!INAPPLICABLE_CANDIDATE!>takeFun<!><String>(::fooInt)
|
||||
|
||||
callFun<String, Wrapper<String>>(::createWrapper)
|
||||
callFun<Int, Wrapper<Number>>(::createWrapper)
|
||||
callFun<String, Wrapper<*>>(::createWrapper)
|
||||
callFun<String, Wrapper<Int>>(::createWrapper)
|
||||
|
||||
callFun<Int, Wrapper<Int>>(::createWrapper).baz(::foo)
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
class Wrapper
|
||||
|
||||
fun <R, S> Wrapper.foo(x: R): S = TODO()
|
||||
fun Wrapper.fooIntString(x: Int): String = ""
|
||||
fun <T> Wrapper.fooReturnString(x: T): String = ""
|
||||
fun <T> Wrapper.fooTakeInt(x: Int): T = TODO()
|
||||
|
||||
fun <T, R, S> bar(f: T.(R) -> S): Tripple<T, R, S> = TODO()
|
||||
fun <T, R, S> baz(x: T, y: R, z: S, f: T.(R) -> S): Tripple<T, R, S> = TODO()
|
||||
|
||||
class Tripple<A, B, C>(val a: A, val b: B, val c: C)
|
||||
|
||||
fun test1() {
|
||||
val x: Wrapper.(String) -> Boolean = Wrapper::foo
|
||||
bar<Wrapper, Double, Float>(Wrapper::foo).checkType { _<Tripple<Wrapper, Double, Float>>() }
|
||||
bar(Wrapper::fooIntString).checkType { _<Tripple<Wrapper, Int, String>>() }
|
||||
}
|
||||
|
||||
fun <T> test2() {
|
||||
bar<Wrapper, Int, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, Int, String>>() }
|
||||
bar<Wrapper, T, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, T, String>>() }
|
||||
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, T, T>(Wrapper::fooReturnString)
|
||||
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, Int, Int>(Wrapper::fooReturnString)
|
||||
|
||||
bar<Wrapper, Int, T>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, T>>() }
|
||||
bar<Wrapper, Int, String>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, String>>() }
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
fun <T, R> foo(x: T): R = TODO()
|
||||
fun <T, R> bar(x: T, y: R, f: (T) -> R): Pair<T, R?> = TODO()
|
||||
|
||||
inline fun <reified T, reified R> baz(x: T, y: R, f: (T) -> R) {}
|
||||
|
||||
data class Pair<A, B>(val a: A, val b: B)
|
||||
|
||||
fun <T> test(x: T) {
|
||||
bar(1, "", ::foo).checkType { _<Pair<Int, String?>>() }
|
||||
bar(null, "", ::foo).checkType { _<Pair<Nothing?, String?>>() }
|
||||
bar(1, null, ::foo).checkType { _<Pair<Int, Nothing?>>() }
|
||||
bar(null, null, ::foo).checkType { _<Pair<Nothing?, Nothing?>>() }
|
||||
bar(1, x, ::foo).checkType { _<Pair<Int, T?>>() }
|
||||
|
||||
val s1: Pair<Int, String?> = bar(1, "", ::foo)
|
||||
val (a: Int, b: String?) = bar(1, "", ::foo)
|
||||
|
||||
val s2: Pair<Int?, String?> = bar(null, null, ::foo)
|
||||
|
||||
baz<Int?, String?>(null, null, ::foo)
|
||||
|
||||
baz<Int, String?>(null, null, ::foo)
|
||||
baz<Int?, String>(null, null, ::foo)
|
||||
baz(null, "", ::foo)
|
||||
baz(1, null, ::foo)
|
||||
baz(null, null, ::foo)
|
||||
|
||||
val s3: Pair<Int, String?> = bar(null, null, ::foo)
|
||||
val s4: Pair<Int?, String> = bar(null, null, ::foo)
|
||||
|
||||
val s5: Pair<Int, String> = bar(1, "", ::foo)
|
||||
val (a1: Int, b1: String) = bar(1, "", ::foo)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// KT-10968 Callable reference: type inference by function return type
|
||||
|
||||
fun <T> getT(): T = null!!
|
||||
|
||||
fun getString() = ""
|
||||
|
||||
fun test() {
|
||||
val a : () -> String = ::getString
|
||||
val b : () -> String = ::getT
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// KT-11075 NONE_APPLICABLE reported for callable reference to an overloaded generic function with expected type provided
|
||||
|
||||
object TestCallableReferences {
|
||||
fun <A> foo(x: A) = x
|
||||
fun <B> foo(x: List<B>) = x
|
||||
|
||||
fun test0(): (String) -> String = TestCallableReferences::foo
|
||||
|
||||
fun <T> test1(): (List<T>) -> List<T> = <!UNRESOLVED_REFERENCE!>TestCallableReferences::foo<!>
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// KT-12286 Strange type is required for generic callable reference
|
||||
|
||||
fun <T: Comparable<T>> maxOf(a: T, b: T): T = if (a < b) b else a
|
||||
|
||||
fun <T: Comparable<T>> useMaxOf() {
|
||||
val f: (T, T) -> T = ::maxOf
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
|
||||
fun <T> shuffle(x: List<T>): List<T> = x
|
||||
|
||||
fun bar() {
|
||||
val s: (List<String>) -> List<String> = ::shuffle
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
|
||||
|
||||
fun foo(i: Int) {}
|
||||
fun foo(s: String) {}
|
||||
fun <T> id(x: T): T = x
|
||||
fun <T> baz(x: T, y: T): T = TODO()
|
||||
|
||||
fun test() {
|
||||
val x1: (Int) -> Unit = id(id(::foo))
|
||||
val x2: (Int) -> Unit = baz(id(::foo), ::foo)
|
||||
val x3: (Int) -> Unit = baz(id(::foo), id(id(::foo)))
|
||||
val x4: (String) -> Unit = baz(id(::foo), id(id(::foo)))
|
||||
val x5: (Double) -> Unit = baz(id(<!UNRESOLVED_REFERENCE!>::foo<!>), id(id(<!UNRESOLVED_REFERENCE!>::foo<!>)))
|
||||
|
||||
|
||||
id<(Int) -> Unit>(id(id(<!UNRESOLVED_REFERENCE!>::foo<!>)))
|
||||
id(id<(Int) -> Unit>(::foo))
|
||||
baz<(Int) -> Unit>(id(<!UNRESOLVED_REFERENCE!>::foo<!>), id(id(<!UNRESOLVED_REFERENCE!>::foo<!>)))
|
||||
baz(id(<!UNRESOLVED_REFERENCE!>::foo<!>), id(id<(Int) -> Unit>(::foo)))
|
||||
baz(id(<!UNRESOLVED_REFERENCE!>::foo<!>), id<(Int) -> Unit>(id(::foo)))
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
// !LANGUAGE: -TypeInferenceOnGenericsForCallableReferences
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
|
||||
|
||||
fun <T> bar(s: T) {}
|
||||
fun <T> complex(t: T, f: (T) -> Unit) {}
|
||||
fun <T> simple(f: (T) -> Unit) {}
|
||||
|
||||
fun test1() {
|
||||
complex(1, ::bar)
|
||||
simple<String>(::bar)
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
fun <T> takeFun(f: (T) -> Unit) {}
|
||||
fun <T, R> callFun(f: (T) -> R): R = TODO()
|
||||
|
||||
fun <T> foo(s: T) {}
|
||||
|
||||
open class Wrapper<T>(val value: T)
|
||||
fun <T, R : Wrapper<in T>> createWrapper(s: T): R = TODO()
|
||||
|
||||
fun <T> Wrapper<T>.baz(transform: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test2() {
|
||||
takeFun<String>(::foo)
|
||||
|
||||
callFun<String, Wrapper<String>>(::createWrapper)
|
||||
callFun<Int, Wrapper<Number>>(::createWrapper)
|
||||
callFun<String, Wrapper<*>>(::createWrapper)
|
||||
|
||||
callFun<Int, Wrapper<Int>>(::createWrapper).baz(::foo)
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
fun test3() {
|
||||
val a1: Array<Double.(Double) -> Double> = arrayOf(Double::plus, Double::minus)
|
||||
val a2: Array<Double.(Int) -> Double> = arrayOf(Double::plus, Double::minus)
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
class A1 {
|
||||
fun <T> a1(t: T): Unit {}
|
||||
fun test1(): (String) -> Unit = A1()::a1
|
||||
}
|
||||
|
||||
class A2 {
|
||||
fun <K, V> a2(key: K): V = TODO()
|
||||
|
||||
fun test1(): (String) -> Unit = A2()::a2
|
||||
fun <T3> test2(): (T3) -> T3 = A2()::a2
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
fun foo1(x: Int?) {}
|
||||
fun foo1(y: String?) {}
|
||||
fun foo1(z: Boolean) {}
|
||||
|
||||
fun <T> baz1(element: (T) -> Unit): T? = null
|
||||
|
||||
fun test4() {
|
||||
val a1: Int? = baz1(::foo1)
|
||||
val a2: String? = baz1(::foo1)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
fun foo(x: Int?) {}
|
||||
fun foo(y: String?) {}
|
||||
fun foo(z: Boolean) {}
|
||||
|
||||
fun <T> baz(element: (T) -> Unit): T? = null
|
||||
|
||||
fun test1() {
|
||||
val a1: Int? = baz(::foo)
|
||||
val a2: String? = baz(::foo)
|
||||
val a3: Boolean? = baz<Boolean>(::foo)
|
||||
|
||||
baz<Int>(::foo).checkType { _<Int?>() }
|
||||
baz<String>(::foo).checkType { _<String?>() }
|
||||
baz<Boolean>(::foo).checkType { _<Boolean?>() }
|
||||
|
||||
val b1: Int = baz(<!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
val b2: String = baz(<!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
val b3: Boolean = baz(<!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
fun test() {
|
||||
val a1: Array<Double.(Double) -> Double> = arrayOf(Double::plus, Double::minus)
|
||||
val a2: Array<Double.(Int) -> Double> = arrayOf(Double::plus, Double::minus)
|
||||
|
||||
val a3: Array<Int.(Int) -> Double> = arrayOf(<!UNRESOLVED_REFERENCE!>Double::plus<!>, <!UNRESOLVED_REFERENCE!>Double::minus<!>)
|
||||
val a4: Array<Int.(Double) -> Double> = arrayOf(Int::plus, <!UNRESOLVED_REFERENCE!>Double::minus<!>)
|
||||
val a5: Array<Double.(Double) -> Double> = arrayOf(Double::plus, <!UNRESOLVED_REFERENCE!>Int::minus<!>)
|
||||
}
|
||||
|
||||
fun foo(x: Int) {}
|
||||
fun foo(y: String) {}
|
||||
|
||||
fun <T> bar(x: T, f: (T) -> Unit) {}
|
||||
|
||||
fun test2() {
|
||||
bar(1, ::foo)
|
||||
bar("", ::foo)
|
||||
<!INAPPLICABLE_CANDIDATE!>bar<!>(1.0, <!UNRESOLVED_REFERENCE!>::foo<!>)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
fun baz(i: Int) = i
|
||||
fun <T> bar(x: T): T = TODO()
|
||||
|
||||
fun nullableFun(): ((Int) -> Int)? = null
|
||||
|
||||
fun test() {
|
||||
val x1: (Int) -> Int = bar(if (true) <!UNRESOLVED_REFERENCE!>::baz<!> else <!UNRESOLVED_REFERENCE!>::baz<!>)
|
||||
val x2: (Int) -> Int = bar(nullableFun() ?: <!UNRESOLVED_REFERENCE!>::baz<!>)
|
||||
val x3: (Int) -> Int = bar(::baz ?: <!UNRESOLVED_REFERENCE!>::baz<!>)
|
||||
|
||||
val i = 0
|
||||
val x4: (Int) -> Int = bar(when (i) {
|
||||
10 -> <!UNRESOLVED_REFERENCE!>::baz<!>
|
||||
20 -> <!UNRESOLVED_REFERENCE!>::baz<!>
|
||||
else -> <!UNRESOLVED_REFERENCE!>::baz<!>
|
||||
})
|
||||
|
||||
val x5: (Int) -> Int = bar(<!UNRESOLVED_REFERENCE!>::baz<!>!!)
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>(if (true) <!UNRESOLVED_REFERENCE!>::baz<!> else <!UNRESOLVED_REFERENCE!>::baz<!>)(1)<!>
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_VARIABLE
|
||||
|
||||
fun test() {
|
||||
data class Pair<F, S>(val first: F, val second: S)
|
||||
val (x, y) =
|
||||
Pair(1,
|
||||
if (1 == 1)
|
||||
<!UNRESOLVED_REFERENCE!>Pair<String, String>::first<!>
|
||||
else
|
||||
<!UNRESOLVED_REFERENCE!>Pair<String, String>::second<!>)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// Issue: KT-25433
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun <T, R> hidden(nameProp: KProperty1<T, R>, value: R) {}
|
||||
fun <T, R> hiddenFun(nameFunc: KFunction1<T, R>, value: R) {}
|
||||
|
||||
class App(val nullable: String?) {
|
||||
fun nullableFun(): String? = null
|
||||
}
|
||||
|
||||
fun test() {
|
||||
hidden(App::nullable, "foo")
|
||||
hiddenFun(App::nullableFun, "foo")
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
|
||||
class Inv<T> {
|
||||
val size: Int = 0
|
||||
}
|
||||
|
||||
class DTO<T> {
|
||||
val test: Inv<T>? = null
|
||||
var q: Int = 0
|
||||
operator fun <R> get(prop: KProperty1<*, R>): R = TODO()
|
||||
operator fun <R> set(prop: KMutableProperty1<*, R>, value: R) { }
|
||||
}
|
||||
|
||||
fun main(intDTO: DTO<Int>?) {
|
||||
if (intDTO != null) {
|
||||
intDTO[DTO<Int>::q] = intDTO[DTO<Int>::test]!!.size
|
||||
intDTO[DTO<Int>::q] = intDTO[DTO<Int>::test]!!.size
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// Issue: KT-32256
|
||||
|
||||
fun main() {
|
||||
myMethod(::refA)
|
||||
myMethod(::refB)
|
||||
anotherMethod(::refA)
|
||||
anotherMethod(::refB)
|
||||
}
|
||||
|
||||
suspend fun refA(input: String): String {
|
||||
return input
|
||||
}
|
||||
|
||||
suspend fun refB(): String {
|
||||
return "Hello, World!"
|
||||
}
|
||||
|
||||
fun myMethod(f: suspend (String) -> String) {}
|
||||
|
||||
fun myMethod(f: suspend () -> String) {}
|
||||
|
||||
fun <I, O> anotherMethod(f: suspend (I) -> O) {}
|
||||
|
||||
fun <O> anotherMethod(f: suspend () -> O) {}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user