FIR: allow lower bound of flexible type when finding contributed invoke
This commit is contained in:
committed by
TeamCityServer
parent
4a24f0fab3
commit
3bca6ae893
@@ -402,7 +402,7 @@ fun FirExpression.isFunctional(
|
|||||||
if (coneType.isBuiltinFunctionalType(session)) {
|
if (coneType.isBuiltinFunctionalType(session)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
val classLikeExpectedFunctionType = expectedFunctionType as? ConeClassLikeType
|
val classLikeExpectedFunctionType = expectedFunctionType?.lowerBoundIfFlexible() as? ConeClassLikeType
|
||||||
if (classLikeExpectedFunctionType == null || coneType is ConeIntegerLiteralType) {
|
if (classLikeExpectedFunctionType == null || coneType is ConeIntegerLiteralType) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public interface MyListener<F extends MyFuture<?>> {
|
|||||||
typealias Handler = (cause: Throwable?) -> Unit
|
typealias Handler = (cause: Throwable?) -> Unit
|
||||||
|
|
||||||
fun <T> MyFuture<T>.setup() {
|
fun <T> MyFuture<T>.setup() {
|
||||||
addListener(ListenerImpl<T, MyFuture<T>>())
|
<!INAPPLICABLE_CANDIDATE!>addListener<!>(ListenerImpl<T, MyFuture<T>>())
|
||||||
addListener { }
|
addListener { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -49,11 +49,11 @@ fun test6(a: Any) {
|
|||||||
|
|
||||||
fun test7(a: (Int) -> Int) {
|
fun test7(a: (Int) -> Int) {
|
||||||
a as () -> Unit
|
a as () -> Unit
|
||||||
J().<!INAPPLICABLE_CANDIDATE!>run1<!>(a)
|
J().run1(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test8(a: () -> Unit) {
|
fun test8(a: () -> Unit) {
|
||||||
J().<!INAPPLICABLE_CANDIDATE!>run1<!>(J.id(a))
|
J().run1(J.id(a))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test9() {
|
fun test9() {
|
||||||
|
|||||||
+7
-7
@@ -1,24 +1,24 @@
|
|||||||
fun test1(a: Function0<Unit>) {
|
fun test1(a: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is Runnable -> runStatic(r = a /*as Runnable */)
|
a is Runnable -> runStatic(r = a /*as Runnable */ /*-> Runnable? */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(a: Function0<Unit>) {
|
fun test2(a: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is Runnable -> J().run1(r = a /*as Runnable */)
|
a is Runnable -> J().run1(r = a /*as Runnable */ /*-> Runnable? */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test3(a: Function0<Unit>) {
|
fun test3(a: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is Runnable -> J().run2(r1 = a /*as Runnable */, r2 = a /*as Runnable */)
|
a is Runnable -> J().run2(r1 = a /*as Runnable */ /*-> Runnable? */, r2 = a /*as Runnable */ /*-> Runnable? */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
||||||
when {
|
when {
|
||||||
a is Runnable -> J().run2(r1 = a /*as Runnable */, r2 = b /*-> Runnable? */)
|
a is Runnable -> J().run2(r1 = a /*as Runnable */ /*-> Runnable? */, r2 = b /*-> Runnable? */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ fun test5x(a: Any) {
|
|||||||
when {
|
when {
|
||||||
a is Runnable -> { // BLOCK
|
a is Runnable -> { // BLOCK
|
||||||
a /*as Runnable */ as Function0<Unit> /*~> Unit */
|
a /*as Runnable */ as Function0<Unit> /*~> Unit */
|
||||||
J().run1(r = a /*as Runnable */)
|
J().run1(r = a /*as Runnable */ /*-> Runnable? */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,11 +44,11 @@ fun test6(a: Any) {
|
|||||||
|
|
||||||
fun test7(a: Function1<Int, Int>) {
|
fun test7(a: Function1<Int, Int>) {
|
||||||
a as Function0<Unit> /*~> Unit */
|
a as Function0<Unit> /*~> Unit */
|
||||||
error("") /* ErrorCallExpression */a /*as Function0<Unit> */;
|
J().run1(r = a /*as Function0<Unit> */ /*-> Runnable? */)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test8(a: Function0<Unit>) {
|
fun test8(a: Function0<Unit>) {
|
||||||
error("") /* ErrorCallExpression */id<Function0<Unit>?>(x = a);
|
J().run1(r = id<Function0<Unit>?>(x = a) /*-> Runnable? */)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test9() {
|
fun test9() {
|
||||||
|
|||||||
+29
-19
@@ -7,8 +7,9 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
|
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=java.lang.Runnable
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public open fun runStatic (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
then: CALL 'public open fun runStatic (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
@@ -18,8 +19,9 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
then: CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test2' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
@@ -29,10 +31,12 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public open fun run2 (r1: java.lang.Runnable?, r2: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
then: CALL 'public open fun run2 (r1: java.lang.Runnable?, r2: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
r1: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
r2: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
r2: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
|
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test3' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>, b:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:b index:1 type:kotlin.Function0<kotlin.Unit>
|
||||||
@@ -43,8 +47,9 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
then: CALL 'public open fun run2 (r1: java.lang.Runnable?, r2: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
then: CALL 'public open fun run2 (r1: java.lang.Runnable?, r2: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
r1: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
|
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
r2: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
r2: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
GET_VAR 'b: kotlin.Function0<kotlin.Unit> declared in <root>.test4' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||||
@@ -72,8 +77,9 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||||
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable
|
||||||
|
GET_VAR 'a: kotlin.Any declared in <root>.test5x' type=kotlin.Any origin=null
|
||||||
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
@@ -91,16 +97,20 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
|||||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||||
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
||||||
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
||||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): /J.run1>#' type=kotlin.Unit
|
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
|
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_CAST typeOperand=kotlin.Function0<kotlin.Unit>
|
||||||
|
GET_VAR 'a: kotlin.Function1<kotlin.Int, kotlin.Int> declared in <root>.test7' type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=null
|
||||||
FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): /J.run1>#' type=kotlin.Unit
|
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
CALL 'public open fun id <T> (x: T of <root>.J.id?): T of <root>.J.id? declared in <root>.J' type=kotlin.Function0<kotlin.Unit>? origin=null
|
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
|
||||||
<T>: kotlin.Function0<kotlin.Unit>?
|
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
|
||||||
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
|
CALL 'public open fun id <T> (x: T of <root>.J.id?): T of <root>.J.id? declared in <root>.J' type=kotlin.Function0<kotlin.Unit>? origin=null
|
||||||
|
<T>: kotlin.Function0<kotlin.Unit>?
|
||||||
|
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||||
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
|
|||||||
Reference in New Issue
Block a user