[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
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
|
||||
}
|
||||
Reference in New Issue
Block a user