[FIR2IR] Insert implicit coercion to unit in adapted function references
^KT-60260 Fixed
This commit is contained in:
committed by
Space Team
parent
99d5ee4db8
commit
a8914acb68
+4
-3
@@ -69,8 +69,9 @@ FILE fqName:<root> fileName:/samConversionInVarargs.kt
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVarargOfInt visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun withVarargOfInt (vararg xs: kotlin.Int): kotlin.String declared in <root>' type=kotlin.String origin=null
|
||||
xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int
|
||||
GET_VAR 'p0: kotlin.Int declared in <root>.testAdaptedCR.withVarargOfInt' type=kotlin.Int origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun withVarargOfInt (vararg xs: kotlin.Int): kotlin.String declared in <root>' type=kotlin.String origin=null
|
||||
xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int
|
||||
GET_VAR 'p0: kotlin.Int declared in <root>.testAdaptedCR.withVarargOfInt' type=kotlin.Int origin=null
|
||||
TYPE_OP type=<root>.IFoo origin=SAM_CONVERSION typeOperand=<root>.IFoo
|
||||
FUNCTION_REFERENCE 'local final fun withVarargOfInt (p0: kotlin.Int): kotlin.Unit declared in <root>.testAdaptedCR' type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun withVarargOfInt (vararg xs: kotlin.Int): kotlin.String declared in <root>
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ fun withVarargOfInt(vararg xs: Int): String {
|
||||
fun testAdaptedCR() {
|
||||
useVararg(foos = [{ // BLOCK
|
||||
local fun withVarargOfInt(p0: Int) {
|
||||
withVarargOfInt(xs = [p0])
|
||||
withVarargOfInt(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
|
||||
::withVarargOfInt /*-> IFoo */
|
||||
|
||||
Vendored
-56
@@ -1,56 +0,0 @@
|
||||
FILE fqName:<root> fileName:/samConversionOnCallableReference.kt
|
||||
CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.KRunnable
|
||||
FUN name:run visibility:public modality:ABSTRACT <> ($this:<root>.KRunnable) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.KRunnable
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:foo0 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
FUN name:foo1 visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.Int
|
||||
VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in <root>'
|
||||
CONST Int type=kotlin.Int value=1
|
||||
FUN name:use visibility:public modality:FINAL <> (r:<root>.KRunnable) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:r index:0 type:<root>.KRunnable
|
||||
BLOCK_BODY
|
||||
FUN name:testSamConstructor visibility:public modality:FINAL <> () returnType:<root>.KRunnable
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testSamConstructor (): <root>.KRunnable declared in <root>'
|
||||
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
||||
FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction0<kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
FUN name:testSamCosntructorOnAdapted visibility:public modality:FINAL <> () returnType:<root>.KRunnable
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testSamCosntructorOnAdapted (): <root>.KRunnable declared in <root>'
|
||||
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
||||
BLOCK type=kotlin.Function0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo1 visibility:local modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit declared in <root>.testSamCosntructorOnAdapted' type=kotlin.Function0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in <root>
|
||||
FUN name:testSamConversion visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun use (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r: TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
||||
FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in <root>' type=kotlin.reflect.KFunction0<kotlin.Unit> origin=null reflectionTarget=<same>
|
||||
FUN name:testSamConversionOnAdapted visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun use (r: <root>.KRunnable): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
r: BLOCK type=<root>.KRunnable origin=ADAPTED_FUNCTION_REFERENCE
|
||||
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo1 visibility:local modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
TYPE_OP type=<root>.KRunnable origin=SAM_CONVERSION typeOperand=<root>.KRunnable
|
||||
FUNCTION_REFERENCE 'local final fun foo1 (): kotlin.Unit declared in <root>.testSamConversionOnAdapted' type=kotlin.Function0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in <root>
|
||||
Vendored
-43
@@ -1,43 +0,0 @@
|
||||
fun interface KRunnable {
|
||||
abstract fun run()
|
||||
|
||||
}
|
||||
|
||||
fun foo0() {
|
||||
}
|
||||
|
||||
fun foo1(vararg xs: Int): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun use(r: KRunnable) {
|
||||
}
|
||||
|
||||
fun testSamConstructor(): KRunnable {
|
||||
return ::foo0 /*-> KRunnable */
|
||||
}
|
||||
|
||||
fun testSamCosntructorOnAdapted(): KRunnable {
|
||||
return { // BLOCK
|
||||
local fun foo1() {
|
||||
foo1()
|
||||
}
|
||||
|
||||
::foo1
|
||||
} /*-> KRunnable */
|
||||
}
|
||||
|
||||
fun testSamConversion() {
|
||||
use(r = ::foo0 /*-> KRunnable */)
|
||||
}
|
||||
|
||||
fun testSamConversionOnAdapted() {
|
||||
use(r = { // BLOCK
|
||||
local fun foo1() {
|
||||
foo1()
|
||||
}
|
||||
|
||||
::foo1 /*-> KRunnable */
|
||||
})
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
fun interface KRunnable {
|
||||
fun run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user