NI: take into account an extension function annotation during CST calculation
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user