NI: take into account an extension function annotation during CST calculation

This commit is contained in:
Victor Petukhov
2020-03-31 19:39:52 +03:00
parent f8d72f5dd9
commit 164f25937f
8 changed files with 122 additions and 11 deletions
@@ -0,0 +1,47 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -CAST_NEVER_SUCCEEDS
// ISSUE: KT-36819
// Case 1
fun <K> select(vararg x: K) = x[0]
interface A
class B: A
class C: A
fun <T> id1(x: T): T = x
fun <R> id2(x: R): R = x
class Out<out R>(x: R)
fun main() {
val x1 = select(id1 { B() }, id2 { C() })
val x2 = select({ B() }, { C() })
val x3 = select(id1(Out(B())), id2(Out(C())))
}
// Case 2
fun <R> fold(initial: R, operation: (R) -> Unit) {}
fun foo() {
fold({ x: Int -> x }) { acc -> }
}
// Case 3
class Foo
typealias X = Foo.(Foo.() -> Unit) -> Unit
fun bar() {
val y = when {
false -> { _ ->
Unit
}
true -> null as X
else -> { x ->
<!UNRESOLVED_REFERENCE!>x<!>()
Unit
}
}
}
+24 -2
View File
@@ -1,8 +1,9 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -CAST_NEVER_SUCCEEDS
// ISSUE: KT-36819
// Case 1
fun <K> select(vararg x: K) = x[0]
interface A
class B: A
@@ -18,8 +19,29 @@ fun main() {
val x3 = select(id1(Out(B())), id2(Out(C())))
}
// Case 2
fun <R> fold(initial: R, operation: (R) -> Unit) {}
fun foo() {
fold({ x: Int -> x }) { acc -> }
}
// Case 3
class Foo
typealias X = Foo.(Foo.() -> Unit) -> Unit
fun bar() {
val y = when {
false -> { _ ->
Unit
}
true -> null as X
else -> { x ->
x()
Unit
}
}
}
@@ -1,5 +1,6 @@
package
public fun bar(): kotlin.Unit
public fun </*0*/ R> fold(/*0*/ initial: R, /*1*/ operation: (R) -> kotlin.Unit): kotlin.Unit
public fun foo(): kotlin.Unit
public fun </*0*/ T> id1(/*0*/ x: T): T
@@ -27,9 +28,17 @@ public final class C : A {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Foo {
public constructor Foo()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Out</*0*/ out R> {
public constructor Out</*0*/ out R>(/*0*/ x: R)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias X = Foo.(Foo.() -> kotlin.Unit) -> kotlin.Unit