Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed
This commit is contained in:
Vendored
-18
@@ -1,18 +0,0 @@
|
||||
// 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
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: 1.kt
|
||||
|
||||
package a
|
||||
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
// 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
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: 1.kt
|
||||
|
||||
package a
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// !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
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
object Obj {
|
||||
fun foo() {}
|
||||
val bar = 2
|
||||
}
|
||||
|
||||
fun test() {
|
||||
checkSubtype<() -> Unit>(Obj::foo)
|
||||
checkSubtype<() -> Int>(Obj::bar)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
object Obj {
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// FILE: A.java
|
||||
|
||||
class A {
|
||||
public CharSequence getFoo() { return null; }
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
with (A()) {
|
||||
foo::toString
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
|
||||
class A {
|
||||
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
fun <T: Any> get(t: T): () -> String {
|
||||
return t::toString
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
fun <T: Any> get(t: T): () -> String {
|
||||
return t::toString
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// 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
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// MODULE: m1
|
||||
// FILE: 1.kt
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// !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
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION, -EXTENSION_SHADOWED_BY_MEMBER
|
||||
// !LANGUAGE: +CallableReferencesToClassMembersWithEmptyLHS
|
||||
|
||||
|
||||
compiler/testData/diagnostics/tests/callableReference/function/callableRefrenceOnNestedObject.fir.kt
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
open class A {
|
||||
fun foo() = 42
|
||||
|
||||
object B: A()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
(A::foo)(A.B)
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
open class A {
|
||||
fun foo() = 42
|
||||
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// !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)
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.kt
|
||||
|
||||
open class A<T>(val x: T)
|
||||
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
// !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)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
// !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
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
val x = ::A
|
||||
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
val x = :: <!SYNTAX!><!>;
|
||||
val y = A::
|
||||
<!SYNTAX!><!>}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class A
|
||||
|
||||
fun main() {
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !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
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS:-UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
class A<T>(val t: T) {
|
||||
fun foo(): T = t
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
val x = A<String>::foo
|
||||
|
||||
checkSubtype<KFunction1<A<String>, String>>(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// !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
|
||||
checkSubtype<KFunction1<Array<String>, Unit>>(main2)
|
||||
main2(args)
|
||||
(A::main)(args)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// FILE: test/A.java
|
||||
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
val x = ::A
|
||||
checkSubtype<KFunction0<A>>(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// !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)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
compiler/testData/diagnostics/tests/callableReference/function/localConstructorFromLocalClass.fir.kt
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun main() {
|
||||
class A
|
||||
|
||||
class B {
|
||||
val x = ::A
|
||||
val f: KFunction0<A> = x
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
fun main() {
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// !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)
|
||||
}
|
||||
}
|
||||
compiler/testData/diagnostics/tests/callableReference/function/localConstructorFromLocalExtension.kt
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// !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)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// FILE: a.kt
|
||||
|
||||
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
class A {
|
||||
class Nested
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x = A::Nested
|
||||
|
||||
checkSubtype<KFunction0<A.Nested>>(x)
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction0
|
||||
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
fun bar() = 42
|
||||
|
||||
fun main() {
|
||||
fun bar() = 239
|
||||
|
||||
::bar
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
fun bar() = 42
|
||||
|
||||
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// 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)
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// SKIP_TXT
|
||||
// FILE: A.java
|
||||
class A {
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// !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() {
|
||||
bar1(::foo)
|
||||
bar2(::foo)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType
|
||||
|
||||
fun foo(a: String, b: Int = 5): String {
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !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)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class Case<T>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// !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
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// KT-10968 Callable reference: type inference by function return type
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// !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
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// KT-12286 Strange type is required for generic callable reference
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// ISSUE: KT-35896
|
||||
|
||||
interface B<E, SC>
|
||||
|
||||
class Inv<T>
|
||||
|
||||
class Foo<T>(x: Int): B<T, Inv<T>>
|
||||
|
||||
fun <T1, T2, S> bar(list: T2, fn: (S) -> B<T1, T2>) {}
|
||||
|
||||
fun <K> foo(list: Inv<K>) {
|
||||
bar(list, ::Foo)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// ISSUE: KT-35896
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
|
||||
fun <T> shuffle(x: List<T>): List<T> = x
|
||||
|
||||
fun bar() {
|
||||
val s: (List<String>) -> List<String> = ::shuffle
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <A1> fun2(f: kotlin.reflect.KFunction1<A1, Unit>, a: A1) {
|
||||
f.invoke(a)
|
||||
}
|
||||
|
||||
fun containsRegex(vararg otherPatterns: String) {}
|
||||
|
||||
fun main() {
|
||||
fun2(::containsRegex, arrayOf("foo"))
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
// !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)
|
||||
Pair<String, String>::first
|
||||
else
|
||||
Pair<String, String>::second)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_VARIABLE
|
||||
|
||||
fun test() {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// !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")
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// Issue: KT-25433
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// !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) {}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// Issue: KT-32256
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// ISSUE: KT-35959
|
||||
|
||||
interface Expect<T>
|
||||
|
||||
inline val <T> Expect<T>.and: Expect<T> get() = this
|
||||
infix fun <T> Expect<T>.and(assertionCreator: Expect<T>.() -> Unit): Expect<T> = this
|
||||
|
||||
fun <K> id(x: K): K = x
|
||||
|
||||
fun test(): Expect<Int>.(Expect<Int>.() -> Unit) -> Expect<Int> = id(Expect<Int>::and)
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// ISSUE: KT-35959
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
import kotlin.reflect.KFunction1
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
object Foo {
|
||||
fun <T> bar(fn: KFunction1<T, Boolean>): String = ""
|
||||
fun <T, U> bar(fn: KFunction2<T, U, Boolean>): Int = 10
|
||||
}
|
||||
|
||||
class A
|
||||
class B
|
||||
|
||||
fun A.test() = true // everything is OK without this line
|
||||
fun B.test() = true
|
||||
|
||||
fun main() {
|
||||
val x = Foo.bar(B::test) // ambiguity in NI
|
||||
}
|
||||
compiler/testData/diagnostics/tests/callableReference/noAmbiguityWhenAllReferencesAreInapplicable.kt
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
open class Base {
|
||||
val foo: Int = 42
|
||||
}
|
||||
|
||||
open class Derived : Base()
|
||||
|
||||
fun test() {
|
||||
val o = Base::foo
|
||||
checkSubtype<KProperty1<Base, Int>>(o)
|
||||
checkSubtype<Int>(o.get(Derived()))
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !DIAGNOSTICS:-UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A(var g: A) {
|
||||
val f: Int = 0
|
||||
|
||||
fun test() {
|
||||
val fRef: KProperty1<A, Int> = A::f
|
||||
val gRef: KMutableProperty1<A, A> = A::g
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS:-UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
val Any?.meaning: Int
|
||||
get() = 42
|
||||
|
||||
fun test() {
|
||||
val f = Any?::meaning
|
||||
checkSubtype<Int>(f.get(null))
|
||||
checkSubtype<Int>(f.get(""))
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
val Any?.meaning: Int
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// SKIP_TXT
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun check1(p: kotlin.reflect.KProperty1<*, *>) {}
|
||||
fun check2(p: kotlin.reflect.KProperty1<in String, *>) {}
|
||||
|
||||
val CharSequence.x: Any get() = this
|
||||
val BooleanArray.x: Any get() = this
|
||||
|
||||
fun box() {
|
||||
check1(CharSequence::x) // error in NI, ok in OI
|
||||
check2(CharSequence::x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// SKIP_TXT
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
class A<T>(val t: T) {
|
||||
val foo: T = t
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
val x = A<String>::foo
|
||||
checkSubtype<KProperty1<A<String>, String>>(x)
|
||||
checkSubtype<KProperty1<A<String>, Any?>>(x)
|
||||
|
||||
val y = A<*>::foo
|
||||
checkSubtype<KProperty1<A<*>, Any?>>(y)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun <T> checkSubtype(t: T) = t
|
||||
|
||||
class A(var g: A) {
|
||||
val f: Int = 0
|
||||
|
||||
fun test() {
|
||||
checkSubtype<KProperty1<A, Int>>(A::f)
|
||||
checkSubtype<KMutableProperty1<A, A>>(A::g)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun <T> checkSubtype(t: T) = t
|
||||
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// KT-12982 Incorrect type inference when accessing mutable protected property via reflection
|
||||
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
|
||||
class Foo {
|
||||
protected var x = 0
|
||||
|
||||
fun baz(p: KMutableProperty1<Foo, Int>) = p
|
||||
fun print() = baz(Foo::x)
|
||||
}
|
||||
|
||||
|
||||
open class A {
|
||||
protected fun a() {}
|
||||
}
|
||||
|
||||
open class B : A() {
|
||||
val x = C::a
|
||||
val y = C()::a
|
||||
}
|
||||
|
||||
class C : B()
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// KT-12982 Incorrect type inference when accessing mutable protected property via reflection
|
||||
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
fun <T, R> getProperty(x: T, property: KProperty1<T, R>): R =
|
||||
property.get(x)
|
||||
|
||||
class Person(val name: String)
|
||||
|
||||
val name1 = getProperty(Person("John Smith"), Person::name)
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
fun <T, R> getProperty(x: T, property: KProperty1<T, R>): R =
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun foo(s: String) {}
|
||||
|
||||
object Scope {
|
||||
fun foo(a: Int) {}
|
||||
fun foo(b: Boolean) {}
|
||||
|
||||
fun <T> bar(f: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
val s: String = bar(::foo)
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
fun fn(f: () -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
fn(::foo)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class Foo
|
||||
|
||||
fun test(fn: KFunction2<Foo, Array<out String>, String>) = null
|
||||
|
||||
fun Foo.bar(vararg x: String) = ""
|
||||
fun Foo.bar(vararg x: Int) = ""
|
||||
|
||||
|
||||
fun actualTest() {
|
||||
test(Foo::bar)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test() {
|
||||
foo(String::extensionReceiver)
|
||||
foo(::valueParameter)
|
||||
}
|
||||
|
||||
fun CharSequence.extensionReceiver(): CharSequence = TODO()
|
||||
fun String.extensionReceiver(): String = TODO()
|
||||
|
||||
fun valueParameter(c: CharSequence): CharSequence = TODO()
|
||||
fun valueParameter(s: String): CharSequence = TODO()
|
||||
|
||||
fun <R> foo(f: (String) -> R) {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user